Certified Kubernetes Application Developer - CKAD

2025 Updates Kustomize Basics

Kustomize vs Helm

This article offers a high-level comparison between Helm and Kustomize for modifying Kubernetes manifests across different environments. Understanding both tools is crucial when selecting the best fit for your project.

Helm's Templating Approach

Helm uses Go templating syntax to inject variable values into Kubernetes manifests. Rather than hard coding values, Helm defines placeholders that can be dynamically replaced with environment-specific configurations. Consider the following example:

# Deployment template (Deployment.yaml)
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Values.name }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ .Values.name }}
  template:
    metadata:
      labels:
        app: {{ .Values.name }}
    spec:
      containers:
      - name: {{ .Chart.Name }}
        image: "nginx:{{ .Values.image.tag }}"

# Values file (values.yaml)
replicaCount: 1
image:
  tag: "2.4.4"

In this example, the double curly braces {{ ... }} denote variables for properties such as name, replicaCount, and image.tag. When deploying your application, Helm replaces these placeholders with the corresponding values defined in values.yaml.

Note

Helm's templating mechanism enables advanced customization by allowing developers to pass different configuration values for each environment.

Organizing a Helm Project

A well-structured Helm project separates Kubernetes manifests (templates) from environment-specific values files. Here’s an example of a typical project structure:

k8s/
└── environments/
    ├── values.dev.yaml
    ├── values.stg.yaml
    └── values.prod.yaml
└── templates/
    ├── nginx-deployment.yaml
    ├── nginx-service.yaml
    ├── db-deployment.yaml
    └── db-service.yaml

In the templates directory, you maintain all Kubernetes manifests with Go templating variables. The environments directory contains separate values files for development, staging, and production. During deployment, you specify the appropriate values file so that Helm can substitute the variables in your templates with environment-specific details.

Additional Features and Trade-offs

Helm is not only a configuration customization tool but also a comprehensive package manager for Kubernetes applications—similar to how package managers like yum or apt work for Linux systems. Its support for advanced features such as conditionals, loops, functions, and hooks makes it superior for complex deployments compared to Kustomize.

However, this added functionality also introduces extra complexity. Since Helm templates are not valid YAML until rendered, reading and understanding Helm charts can be challenging due to the intensive use of templating logic. In contrast, Kustomize relies on plain YAML for both base configurations and overlays, which can enhance clarity and ease of reading.

Warning

When choosing between Kustomize and Helm, consider the trade-off between the simplicity of Kustomize and the advanced, but more complex, capabilities of Helm.

Feature Comparison

FeatureHelmKustomize
TemplatingUses Go templating for dynamic variable substitutionsUses plain YAML with overlays for configuration
ComplexityMore complex due to advanced featuresSimpler and easier to read
Package ManagementActs as a full-fledged package manager for KubernetesFocuses solely on configuration customization
FlexibilityHighly flexible with conditionals, loops, and hooksPrioritizes clarity and straightforward configuration

For more information on Kubernetes configurations and best practices, check out the following resources:

In summary, your choice between Kustomize and Helm should be guided by your project requirements—whether you need the simplicity and transparency of plain YAML or the advanced customization and package management features that Helm provides.

Watch Video

Watch video content

Previous
Kustomize Problem Statement idealogy