Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion cmd/test-manifests/hello/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
commonLabels:
labels:
app: hello

namespace: default
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/faq/kustomize/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ The configuration directive allows customization of the following transformers:

```yaml
commonAnnotations: []
commonLabels: []
labels: []
nameprefix: []
namespace: []
varreference: []
Expand Down
16 changes: 8 additions & 8 deletions site/content/en/guides/config_management/labels_annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: >


{{< alert color="success" title="TL;DR" >}}
- Set Labels for all Resources declared within a Project with `commonLabels`
- Set Labels for all Resources declared within a Project with `labels`
- Set Annotations for all Resources declared within a Project with `commonAnnotations`
{{< /alert >}}

Expand All @@ -26,9 +26,9 @@ Users may want to define a common set of labels or annotations for all the Resou

## Setting Labels

**Example:** Add the labels declared in `commonLabels` to all Resources in the project.
**Example:** Add the labels declared in `labels` to all Resources in the project.

**Important:** Once set, commonLabels should not be changed so as not to change the Selectors for Services
**Important:** Once set, labels should not be changed so as not to change the Selectors for Services
or Workloads.

**Input:** The kustomization.yaml and deployment.yaml files
Expand All @@ -37,7 +37,7 @@ or Workloads.
# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels:
labels:
app: foo
environment: test
resources:
Expand Down Expand Up @@ -99,22 +99,22 @@ spec:
```

{{% alert color="success" title="Command / Examples" %}}
Check out the [reference](/references/kustomize/kustomization/commonlabels/) for commands and examples for `setting labels`
Check out the [reference](/references/kustomize/kustomization/labels/) for commands and examples for `setting labels`
{{% /alert %}}

### Propagating Labels to Selectors
In addition to updating the labels for each Resource, any selectors will also be updated to target the
labels. e.g. the selectors for Services in the project will be updated to include the commonLabels
labels. e.g. the selectors for Services in the project will be updated to include the labels
*in addition* to the other labels.

**Note:** Once set, commonLabels should not be changed so as not to change the Selectors for Services
**Note:** Once set, labels should not be changed so as not to change the Selectors for Services
or Workloads.

{{< alert color="success" title="Common Labels" >}}
The k8s.io documentation defines a set of [Common Labeling Conventions](https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/)
that may be applied to Applications.

**Note:** commonLabels should only be set for **immutable** labels, since they will be applied to Selectors.
**Note:** labels should only be set for **immutable** labels, since they will be applied to Selectors.

Labeling Workload Resources makes it simpler to query Pods - e.g. for the purpose of getting their logs.
{{< /alert >}}
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/guides/extending_kustomize/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ and _transformers_.
* A _transformer_ plugin makes changes to existing Kubernetes objects. For example, it might apply a custom order to the resource list, perform special
container command line edits, or any other
transformation beyond those provided by the
builtin (`namePrefix`, `commonLabels`, etc.)
builtin (`namePrefix`, `labels`, etc.)
transformers.

[generator options]: https://github.com/kubernetes-sigs/kustomize/tree/master/examples/generatorOptions.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ referencing all of the above:

```yaml
# $MYAPP/kustomization.yaml
commonLabels:
labels:
app: hello
resources:
- deployment.yaml
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/guides/extending_kustomize/exec_plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ referencing all of the above:

```bash
# $MYAPP/kustomization.yaml
commonLabels:
labels:
app: hello
resources:
- deployment.yaml
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/guides/extending_kustomize/go_plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ config:

```shell
cat <<EOF >$MYAPP/kustomization.yaml
commonLabels:
labels:
app: hello
generators:
- secGenerator.yaml
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/references/kubectl/apply/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ resources:
namespace: default

# labels added to all Resources
commonLabels:
labels:
app: example
env: test
```
Expand Down
4 changes: 2 additions & 2 deletions site/content/en/references/kustomize/builtins/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ images:

### Usage via `kustomization.yaml`

#### field name: `commonLabels`
#### field name: `labels`

Adds labels to all resources and selectors

```bash
commonLabels:
labels:
someName: someValue
owner: alice
app: bingo
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/references/kustomize/cmd/create/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ resources:
- deployment.yaml
- service.yaml
namespace: myapp
commonLabels:
labels:
app: myapp
```
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ example
```shell
# example/localized-remote-kustomize-v5.0.0/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
commonLabels:
labels:
purpose: remoteReference
kind: Kustomization
resources:
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/references/kustomize/glossary/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ falling into four categories:

* _transformers_ - what to _do_ to the aforementioned resources.
Example fields: _namePrefix_, _nameSuffix_, _images_,
_commonLabels_, _patchesJson6902_, etc. and the more
_labels_, _patchesJson6902_, etc. and the more
general _transformers_ (v2.1) field.

* _meta_ - fields which may influence all or some of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ validators:
The order in each of these lists is relevant
and respected.

> There are other fields too, e.g. `commonLabels`, `namePrefixes`,
> There are other fields too, e.g. `labels`, `namePrefixes`,
> `patches`, etc. These fields are _convenience_ fields, shorthand for
> longer transformer configuration stanzas, and are discussed later.
> They're what's used most often, but it's useful to first cover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,27 @@ description: >

[labels]: https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/labels/

{{% pageinfo color="warning" %}}
The `commonLabels` field was deprecated in v5.0.0. Please use the [labels] field instead.

The `commonLabels` field will never be removed from the kustomize.config.k8s.io/v1beta1 Kustomization API,
but it will not be included in the kustomize.config.k8s.io/v1 Kustomization API. When Kustomization v1 is available,
we will announce the deprecation of the v1beta1 version. There will be at least
two releases between deprecation and removal of Kustomization v1beta1 support from the
kustomize CLI, and removal itself will happen in a future major version bump.

You can run `kustomize edit fix` to automatically convert `commonLabels` to `labels`.

Note: 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 %}}

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ description: >
---

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.
This can be used instead of the deprecated `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.
is equivalent to changing the deprecated `commonLabels` and could result in failures.
{{% /pageinfo %}}

The following flags are available:
Expand Down
2 changes: 1 addition & 1 deletion site/content/zh/api-reference/glossary/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Kustomize 鼓励对声明式应用程序管理([Declarative Application Manage

- `resources`:待定制的现存[资源],示例字段:`resources`、`crds`。
- `generator`:将要创建的**新**资源,示例字段:`configMapGenerator`(传统)、`secretGenerator`(传统)、`generators`(v2.1)
- `transformer`:对前面提到的新旧资源进行**处理**的方式。示例字段:`namePrefix`、`nameSuffix`、`images`、`commonLabels`、`patchesJson6902` 等。在 v2.1 中还有更多的 `transformer`。
- `transformer`:对前面提到的新旧资源进行**处理**的方式。示例字段:`namePrefix`、`nameSuffix`、`images`、`labels`、`patchesJson6902` 等。在 v2.1 中还有更多的 `transformer`。
- `meta`:会对上面几种字段产生影响。示例字段:`vars`、`namespace`、`apiVersion`、`kind` 等。

## kustomization root
Expand Down
2 changes: 1 addition & 1 deletion site/content/zh/faq/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The configuration directive allows customization of the following transformers:

```yaml
commonAnnotations: []
commonLabels: []
labels: []
nameprefix: []
namespace: []
varreference: []
Expand Down
2 changes: 1 addition & 1 deletion site/content/zh/guides/plugins/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Kustomize 提供一个插件框架,允许用户开发自己的 _生成器_ 和
[12-factor]: https://12factor.net

* _generator_ 插件生成 k8s 资源,比如 [helm chart inflator] 是一个 generator 插件,基于少量自由变量生成一个 [12-factor] 应用所包含的全部组件 deployment,service,scaler,ingress 等)也是一个 generator 插件。
* _transformer_ 插件转化(修改)k8s 资源,比如可能会执行对特殊容器命令行的编辑,或为其他内置转换器(`namePrefix`、`commonLabels` 等)无法转换的内容提供转换。
* _transformer_ 插件转化(修改)k8s 资源,比如可能会执行对特殊容器命令行的编辑,或为其他内置转换器(`namePrefix`、`labels` 等)无法转换的内容提供转换。

## `kustomization.yaml` 的格式

Expand Down
4 changes: 2 additions & 2 deletions site/content/zh/guides/plugins/builtins.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ images:

### 使用 `kustomization.yaml`

#### 字段名称:`commonLabels`
#### 字段名称:`labels`

为所有资源和 selectors 增加标签。

```yaml
commonLabels:
labels:
someName: someValue
owner: alice
app: bingo
Expand Down
2 changes: 1 addition & 1 deletion site/content/zh/guides/plugins/execPluginGuidedExample.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ EOF

```bash
cat <<EOF >$MYAPP/kustomization.yaml
commonLabels:
labels:
app: hello
resources:
- deployment.yaml
Expand Down
2 changes: 1 addition & 1 deletion site/content/zh/guides/plugins/goPluginGuidedExample.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ EOF

```shell
cat <<EOF >$MYAPP/kustomization.yaml
commonLabels:
labels:
app: hello
generators:
- secGenerator.yaml
Expand Down