If you want to add labels and assign roles to your nodes, you must edit the Cluster object, and add the labels under spec.topology.workers.metadata
:
workers:
machineDeployments:
- class: workeramd64hcloud
name: md-0
replicas: 5
failureDomain: nbg1
metadata: // [!code ++]
labels: // [!code ++]
node-role.kubernetes.io/backend: 'true' // [!code ++]
node.cluster.x-k8s.io/environment: 'production' // [!code ++]
variables:
overrides:
- name: workerMachineTypeHcloud
value: cpx31
- name: workerMachinePlacementGroupNameHcloud
value: md-0
For the label to propagate to the node in the workload cluster, it should meet one of the following criteria:
You can create new machine deployments and separate your node labels however you like. For example, you might have the same five machines, but three with label node.cluster.x-k8s.io/environment: production
and two with node.cluster.x-k8s.io/environment: staging
:
workers:
machineDeployments:
- class: workeramd64hcloud
name: md-0
replicas: 5 // [!code --]
replicas: 3 // [!code ++]
failureDomain: nbg1
metadata:
labels:
node-role.kubernetes.io/backend: 'true'
node.cluster.x-k8s.io/environment: 'production'
variables:
overrides:
- name: workerMachineTypeHcloud
value: cpx31
- name: workerMachinePlacementGroupNameHcloud
value: md-0
- class: workeramd64hcloud // [!code ++]
name: md-1 // [!code ++]
replicas: 2 // [!code ++]
failureDomain: nbg1 // [!code ++]
metadata: // [!code ++]
labels: // [!code ++]
node-role.kubernetes.io/backend: 'true' // [!code ++]
environment: 'staging' // [!code ++]
variables: // [!code ++]
overrides: // [!code ++]
- name: workerMachineTypeHcloud // [!code ++]
value: cpx31 // [!code ++]
- name: workerMachinePlacementGroupNameHcloud // [!code ++]
value: md-0 // [!code ++]