Skip to content

Commit 297b5cc

Browse files
committed
docs: add docs on node labels
clarify the confusion on node labels Signed-off-by: Amarachi Iheanacho <[email protected]>
1 parent e168512 commit 297b5cc

File tree

3 files changed

+141
-0
lines changed

3 files changed

+141
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: "Node Labels"
3+
description: "How to configure and use node labels with Talos."
4+
---
5+
6+
Talos can propagate labels from `machine.nodeLabels` to the Kubernetes Node object.
7+
These labels are written using the node’s kubelet identity, which is restricted by the Kubernetes [NodeRestriction admission controller](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#noderestriction).
8+
9+
With NodeRestriction in place, a kubelet is only allowed to modify a small, whitelisted set of labels, such as:
10+
11+
* `topology.kubernetes.io/region`
12+
* `topology.kubernetes.io/zone`
13+
* `kubernetes.io/hostname`
14+
* `kubernetes.io/arch`
15+
* `kubernetes.io/os`
16+
* some `node.kubernetes.io/*` labels
17+
18+
Labels outside that set, including the conventional role labels `node-role.kubernetes.io/<role>`, are rejected by the API server when requested by the node itself.
19+
20+
This prevents a worker node from assigning itself a privileged role.
21+
22+
### Apply nodeLabels
23+
24+
You can add labels to a node by specifying them under `machine.nodeLabels` in the machine configuration. For example:
25+
26+
```yaml
27+
machine:
28+
nodeLabels:
29+
topology.kubernetes.io/zone: "pve03"
30+
topology.kubernetes.io/region: "Region-1"
31+
```
32+
33+
After you patch and reboot, the nodes will have the labels applied. Verify them with
34+
35+
```bash
36+
kubectl describe node <node-name>
37+
```
38+
39+
### Role Labels
40+
41+
If you need to assign role labels, for example, `node-role.kubernetes.io/worker` or `node-role.kubernetes.io/ingress`, you must set them with a cluster-admin account:
42+
43+
```bash
44+
kubectl label node <node-name> node-role.kubernetes.io/worker
45+
```
46+
47+
Alternatively, you can use the [Talos Cloud Controller Manager](https://github.com/siderolabs/talos-cloud-controller-manager/blob/main/docs/config.md) or your own controller to translate custom domain labels into the conventional `node-role.kubernetes.io/*` form if required.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: "Node Labels"
3+
description: "How to configure and use node labels with Talos."
4+
---
5+
6+
Talos can propagate labels from `machine.nodeLabels` to the Kubernetes Node object.
7+
These labels are written using the node’s kubelet identity, which is restricted by the Kubernetes [NodeRestriction admission controller](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#noderestriction).
8+
9+
With NodeRestriction in place, a kubelet is only allowed to modify a small, whitelisted set of labels, such as:
10+
11+
* `topology.kubernetes.io/region`
12+
* `topology.kubernetes.io/zone`
13+
* `kubernetes.io/hostname`
14+
* `kubernetes.io/arch`
15+
* `kubernetes.io/os`
16+
* some `node.kubernetes.io/*` labels
17+
18+
Labels outside that set, including the conventional role labels `node-role.kubernetes.io/<role>`, are rejected by the API server when requested by the node itself.
19+
20+
This prevents a worker node from assigning itself a privileged role.
21+
22+
### Apply nodeLabels
23+
24+
You can add labels to a node by specifying them under `machine.nodeLabels` in the machine configuration. For example:
25+
26+
```yaml
27+
machine:
28+
nodeLabels:
29+
topology.kubernetes.io/zone: "pve03"
30+
topology.kubernetes.io/region: "Region-1"
31+
```
32+
33+
After you patch and reboot, the nodes will have the labels applied. Verify them with
34+
35+
```bash
36+
kubectl describe node <node-name>
37+
```
38+
39+
### Role Labels
40+
41+
If you need to assign role labels, for example, `node-role.kubernetes.io/worker` or `node-role.kubernetes.io/ingress`, you must set them with a cluster-admin account:
42+
43+
```bash
44+
kubectl label node <node-name> node-role.kubernetes.io/worker
45+
```
46+
47+
Alternatively, you can use the [Talos Cloud Controller Manager](https://github.com/siderolabs/talos-cloud-controller-manager/blob/main/docs/config.md) or your own controller to translate custom domain labels into the conventional `node-role.kubernetes.io/*` form if required.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: "Node Labels"
3+
description: "How to configure and use node labels with Talos."
4+
---
5+
6+
Talos can propagate labels from `machine.nodeLabels` to the Kubernetes Node object.
7+
These labels are written using the node’s kubelet identity, which is restricted by the Kubernetes [NodeRestriction admission controller](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#noderestriction).
8+
9+
With NodeRestriction in place, a kubelet is only allowed to modify a small, whitelisted set of labels, such as:
10+
11+
* `topology.kubernetes.io/region`
12+
* `topology.kubernetes.io/zone`
13+
* `kubernetes.io/hostname`
14+
* `kubernetes.io/arch`
15+
* `kubernetes.io/os`
16+
* some `node.kubernetes.io/*` labels
17+
18+
Labels outside that set, including the conventional role labels `node-role.kubernetes.io/<role>`, are rejected by the API server when requested by the node itself.
19+
20+
This prevents a worker node from assigning itself a privileged role.
21+
22+
### Apply nodeLabels
23+
24+
You can add labels to a node by specifying them under `machine.nodeLabels` in the machine configuration. For example:
25+
26+
```yaml
27+
machine:
28+
nodeLabels:
29+
topology.kubernetes.io/zone: "pve03"
30+
topology.kubernetes.io/region: "Region-1"
31+
```
32+
33+
After you patch and reboot, the nodes will have the labels applied. Verify them with
34+
35+
```bash
36+
kubectl describe node <node-name>
37+
```
38+
39+
### Role Labels
40+
41+
If you need to assign role labels, for example, `node-role.kubernetes.io/worker` or `node-role.kubernetes.io/ingress`, you must set them with a cluster-admin account:
42+
43+
```bash
44+
kubectl label node <node-name> node-role.kubernetes.io/worker
45+
```
46+
47+
Alternatively, you can use the [Talos Cloud Controller Manager](https://github.com/siderolabs/talos-cloud-controller-manager/blob/main/docs/config.md) or your own controller to translate custom domain labels into the conventional `node-role.kubernetes.io/*` form if required.

0 commit comments

Comments
 (0)