Kustomization Yaml File
Kustomisation Yaml File
-
Example:
-
k8sdirectory that containsnginx-depl.ymlandnginx-service.yml.kustomizedoes not look for either of the above files. In fact, it looks for akustomization.yamlfile.
-
The
kustomization.yamlfile will contain all of the resources needed bykustomize:
# kubernetes resources to be managed by kustomize
resources:
- nginx-deployment.yaml
- nginx-service .yaml
# Customizations that need to be made
commonLabels:
company: KodeKloud
-
The
Cusotmizations that need to be madesection contains all of the changes that we want to apply. -
Once all customisations are done, we run
kustomize build <root directory>. In the above example,<root directory>would bek8s.- It will input all resources and apply transformations that we have defined.
-
If you check the terminal output, in the above case you’ll see the
nginxservice and thenginxdeployment output. -
Then you’ll see the additions that were made.
commonLabels:
kustomize build k8s/
apiVersion: v1
kind: Service
metadata:
labels:
company: KodeKloud
-
The
kustomize buildcommand however does not apply/deploy the Kubernetes resources to the cluster. -
It just outputs what the final configuration file looks like in the terminal.
-
If we want to apply what
kustomize buildoutputs to the cluster, it needs to be directed to thekubectl applycommand.