mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 08:20:59 +00:00
Add common Tasks to documentation (#5383)
* Add labels, annotations, namespaces, and names tasks * Remove redundant information from ref/labels ref/annotations * Update labels and annotations example names for consistency * Remove name, prefix and suffix api examples * Add link to tasks in reference * Add link to tasks section for ref/configMapGenerator and ref/secretGenerator * Add Labels/Annotatations headers * Add Labels * Add Template Labels * Cleanup Add Template Labels * Consolidate commonLabels and labels.includeSelectors * Improve commonAnnotations example * Add labels and annotations ref links * Add generated ConfigMap to namespace example * Add name headers * Change header weights so they appear in sidebar * Add namespace/name links * Add generated ConfigMap to namePrefix example * Add name propagation example * Add more description of name propagation * template labels * Address feedback for labels * Address names feedback * Update for consistency * Address feedback * Remove API
This commit is contained in:
@@ -7,52 +7,4 @@ description: >
|
||||
Add annotations to add all resources.
|
||||
---
|
||||
|
||||
Add annotations to all resources. If the annotation key already is present on the resource,
|
||||
the value will be overridden.
|
||||
|
||||
```yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
commonAnnotations:
|
||||
oncallPager: 800-555-1212
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
### File Input
|
||||
|
||||
```yaml
|
||||
# kustomization.yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
commonAnnotations:
|
||||
oncallPager: 800-555-1212
|
||||
|
||||
resources:
|
||||
- deploy.yaml
|
||||
```
|
||||
|
||||
```yaml
|
||||
# deploy.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: example
|
||||
spec:
|
||||
...
|
||||
```
|
||||
|
||||
### Build Output
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: example
|
||||
annotations:
|
||||
oncallPager: 800-555-1212
|
||||
spec:
|
||||
...
|
||||
```
|
||||
The Tasks section contains examples of how to use [`commonAnnotations`](/docs/tasks/labels_and_annotations/).
|
||||
|
||||
@@ -7,101 +7,4 @@ description: >
|
||||
Add labels and selectors to add all resources.
|
||||
---
|
||||
|
||||
[labels]: /docs/reference/api/kustomization-file/labels/
|
||||
|
||||
Add labels and selectors to all resources. If the label key already is present on the resource,
|
||||
the value will be overridden.
|
||||
|
||||
An alternative to this field is the [labels] field, which allows adding labels without also automatically
|
||||
injecting corresponding selectors.
|
||||
|
||||
{{% pageinfo color="warning" %}}
|
||||
Selectors for resources such as Deployments and Services shouldn't be changed once the
|
||||
resource has been applied to a cluster.
|
||||
|
||||
Changing commonLabels to live resources could result in failures.
|
||||
{{% /pageinfo %}}
|
||||
|
||||
```yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
commonLabels:
|
||||
someName: someValue
|
||||
owner: alice
|
||||
app: bingo
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
### File Input
|
||||
|
||||
```yaml
|
||||
# kustomization.yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
commonLabels:
|
||||
someName: someValue
|
||||
owner: alice
|
||||
app: bingo
|
||||
|
||||
resources:
|
||||
- deploy.yaml
|
||||
- service.yaml
|
||||
```
|
||||
|
||||
```yaml
|
||||
# deploy.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: example
|
||||
```
|
||||
|
||||
```yaml
|
||||
# service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: example
|
||||
```
|
||||
|
||||
### Build Output
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
name: example
|
||||
spec:
|
||||
selector:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
name: example
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
```
|
||||
The Tasks section contains examples of how to use [`commonLabels`](/docs/tasks/labels_and_annotations/).
|
||||
|
||||
@@ -6,3 +6,5 @@ weight: 6
|
||||
description: >
|
||||
Generate ConfigMap resources.
|
||||
---
|
||||
|
||||
The Tasks section contains examples of how to use [`configMapGenerator`](/docs/tasks/configmap_generator/).
|
||||
|
||||
@@ -7,231 +7,4 @@ description: >
|
||||
Add labels and optionally selectors to all resources.
|
||||
---
|
||||
|
||||
A field that allows adding labels without also automatically injecting corresponding selectors.
|
||||
This can be used instead of the `commonLabels` field, which always adds selectors.
|
||||
|
||||
{{% pageinfo color="warning" %}}
|
||||
Selectors for resources such as Deployments and Services shouldn't be changed once the
|
||||
resource has been applied to a cluster.
|
||||
|
||||
Changing `includeSelectors` to `true` or changing labels when `includeSelectors` is `true` in live resources
|
||||
is equivalent to changing `commonLabels` and could result in failures.
|
||||
{{% /pageinfo %}}
|
||||
|
||||
The following flags are available:
|
||||
* `includeTemplates`: When set will also apply labels to metadata/labels and spec/template/metadata/labels. This can be used to add labels to Pods from owner resources, such as Deployments and StatefulSets, without modifying selectors. False by default.
|
||||
* `includeSelectors`: When set will apply labels to metadata/labels, selectors, and spec/template/metadata/labels. False by default.
|
||||
|
||||
```yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
labels:
|
||||
- pairs:
|
||||
someName: someValue
|
||||
owner: alice
|
||||
app: bingo
|
||||
includeSelectors: true # <-- false by default
|
||||
includeTemplates: true # <-- false by default
|
||||
```
|
||||
|
||||
## Example 1 - selectors and templates NOT modified
|
||||
|
||||
### File Input
|
||||
|
||||
```yaml
|
||||
# kustomization.yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
labels:
|
||||
- pairs:
|
||||
someName: someValue
|
||||
owner: alice
|
||||
app: bingo
|
||||
|
||||
resources:
|
||||
- deploy.yaml
|
||||
- service.yaml
|
||||
```
|
||||
|
||||
```yaml
|
||||
# deploy.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: example
|
||||
```
|
||||
|
||||
```yaml
|
||||
# service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: example
|
||||
```
|
||||
|
||||
### Build Output
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
name: example
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
name: example
|
||||
```
|
||||
|
||||
|
||||
## Example 2 - selectors modified
|
||||
|
||||
### File Input
|
||||
|
||||
```yaml
|
||||
# kustomization.yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
labels:
|
||||
- pairs:
|
||||
someName: someValue
|
||||
owner: alice
|
||||
app: bingo
|
||||
includeSelectors: true
|
||||
|
||||
resources:
|
||||
- deploy.yaml
|
||||
- service.yaml
|
||||
```
|
||||
|
||||
```yaml
|
||||
# deploy.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: example
|
||||
```
|
||||
|
||||
```yaml
|
||||
# service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: example
|
||||
```
|
||||
|
||||
### Build Output
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
name: example
|
||||
spec:
|
||||
selector:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
name: example
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
```
|
||||
|
||||
## Example 3 - templates modified
|
||||
|
||||
### File Input
|
||||
|
||||
```yaml
|
||||
# kustomization.yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
labels:
|
||||
- pairs:
|
||||
someName: someValue
|
||||
owner: alice
|
||||
app: bingo
|
||||
includeTemplates: true
|
||||
|
||||
resources:
|
||||
- deploy.yaml
|
||||
- service.yaml
|
||||
```
|
||||
|
||||
```yaml
|
||||
# deploy.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: example
|
||||
```
|
||||
|
||||
```yaml
|
||||
# service.yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: example
|
||||
```
|
||||
|
||||
### Build Output
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
name: example
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
name: example
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
```
|
||||
The Tasks section contains examples of how to use [`labels`](/docs/tasks/labels_and_annotations/).
|
||||
|
||||
@@ -7,58 +7,4 @@ description: >
|
||||
Prepends the value to the names of all resources and references.
|
||||
---
|
||||
|
||||
As `namePrefix` is self explanatory, it helps adding prefix to names in the defined yaml files.
|
||||
|
||||
## Example
|
||||
|
||||
### File Input
|
||||
|
||||
```yaml
|
||||
# deployment.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: the-deployment
|
||||
spec:
|
||||
replicas: 5
|
||||
template:
|
||||
containers:
|
||||
- name: the-container
|
||||
image: registry/container:latest
|
||||
```
|
||||
|
||||
```yaml
|
||||
# kustomization.yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
namePrefix: custom-prefix-
|
||||
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
```
|
||||
|
||||
### Build Output
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: custom-prefix-the-deployment
|
||||
spec:
|
||||
replicas: 5
|
||||
template:
|
||||
containers:
|
||||
- image: registry/container:latest
|
||||
name: the-container
|
||||
```
|
||||
|
||||
{{< alert color="success" title="References" >}}
|
||||
Apply will propagate the `namePrefix` to any place Resources within the project are referenced by other Resources
|
||||
including:
|
||||
|
||||
- Service references from StatefulSets
|
||||
- ConfigMap references from PodSpecs
|
||||
- Secret references from PodSpecs
|
||||
{{< /alert >}}
|
||||
The Tasks section contains examples of how to use [`namePrefix`](/docs/tasks/namespaces_and_names/).
|
||||
|
||||
@@ -7,51 +7,4 @@ description: >
|
||||
Appends the value to the names of all resources and references.
|
||||
---
|
||||
|
||||
As `nameSuffix` is self explanatory, it helps adding suffix to names in the defined yaml files.
|
||||
|
||||
**Note:** The suffix is appended before the content hash if the resource type is ConfigMap or Secret.
|
||||
|
||||
## Example
|
||||
|
||||
### File Input
|
||||
|
||||
```yaml
|
||||
# deployment.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: the-deployment
|
||||
spec:
|
||||
replicas: 5
|
||||
template:
|
||||
containers:
|
||||
- name: the-container
|
||||
image: registry/container:latest
|
||||
```
|
||||
|
||||
```yaml
|
||||
# kustomization.yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
nameSuffix: -custom-suffix
|
||||
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
```
|
||||
|
||||
### Build Output
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: the-deployment-custom-suffix
|
||||
spec:
|
||||
replicas: 5
|
||||
template:
|
||||
containers:
|
||||
- image: registry/container:latest
|
||||
name: the-container
|
||||
```
|
||||
The Tasks section contains examples of how to use [`nameSuffix`](/docs/tasks/namespaces_and_names/).
|
||||
|
||||
@@ -7,52 +7,4 @@ description: >
|
||||
Adds namespace to all resources.
|
||||
---
|
||||
|
||||
Will override the existing namespace if it is set on a resource, or add it
|
||||
if it is not set on a resource.
|
||||
|
||||
## Example
|
||||
|
||||
### File Input
|
||||
|
||||
```yaml
|
||||
# deployment.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: the-deployment
|
||||
namespace: the-namespace
|
||||
spec:
|
||||
replicas: 5
|
||||
template:
|
||||
containers:
|
||||
- name: the-container
|
||||
image: registry/container:latest
|
||||
```
|
||||
|
||||
```yaml
|
||||
# kustomization.yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
namespace: kustomize-namespace
|
||||
|
||||
resources:
|
||||
- deployment.yaml
|
||||
|
||||
```
|
||||
|
||||
### Build Output
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: the-deployment
|
||||
namespace: kustomize-namespace
|
||||
spec:
|
||||
replicas: 5
|
||||
template:
|
||||
containers:
|
||||
- image: registry/container:latest
|
||||
name: the-container
|
||||
```
|
||||
The Tasks section contains examples of how to use [`namespace`](/docs/tasks/namespaces_and_names/).
|
||||
|
||||
@@ -7,6 +7,4 @@ description: >
|
||||
Generate Secret resources.
|
||||
---
|
||||
|
||||
Each entry in the argument list results in the creation of one Secret resource (it's a generator of N secrets).
|
||||
|
||||
This works like the [configMapGenerator](/docs/reference/api/kustomization-file/configmapgenerator).
|
||||
The Tasks section contains examples of how to use [`secretGenerator`](/docs/tasks/secret_generator/).
|
||||
|
||||
Reference in New Issue
Block a user