Skip to content

Commit dfaf833

Browse files
authored
Merge pull request #27377 from sftim/20210401_namespace_default_label_name_tweaks
Improve docs for NamespaceDefaultLabelName
2 parents 029c885 + 0bfff0b commit dfaf833

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

content/en/docs/concepts/overview/working-with-objects/namespaces.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Namespaces are a way to divide cluster resources between multiple users (via [re
3030

3131
It is not necessary to use multiple namespaces to separate slightly different
3232
resources, such as different versions of the same software: use
33-
[labels](/docs/concepts/overview/working-with-objects/labels) to distinguish
33+
{{< glossary_tooltip text="labels" term_id="label" >}} to distinguish
3434
resources within the same namespace.
3535

3636
## Working with Namespaces
@@ -114,6 +114,16 @@ kubectl api-resources --namespaced=true
114114
kubectl api-resources --namespaced=false
115115
```
116116

117+
## Automatic labelling
118+
119+
{{< feature-state state="beta" for_k8s_version="1.21" >}}
120+
121+
The Kubernetes control plane sets an immutable {{< glossary_tooltip text="label" term_id="label" >}}
122+
`kubernetes.io/metadata.name` on all namespaces, provided that the `NamespaceDefaultLabelName`
123+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled.
124+
The value of the label is the namespace name.
125+
126+
117127
## {{% heading "whatsnext" %}}
118128

119129
* Learn more about [creating a new namespace](/docs/tasks/administer-cluster/namespaces/#creating-a-new-namespace).

content/en/docs/concepts/services-networking/network-policies.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,19 @@ supports the `endPort` field in NetworkPolicy specifications.
266266

267267
## Targeting a Namespace by its name
268268

269-
As of Kubernetes v1.21, an immutable label `kubernetes.io/metadata.name` is added to all
270-
namespaces. The value of the label is the namespace name. While NetworkPolicy cannot
271-
target a namespace by its name with some object field, this label now can be used to target
272-
a specific namespace.
269+
{{< feature-state state="beta" for_k8s_version="1.21" >}}
270+
271+
The Kubernetes control plane sets an immutable label `kubernetes.io/metadata.name` on all
272+
namespaces, provided that the `NamespaceDefaultLabelName`
273+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled.
274+
The value of the label is the namespace name.
275+
276+
While NetworkPolicy cannot target a namespace by its name with some object field, you can use the
277+
standardized label to target a specific namespace.
273278

274279
## What you can't do with network policies (at least, not yet)
275280

276-
As of Kubernetes 1.20, the following functionality does not exist in the NetworkPolicy API, but you might be able to implement workarounds using Operating System components (such as SELinux, OpenVSwitch, IPTables, and so on) or Layer 7 technologies (Ingress controllers, Service Mesh implementations) or admission controllers. In case you are new to network security in Kubernetes, its worth noting that the following User Stories cannot (yet) be implemented using the NetworkPolicy API. Some (but not all) of these user stories are actively being discussed for future releases of the NetworkPolicy API.
281+
As of Kubernetes {{< skew latestVersion >}}, the following functionality does not exist in the NetworkPolicy API, but you might be able to implement workarounds using Operating System components (such as SELinux, OpenVSwitch, IPTables, and so on) or Layer 7 technologies (Ingress controllers, Service Mesh implementations) or admission controllers. In case you are new to network security in Kubernetes, its worth noting that the following User Stories cannot (yet) be implemented using the NetworkPolicy API.
277282

278283
- Forcing internal cluster traffic to go through a common gateway (this might be best served with a service mesh or other proxy).
279284
- Anything TLS related (use a service mesh or ingress controller for this).

content/en/docs/reference/command-line-tools-reference/feature-gates.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,8 @@ Each feature gate is designed for enabling/disabling a specific feature:
704704
the volume mounter.
705705
- `MountPropagation`: Enable sharing volume mounted by one container to other containers or pods.
706706
For more details, please see [mount propagation](/docs/concepts/storage/volumes/#mount-propagation).
707-
- `NamespaceDefaultLabelName`: Enable the API Server to create a default label `kubernetes.io/metadata.name` in all namespaces containing the namespace name.
707+
- `NamespaceDefaultLabelName`: Configure the API Server to set an immutable {{< glossary_tooltip text="label" term_id="label" >}}
708+
`kubernetes.io/metadata.name` on all namespaces, containing the namespace name.
708709
- `NetworkPolicyEndPort`: Enable use of the field `endPort` in NetworkPolicy objects, allowing the selection of a port range instead of a single port.
709710
- `NodeDisruptionExclusion`: Enable use of the Node label `node.kubernetes.io/exclude-disruption`
710711
which prevents nodes from being evacuated during zone failures.

content/en/docs/reference/labels-annotations-taints.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ Example: `kubernetes.io/metadata.name=mynamespace`
3636

3737
Used on: Namespaces
3838

39-
Kubernetes API Server defaults this label to the namespace name during admission. This label can be used with any namespace selector, as an example with NetworkPolicy objects.
39+
When the `NamespaceDefaultLabelName`
40+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled,
41+
the Kubernetes API server sets this label on all namespaces. The label value is set to
42+
the name of the namespace.
43+
44+
This is useful if you want to target a specific namespace with a label
45+
{{< glossary_tooltip text="selector" term_id="selector" >}}.
4046

4147
## beta.kubernetes.io/arch (deprecated)
4248

0 commit comments

Comments
 (0)