All guides

Helm or Kustomize: which one for which job

Helm's documentation calls Helm the package manager for Kubernetes. Kustomize's README says it customizes raw, template-free YAML and leaves the original untouched. The two projects' own pages show which jobs each one covers.

Python code on a screen, seen at an angle

Templating versus patching

A Helm chart holds a templates/ directory and a values.yaml. The chart documentation says the templates, when combined with values, generate valid Kubernetes manifest files. This is from the Deployment template that helm create generates:

Text

spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}

To configure a chart for an environment, the Helm introduction says, you supply different values to the same chart.

Kustomize works on YAML with no templates. Its patches add or override fields on resources, as a strategic merge patch or a JSON6902 patch, from a file or inline:

YAML

patches:
  - target:
      kind: Deployment
      name: my-app
    patch: |-
      - op: replace
        path: /spec/replicas
        value: 4

The Deployment name and the replica count are this example's. Built with kubectl kustomize over a base that holds a Deployment named my-app, this patch produced replicas: 4.

Packaging and distribution

Helm bundles related manifests into one unit, the chart. A chart is versioned, shared, installed and rolled back as a single release. helm package writes an archive named after the chart and its version, and helm push uploads it to an OCI registry. The Helm documentation recommends registries with OCI support for storing and sharing charts. A chart can declare dependencies on other charts in Chart.yaml.

For Kustomize, the Kubernetes documentation says a base is a directory with a kustomization.yaml, either a local directory or a directory from a remote repository. A resources entry can be a URL with a ?ref= revision. Since version 1.14, kubectl supports kustomization files directly, with kubectl apply -k.

Release tracking and rollback

Helm stores release information, by default in Secrets in the namespace of the release. These are the synopsis lines of two commands from its reference:

Shell

helm history RELEASE_NAME
helm rollback <RELEASE> [REVISION]

helm history prints the historical revisions of a release. helm rollback rolls a release back to a previous revision, and with the revision omitted it goes to the previous release. On helm upgrade, --rollback-on-failure rolls back to the previous successful release when the upgrade fails.

The Kustomize README compares the tool to sed, in that it emits edited text. The Kustomize guides pipe that output to kubectl, as in kustomize build ~/ldap/overlays/production | kubectl apply -f -. In the words of the same guides, Kustomize is used to author resource configuration, and apply manages applications through those files.

Two GitOps controllers document how they treat Helm releases. The Argo CD documentation says Helm is only used to inflate charts with helm template, and that Argo CD handles the lifecycle of the application. Flux's HelmRelease performs Helm actions: install, upgrade, test, uninstall and rollback among them.

Both tools together

The documentation of each project describes a way to combine them.

  1. Kustomize inflates a chart. The helmCharts field runs the helm program in a subprocess during a build. It must be enabled with kustomize build --enable-helm. The reference calls this support limited and says it will not add private registry authentication or OCI registries.
  2. Helm calls a post-renderer. Post rendering lets tools like Kustomize change rendered manifests before Helm installs them. The Helm documentation gives the purpose: no need to fork a public chart. In Helm 4, post-renderers are implemented as plugins.
  3. Flux post-renders in the HelmRelease. .spec.postRenderers supports the Kustomize directives patches and images:

YAML

apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: my-app
  namespace: my-app
spec:
  interval: 15m
  chartRef:
    kind: OCIRepository
    name: my-app
  values:
    replicaCount: 2
  postRenderers:
    - kustomize:
        patches:
          - target:
              kind: Deployment
              name: my-app
            patch: |
              - op: add
                path: /metadata/labels/environment
                value: production

The names, the interval and the values are choices for this example. The Flux FAQ says Flux does not allow Kustomize plugins that shell out to arbitrary binaries, the helmCharts route included, and points to its own Helm resources.

In Argo CD, the Kustomize page says --enable-helm is not among its Kustomize options. It gives two ways to add it: a config management plugin, or kustomize.buildOptions: --enable-helm in the argocd-cm ConfigMap, which applies to all Kustomize applications.

Third-party software and your own applications

Both projects document both cases.

  • Helm, off the shelf. Among the uses in the Helm introduction is installing ready-made applications from a chart: databases, monitoring stacks and ingress controllers. helm show values lists what a chart lets you configure, and a values file passed at installation overrides those settings.
  • Helm, your own. The same page lists bundling your own resources into a chart, versioning it and distributing it to your team or the wider community.
  • Kustomize, off the shelf. Its off-the-shelf workflow forks an existing configuration, clones it as the base, adds overlays and rebases on the upstream repository to capture changes.
  • Kustomize, your own. In its workflow for user-owned applications all configuration files are owned by the user: a base, plus an overlay for each variant such as staging and production.

A way to decide

Match the documented facts to your case.

  1. For a versioned package that others install, Helm has helm package, helm push and chart versions.
  2. For plain YAML that stays usable as it is, Kustomize patches it and leaves the original untouched.
  3. For release history and rollback from the command line, Helm has helm history and helm rollback.
  4. With a GitOps controller, read how it treats each tool first: Argo CD renders charts with helm template, and Flux does not run the helmCharts route.

Sources

Want a second pair of eyes on yours? We do this work for a living.

Book a call

More guides