Helm, Kustomize, CRDs & operators
Install components with Helm or Kustomize and work with custom resources.
By Invicly Tech, , in Kubernetes Administrator (CKA). About 8 minutes to read.
In short
Helm packages applications as charts with templated manifests and configurable values. Kustomize customizes plain YAML with overlays and is built into kubectl. CRDs add new resource types, and operators are controllers that manage those custom resources automatically.
Explained simply
Real applications need many YAML files: Deployments, Services, ConfigMaps, RBAC rules. Copying and editing them by hand for every environment gets messy. Helm and Kustomize are two tools that package and customise those files so installs are repeatable.
Helm is like an app store with installers. A chart is a package with templates and a list of settings called values. You install it with your own values. Kustomize is more like tracing paper: you keep plain base YAML and lay small patches over it for dev or prod.
Custom Resource Definitions (CRDs) let you add your own object types, such as a Database or a Certificate. An operator is a program that watches those objects and does the real work, like creating Pods and backups. Many Helm charts install exactly this pair.
Press Play on a diagram to walk through it one step at a time.
- Templated charts
- values.yaml and --set overrides
- Releases with history and rollback
- Install from chart repositories
- Template-free YAML
- Base plus overlays
- Built into kubectl apply -k
- Patches, prefixes, image tags
- 1Watch custom resource
Operator watches objects of its CRD kind.
- 2Compare states
Desired spec versus actual cluster resources.
- 3Act
Create, update or delete Pods, Services and more.
- 4Update status
Write results to the resource's status field.
- Back to step 1
- base/
- deployment.yaml
- service.yaml
- kustomization.yaml
- overlays/dev/
- kustomization.yaml (namespace: dev)
- replicas-patch.yaml (1 replica)
- overlays/prod/
- kustomization.yaml (namespace: prod)
- replicas-patch.yaml (5 replicas)
- images: tag 2.1.0
- 1Load chart
Templates and default values
- 2Merge values
Defaults, then -f files, then --set
- 3Render
Templates become plain YAML
- 4Apply
Objects sent to the API server
- 5Record
Release stored as a Secret
In depth
Helm day-to-day
A typical flow is: helm repo add to register a chart repository, helm repo update to refresh its index, helm search repo to find a chart, and helm show values to see what you can configure. Then helm install NAME CHART -n NS --create-namespace -f my-values.yaml installs a release.
helm upgrade --install is handy because it installs if missing and upgrades if present. helm history and helm rollback NAME REVISION undo a bad change. helm template renders the YAML without installing, which is great for checking what a chart will create.
- helm list -A shows releases in all namespaces
- helm get values NAME shows the values you set
- helm uninstall NAME -n NS removes a release
Where Helm keeps its memory
Helm 3 has no server component. It stores each release revision as a Secret in the release's namespace, named like sh.helm.release.v1.web.v3. That record holds the rendered manifests and values, which is how upgrade and rollback know what to change.
This also explains a common surprise: helm list without -n only shows releases in your current namespace. If a release seems missing, add -A.
- Step 1helm install web
Secret sh.helm.release.v1.web.v1
- Step 2helm upgrade web
Revision 2, new Secret .v2
- Step 3helm rollback web 1
Reads revision 1's manifests
- Step 4Revision 3
Rollback is recorded as a new revision
Kustomize building blocks
A folder with a kustomization.yaml file is a kustomization. It lists resources (YAML files or other folders) and transformations: namespace sets the namespace on everything, namePrefix adds a prefix, labels adds labels, images changes image tags, and patches applies strategic merge or JSON patches.
configMapGenerator builds ConfigMaps from files or literals and adds a hash suffix to the name. When the content changes, the name changes, and Deployments that use it roll out automatically. kubectl kustomize DIR previews the output; kubectl apply -k DIR applies it.
- Step 1Edit the source file
- Step 2New hash suffix
Name changes, e.g. app-config-7f9k2m
- Step 3References updated
Deployment now points at the new name
- Step 4Pod template changed
Deployment rolls out new Pods
CRDs and validation
A CRD registers a new resource type with a group, version, kind and an OpenAPI schema. The schema validates objects and powers kubectl explain for the new kind. Once a CRD exists, kubectl get, describe and apply work on its objects like any built-in resource.
Deleting a CRD deletes every object of that type, so be careful. Use kubectl get crd to list them and kubectl api-resources --api-group=GROUP to see the kinds they add.
Learn it in 5 short steps
About 50m each. Track them with a timer in your plan.
- 1Install a chart with Helm~50m
- 2Override chart values~50m
- 3Apply overlays with Kustomize~50m
- 4Create and use a CRD~50m
- 5Explain the operator pattern~50m
Key points
- helm install RELEASE CHART creates a release; helm upgrade changes it.
- Override values with -f values.yaml or --set key=value.
- kubectl apply -k DIR builds and applies a kustomization.
- A CRD alone only stores data; a controller gives it behavior.
Key terms
Tap a card to flip it. 0/5 known
Examples
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm install web bitnami/nginx -n web --create-namespace \
--set replicaCount=2
helm list -n web
helm upgrade web bitnami/nginx -n web -f values.yaml
helm rollback web 1 -n web
kubectl kustomize overlays/prod # preview
kubectl apply -k overlays/prod
kubectl get crdInstalling ingress-nginx with Helm and one override
Step 1: add and update the repository. Step 2: check the available values. Step 3: install into its own namespace with a NodePort Service, because a lab has no cloud load balancer. Step 4: confirm the release and its Pods.
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm show values ingress-nginx/ingress-nginx | grep -A3 'type: LoadBalancer'
helm install ingress ingress-nginx/ingress-nginx -n ingress-nginx \
--create-namespace --set controller.service.type=NodePort
helm list -n ingress-nginx
kubectl -n ingress-nginx get pods,svcA prod overlay with Kustomize
Step 1: the base folder holds a plain Deployment named web. Step 2: the prod overlay points at the base, sets the namespace, raises replicas and pins the image tag. Step 3: preview with kubectl kustomize, then apply with -k.
# overlays/prod/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
namespace: prod
images:
- name: nginx
newTag: "1.27"
patches:
- target: {kind: Deployment, name: web}
patch: |-
- {op: replace, path: /spec/replicas, value: 5}
# kubectl kustomize overlays/prod && kubectl apply -k overlays/prodQuick reference
- helm upgrade --install NAME CHART -n NS --create-namespace -f values.yaml
- helm show values CHART > values.yaml to see every setting
- helm rollback NAME REV; helm history NAME shows revisions
- helm template NAME CHART renders YAML without installing
- kubectl kustomize DIR previews; kubectl apply -k DIR applies
- configMapGenerator adds a hash suffix so config changes roll Pods
- k get crd; k explain KIND works when the CRD has a schema
Common mistakes
- Forgetting -n on helm commands, so the release lands in default.
- Deleting a CRD, which deletes all of its custom resources.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Install the bitnami/nginx chart as release web in namespace web with 2 replicas, then list the release.
- Exercise 2medium
Upgrade release web to 3 replicas, then roll back to the previous revision and confirm the replica count.
- Exercise 3hard
Create a CRD for kind Website (group demo.io, version v1, namespaced) with a required string field spec.url, then create one Website and list it.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Should I use Helm or Kustomize?
- Use Helm to install third-party software that ships as a chart. Use Kustomize for your own plain YAML across environments. Many teams use both.
- Is Kustomize a separate install?
- No. It is built into kubectl through kubectl kustomize and kubectl apply -k. A standalone kustomize binary exists if you want a newer version.
- What is the difference between a CRD and an operator?
- A CRD adds a new object type to the API. An operator is a controller that watches those objects and performs actions to make reality match them.