Category: Kubernetes, Docker, yaml

When you start working with Kubernetes, you may get to a point where you’re shocked at how complex your YAML files have become. For a complex application consisting of different containers your YAML files will become very very long and it will become harder to change a single piece of configuration like the name of your application without breaking things.

In the following example my application consist of a 010-deployment.yaml and a 020-service.yaml file: With the help of the file kustomization.yaml you can now apply your base configuration with: So far this results in the same outcome as using the option kubectl apply -f.

For example you want to change an environment variable to your deployment, add a new file named custom-env.yaml with the new setting: Merge the new junk yaml file with the option patchesStategicMerge in your /overlay/variant-1/kustomization.yaml file: This will add the new ‘CUSTOM_ENV_VARIABLE’ with the value ‘some-value’ to your deployment of ‘my-app’.

You can add additional deployment resources with the resource option in your kustomize.yaml file: This example will add a new resource ‘090-ingress.yaml‘ into your base deployment.

Related Articles