You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/tasks/manage-kubernetes-objects/kustomization.md
+12-13Lines changed: 12 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,13 +46,12 @@ Kustomize is a tool for customizing Kubernetes configurations. It has the follow
46
46
47
47
### Generating Resources
48
48
49
-
ConfigMap and Secret hold config or sensitive data that are used by other Kubernetes objects, such as Pods. The source
50
-
of truth of ConfigMap or Secret are usually from somewhere else, such as a `.properties` file or a ssh key file.
49
+
ConfigMaps and Secrets hold configuration or sensitive data that are used by other Kubernetes objects, such as Pods. The source of truth of ConfigMaps or Secrets are usually external to a cluster, such as a `.properties` file or an SSH keyfile.
51
50
Kustomize has `secretGenerator` and `configMapGenerator`, which generate Secret and ConfigMap from files or literals.
52
51
53
52
#### configMapGenerator
54
53
55
-
To generate a ConfigMap from a file, add an entry to `files` list in `configMapGenerator`. Here is an example of generating a ConfigMap with a data item from a file content.
54
+
To generate a ConfigMap from a file, add an entry to the `files` list in `configMapGenerator`. Here is an example of generating a ConfigMap with a data item from a `.properties` file:
56
55
57
56
```shell
58
57
# Create a application.properties file
@@ -68,7 +67,7 @@ configMapGenerator:
68
67
EOF
69
68
```
70
69
71
-
The generated ConfigMap can be checked by the following command:
70
+
The generated ConfigMap can be examined with the following command:
72
71
73
72
```shell
74
73
kubectl kustomize ./
@@ -86,7 +85,7 @@ metadata:
86
85
name: example-configmap-1-8mbdf7882g
87
86
```
88
87
89
-
ConfigMap can also be generated from literal key-value pairs. To generate a ConfigMap from a literal key-value pair, add an entry to `literals` list in configMapGenerator. Here is an example of generating a ConfigMap with a data item from a key-value pair.
88
+
ConfigMaps can also be generated from literal key-value pairs. To generate a ConfigMap from a literal key-value pair, add an entry to the `literals` list in configMapGenerator. Here is an example of generating a ConfigMap with a data item from a key-value pair:
90
89
91
90
```shell
92
91
cat <<EOF >./kustomization.yaml
@@ -103,7 +102,7 @@ The generated ConfigMap can be checked by the following command:
103
102
kubectl kustomize ./
104
103
```
105
104
106
-
The generated ConfigMap is
105
+
The generated ConfigMap is:
107
106
108
107
```yaml
109
108
apiVersion: v1
@@ -116,7 +115,7 @@ metadata:
116
115
117
116
#### secretGenerator
118
117
119
-
You can generate Secrets from files or literal key-value pairs. To generate a Secret from a file, add an entry to `files` list in `secretGenerator`. Here is an example of generating a Secret with a data item from a file.
118
+
You can generate Secrets from files or literal key-value pairs. To generate a Secret from a file, add an entry to the `files` list in `secretGenerator`. Here is an example of generating a Secret with a data item from a file:
120
119
121
120
```shell
122
121
# Create a password.txt file
@@ -145,7 +144,7 @@ metadata:
145
144
type: Opaque
146
145
```
147
146
148
-
To generate a Secret from a literal key-value pair, add an entry to `literals` list in `secretGenerator`. Here is an example of generating a Secret with a data item from a key-value pair.
147
+
To generate a Secret from a literal key-value pair, add an entry to `literals` list in `secretGenerator`. Here is an example of generating a Secret with a data item from a key-value pair:
149
148
150
149
```shell
151
150
cat <<EOF >./kustomization.yaml
@@ -172,7 +171,7 @@ type: Opaque
172
171
173
172
#### generatorOptions
174
173
175
-
The generated ConfigMaps and Secrets have a suffix appended by hashing the contents. This ensures that a new ConfigMap or Secret is generated when the content is changed. To disable the behavior of appending a suffix, one can use `generatorOptions`. Besides that, it is also possible to specify cross-cutting options for generated ConfigMaps and Secrets.
174
+
The generated ConfigMaps and Secrets have a content hash suffix appended. This ensures that a new ConfigMap or Secret is generated when the contents are changed. To disable the behavior of appending a suffix, one can use `generatorOptions`. Besides that, it is also possible to specify cross-cutting options for generated ConfigMaps and Secrets.
176
175
177
176
```shell
178
177
cat <<EOF >./kustomization.yaml
@@ -209,7 +208,7 @@ metadata:
209
208
It is quite common to set cross-cutting fields for all Kubernetes resources in a project.
210
209
Some use cases for setting cross-cutting fields:
211
210
212
-
* setting the same namespace for all Resource
211
+
* setting the same namespace for all Resources
213
212
* adding the same name prefix or suffix
214
213
* adding the same set of labels
215
214
* adding the same set of annotations
@@ -289,7 +288,7 @@ Kustomize offers composing Resources from different files and applying patches o
289
288
#### Composing
290
289
291
290
Kustomize supports composition of different resources. The `resources` field, in the `kustomization.yaml` file, defines the list of resources to include in a configuration. Set the path to a resource's configuration file in the `resources` list.
292
-
Here is an example for an nginx application with a Deployment and a Service.
291
+
Here is an example of an NGINX application comprised of a Deployment and a Service:
293
292
294
293
```shell
295
294
# Create a deployment.yaml file
@@ -339,11 +338,11 @@ resources:
339
338
EOF
340
339
```
341
340
342
-
The Resources from `kubectl kustomize ./` contains both the Deployment and the Service objects.
341
+
The Resources from `kubectl kustomize ./` contain both the Deployment and the Service objects.
343
342
344
343
#### Customizing
345
344
346
-
On top of Resources, one can apply different customizations by applying patches. Kustomize supports different patching
345
+
Patches can be used to apply different customizations to Resources. Kustomize supports different patching
347
346
mechanisms through `patchesStrategicMerge` and `patchesJson6902`. `patchesStrategicMerge` is a list of file paths. Each file should be resolved to a [strategic merge patch](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-api-machinery/strategic-merge-patch.md). The names inside the patches must match Resource names that are already loaded. Small patches that do one thing are recommended. For example, create one patch for increasing the deployment replica number and another patch for setting the memory limit.
0 commit comments