Kustomize
kustomizaton.yaml anatomy
Features of kustomization.yaml
resources
: list of configuration files or folders to be includedpatchesStrategicMerge
: list of strategic merge files for kubernetes objects (patch existing object with entries from the)namespace
: namespace to apply to all resourcessecretGenerator
: list of entries generating a secretcommonLabels
: map of labels / values to add to all resources and selectorscommonAnnotations
: map of annotations to add to all resourcesimages
: list of image name overrides (name/tags/digest) without the need of a patchnamePrefix
: text to be prepended to the name of all resourcesnameSuffix
: text to be appended to the name of all resources
Folder structure:
- base/: all base manifests shared between environments
-- deployment.yaml
-- kustomization.yaml
-- service.yaml
- overlays/: environment specific files
- dev/
-- kustomization.yaml
-- replicas.yaml
-- config.properties
- prod/
-- kustomization.yaml
-- replicas.yaml
-- config.properties
- components/: optional parts that can be selectively included per environment
- mock-server/
-- kustomization.yaml
-- deployment.yaml
base/kustomization.yaml:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels:
app: hello-world
resources:
- service.yaml
- deployment.yaml
overlay/**/kustomization.yaml:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namePrefix: prod-
bases:
- ../../base
patchesStrategicMerge:
- replicas.yaml
configMapGenerator:
- name: app-configmap
files:
- config.properties