Difference between revisions of "Kubernetes/Kustomize"
Jump to navigation
Jump to search
(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...") |
|||
Line 1: | Line 1: | ||
= [https:// | = [https://kustomize.io/ Kustomize] = | ||
kustomize lets you customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as is. | kustomize lets you customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as is. | ||
= Install = | |||
<source lang=bash> | <source lang=bash> | ||
# Install on Linux | # Detects your OS and downloads kustomize binary to cwd | ||
curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize% | curl -s "https://raw.githubusercontent.com/\ | ||
tar xzvf | kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash | ||
# Install on Linux - option2 | |||
VERSION=v3.8.2 | |||
curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${VERSION}/kustomize_${VERSION}_linux_amd64.tar.gz -o kustomize_${VERSION}_linux_amd64.tar.gz | |||
tar xzvf kustomize_${VERSION}_linux_amd64.tar.gz | |||
sudo install ./kustomize /usr/local/bin/kustomize | sudo install ./kustomize /usr/local/bin/kustomize | ||
$ kustomize version --short | $ kustomize version --short | ||
{kustomize/v3. | {kustomize/v3.8.2 2020-08-29T17:44:01Z } | ||
</source> | </source> | ||
= Kustomize build workflow = | |||
<source>$ kustomize build ~/target</source> | <source>$ kustomize build ~/target</source> | ||
# load universal k8s object descriptions | # load universal k8s object descriptions | ||
Line 23: | Line 30: | ||
= Known issues = | |||
* [https://github.com/kubernetes-sigs/kustomize/issues/2034 commonLabels altering podSelector.matchLabels] and [https://github.com/kubernetes-sigs/kustomize/issues/157 Allow excluding some label selectors from commonLabels] | * [https://github.com/kubernetes-sigs/kustomize/issues/2034 commonLabels altering podSelector.matchLabels] and [https://github.com/kubernetes-sigs/kustomize/issues/157 Allow excluding some label selectors from commonLabels] | ||
In some settings it makes sense for <code>commonLabels</code> 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 <code>matchLabels</code> to <code>matchExpressions</code> and Kustomize won't touch them. API docs | In some settings it makes sense for <code>commonLabels</code> 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 <code>matchLabels</code> to <code>matchExpressions</code> and Kustomize won't touch them. API docs | ||
Line 46: | Line 53: | ||
= Resources = | |||
* [https://github.com/kubernetes-sigs/kustomize Kustomize sig] | |||
* [https://github.com/kubernetes-sigs/kustomize/blob/master/docs/glossary.md#kustomization Glossary] | * [https://github.com/kubernetes-sigs/kustomize/blob/master/docs/glossary.md#kustomization Glossary] | ||
* [https://github.com/kubernetes-sigs/kustomize/blob/master/docs/fields.md Kustomization File Fields] | * [https://github.com/kubernetes-sigs/kustomize/blob/master/docs/fields.md Kustomization File Fields] |
Revision as of 23:07, 9 September 2020
Kustomize
kustomize lets you customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as is.
Install
# Detects your OS and downloads kustomize binary to cwd curl -s "https://raw.githubusercontent.com/\ kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash # Install on Linux - option2 VERSION=v3.8.2 curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${VERSION}/kustomize_${VERSION}_linux_amd64.tar.gz -o kustomize_${VERSION}_linux_amd64.tar.gz tar xzvf kustomize_${VERSION}_linux_amd64.tar.gz sudo install ./kustomize /usr/local/bin/kustomize $ kustomize version --short {kustomize/v3.8.2 2020-08-29T17:44:01Z }
Kustomize build workflow
$ kustomize build ~/target
- load universal k8s object descriptions
- read
kustomization.yaml
from target - kustomize bases (recurse 2-5)
- load and/or generate resources
- apply target's kustomization operations
- fix name references
- emit yaml
Known issues
- commonLabels altering podSelector.matchLabels and Allow excluding some label selectors from commonLabels
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
- Kustomize sig
- Glossary
- Kustomization File Fields
- Kustomize - examples kubectl.docs.kubernetes.io
- Kustomize structure_directories
- reference Good!
- inlinePatch