kubernetes kustomize
https://github.com/kubernetes-sigs/kustomize
When managing multiple environments, there would be some environment specific that can’t be dealt with only kubernetes ConfigMaps:
Host
for kubernestes ingress- physical resources affecting kubernetes pods
- metadata (kubernetes label, kubernetes annotation, …) shared to the resources
Kustomize
gives the possibility to:
- load classic descriptors
- create kubernetes ConfigMap and kubernetes Secret
- apply transformation
Concept
- no template
- no variable
- static configuration: what is deployed is what is described
Kustomize generators
configMapGenerator
secretGenerator
Generate kubernetes ConfigMap and kubernetes Secret from:
- entry key=value
- files
- env variable file (one line == key=value)
Kustomize transformers
commonAnnotations
,comonLabels
: global annotations and labels definitionnamespace
: global kubernetes namespace definitionnamePrefix
,nameSuffix
: resource name modificationimages
: replace image referencepatches
: apply updates from a “patch”- custom: we can extend
Kustomize
with custom transformers
Kustomization project structure
Kustomization example
Overlay example
Merge patch example
Considerations
- declare in advance environment specific in a specific
Overlay
- composition between base and
overlays
at several levels - define
components
to compose multiple configurations
Local updates
Useful in continuous integration workflow