Kubernetes/Kustomize

From Ever changing code
< Kubernetes
Revision as of 22:49, 9 September 2020 by Pio2pio (talk | contribs) (Created page with "= [https://github.com/kubernetes-sigs/kustomize Kustomize] = kustomize lets you customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouc...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Kustomize

kustomize lets you customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as is.

# Install on Linux
curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv3.5.4/kustomize_v3.5.4_linux_amd64.tar.gz -o kustomize_v3.5.4_linux_amd64.tar.gz
tar xzvf kustomize_v3.5.4_linux_amd64.tar.gz
sudo install ./kustomize /usr/local/bin/kustomize

$ kustomize version --short
{kustomize/v3.5.4  2020-01-11T03:12:59Z  }


Kustomize build workflow
$ kustomize build ~/target
  1. load universal k8s object descriptions
  2. read kustomization.yaml from target
  3. kustomize bases (recurse 2-5)
  4. load and/or generate resources
  5. apply target's kustomization operations
  6. fix name references
  7. emit yaml


Known issues

In some settings it makes sense for commonLabels to be included in selectors, and in some settings it doers not make sense to include them in selectors. Kustomize includes by default, and there is no way to opt out. As workaround, you can convert matchLabels to matchExpressions and Kustomize won't touch them. API docs

- podSelector:
      matchLabels:
        app: mongodb-backup


is equivalent with

- podSelector:
      matchExpressions:
        - key: app
        operator: In
        values:
          - mongodb-backup

and Kustomize will keep its hands off.


Resources