Kubernetes kustomize: Difference between revisions
No edit summary |
m (Pchero moved page Kustomize to Kubernetes kustomize without leaving a redirect) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
Kustomize does customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as-is. | Kustomize does customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as-is. | ||
== Basic == | |||
Kustomize is a tool for customizing Kubernetes configurations. It has the following features to manage application configuration files: | |||
* generating resources from other sources. | |||
* setting cross-cutting fields for resources. | |||
* composing and customizing collections of resources. | |||
Kustomize is a standalone tool to customize Kubernetes objects through a kustomization file. | |||
Since 1.14, Kubectl also supports the management of Kubernetes objects using a kustomization file. To view Resources found in a directory containing a kustomization file, run the following command. | |||
<pre> | |||
$ kubectl kustomize <kustomization_directory> | |||
</pre> | |||
To apply those Resources, run '''kubectl apply''' with --kustomize or -k flag. | |||
<pre> | |||
$ kubectl apply -k <kustomization_directory> | |||
</pre> | |||
== Generating resources == | |||
ConfigMap and Secret hold config or sesitive data that are used by other Kubernetes objects, such as Pods. The source of truth of ConfigMap or Secret are usually from somewhere else, such as .properties file or a ssh key file. Kustomize has secretGenerator and configMapGenerator, which generate Secret and ConfigMap from files or literals. | |||
=== ConfigMapGenerator === | |||
To generate a ConfigMap from a file, add an entry to files list in configMapGenerator. | |||
<pre> | |||
# Create a application.properties file | |||
$ cat <<EOF >application.properties | |||
FOO=Bar | |||
EOF | |||
$ cat <<EOF >./kustomization.yaml | |||
configMapGenerator: | |||
- name: example-configmap-1 | |||
files: | |||
- application.properties | |||
EOF | |||
</pre> | |||
== Feature list == | |||
* namespace: string: Add namespace to all resources | |||
* namePrefix: string: Value of this filed is presented to the names of all resources. | |||
* nameSuffix: string: Value of this field is appended to the names of all resources. | |||
* commonLabels: map[string]string: Labels to add to all resources and selectors. | |||
* commonAnnotations: map[string]string: Annotations to add to all resources. | |||
== See also == | == See also == | ||
* https://blog.stack-labs.com/code/kustomize-101/ - Kustomize - The right way to do templating in Kubernetes | * https://blog.stack-labs.com/code/kustomize-101/ - Kustomize - The right way to do templating in Kubernetes | ||
* https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization - Declarative management of kubernetes objects using kustomize | |||
[[category:kubernetes]] | [[category:kubernetes]] |
Latest revision as of 01:12, 21 December 2020
Overview
Kustomize 내용 정리.
Kustomize does customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as-is.
Basic
Kustomize is a tool for customizing Kubernetes configurations. It has the following features to manage application configuration files:
- generating resources from other sources.
- setting cross-cutting fields for resources.
- composing and customizing collections of resources.
Kustomize is a standalone tool to customize Kubernetes objects through a kustomization file.
Since 1.14, Kubectl also supports the management of Kubernetes objects using a kustomization file. To view Resources found in a directory containing a kustomization file, run the following command.
$ kubectl kustomize <kustomization_directory>
To apply those Resources, run kubectl apply with --kustomize or -k flag.
$ kubectl apply -k <kustomization_directory>
Generating resources
ConfigMap and Secret hold config or sesitive data that are used by other Kubernetes objects, such as Pods. The source of truth of ConfigMap or Secret are usually from somewhere else, such as .properties file or a ssh key file. Kustomize has secretGenerator and configMapGenerator, which generate Secret and ConfigMap from files or literals.
ConfigMapGenerator
To generate a ConfigMap from a file, add an entry to files list in configMapGenerator.
# Create a application.properties file $ cat <<EOF >application.properties FOO=Bar EOF $ cat <<EOF >./kustomization.yaml configMapGenerator: - name: example-configmap-1 files: - application.properties EOF
Feature list
- namespace: string: Add namespace to all resources
- namePrefix: string: Value of this filed is presented to the names of all resources.
- nameSuffix: string: Value of this field is appended to the names of all resources.
- commonLabels: map[string]string: Labels to add to all resources and selectors.
- commonAnnotations: map[string]string: Annotations to add to all resources.
See also
- https://blog.stack-labs.com/code/kustomize-101/ - Kustomize - The right way to do templating in Kubernetes
- https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization - Declarative management of kubernetes objects using kustomize