Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add common Tasks to documentation #5383

Merged
merged 26 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4ccc571
Add labels, annotations, namespaces, and names tasks
ncapps Oct 19, 2023
6093020
Remove redundant information from ref/labels ref/annotations
ncapps Oct 22, 2023
2e8a5bc
Update labels and annotations example names for consistency
ncapps Oct 22, 2023
ad34d82
Remove name, prefix and suffix api examples
ncapps Oct 22, 2023
0c999c8
Add link to tasks in reference
ncapps Oct 26, 2023
b5c9b05
Add link to tasks section for ref/configMapGenerator and ref/secretGe…
ncapps Nov 4, 2023
7b357a1
Add Labels/Annotatations headers
ncapps Nov 4, 2023
35e37c0
Add Labels
ncapps Nov 4, 2023
d400f54
Add Template Labels
ncapps Nov 5, 2023
fa0a578
Cleanup Add Template Labels
ncapps Nov 5, 2023
12889ac
Consolidate commonLabels and labels.includeSelectors
ncapps Nov 5, 2023
ba3fa09
Improve commonAnnotations example
ncapps Nov 5, 2023
420e224
Add labels and annotations ref links
ncapps Nov 5, 2023
645568b
Add generated ConfigMap to namespace example
ncapps Nov 5, 2023
a4638b5
Add name headers
ncapps Nov 10, 2023
98f3fd2
Change header weights so they appear in sidebar
ncapps Nov 10, 2023
1ecf4c7
Add namespace/name links
ncapps Nov 10, 2023
4134f39
Add generated ConfigMap to namePrefix example
ncapps Nov 10, 2023
a745460
Add name propagation example
ncapps Nov 10, 2023
dc38832
Add more description of name propagation
ncapps Nov 10, 2023
bda5c77
template labels
ncapps Nov 11, 2023
664b2da
Address feedback for labels
ncapps Nov 18, 2023
7a22a7d
Address names feedback
ncapps Nov 18, 2023
1037644
Update for consistency
ncapps Nov 18, 2023
a65ee4a
Address feedback
ncapps Nov 24, 2023
698ab16
Remove API
ncapps Nov 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
ncapps marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ weight: 6
description: >
Generate ConfigMap resources.
---

The Tasks section contains examples of how to use [`configMapGenerator`](/docs/tasks/configmap_generator/).
229 changes: 1 addition & 228 deletions site/content/en/docs/Reference/API/Kustomization File/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
Loading
Loading