Kustomize vs Helm
Kustomise vs Helm
-
helmprovides modifications to Kubernetes manifests on a per-environment basis.helmuses agotemplate to assign variables to properties.
-
An exmaple deployment configuration:
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 }}"
-
The
gotemplating uses two {{ }} on either side.- The variable can be changed on a per-environment basis.
-
To then populate the
.Values.replicaCountfield, we createvalues.yamland provide it with the following: ``` replicaCount: 1
image: tag: “2.4.4”
* When the application is deployed, value of 1 is set in the `replicas` property.
* Then under `"nginx:{{ .Values.image.tag }}"` is looks for `tag`, under `image:` --> `tag` as shown above.
* Here is a `helm` project structure that allows us to customise the `values` file:
k8s –> environments / templates ```
-
Under
environments, you havevalues.dev.yaml,values.stg.yamlandvalues.prod.yaml. -
Under
templates, you then havenginx-deployment.yaml,nginx-service.yaml,db-deployment.yamlanddb-service.yaml. -
In
environments, this stores all of the values we want to set on a per-environment basis. -
helmdoesn’t just do the above - it is a package manager for the app as well. -
helmprovides extra features like conditional, loops, functions and hooks. -
helmtemplates are not valid YAML - they are usinggo. The templating syntax makes things difficult to read. -
kustomizeis just regularyaml. The base configuration are regular manifests and theoverlaysis alsoyaml