// Module included in the following assemblies: // // * rosa_cluster_admin/rosa_nodes/rosa-managing-worker-nodes.adoc // * nodes/rosa-managing-worker-nodes.adoc // * osd_cluster_admin/osd_nodes/osd-managing-worker-nodes.adoc :_mod-docs-content-type: PROCEDURE [id="rosa-adding-node-labels_{context}"] = Adding node labels to a machine pool Add or edit labels for compute (also known as worker) nodes at any time to manage the nodes in a manner that is relevant to you. For example, you can assign types of workloads to specific nodes. Labels are assigned as key-value pairs. Each key must be unique to the object it is assigned to. .Prerequisites ifdef::openshift-rosa,openshift-rosa-hcp[] * You installed and configured the latest {rosa-cli-first} on your workstation. * You logged in to your Red{nbsp}Hat account using the {rosa-cli}. * You created a {product-title} cluster. endif::openshift-rosa,openshift-rosa-hcp[] ifndef::openshift-rosa,openshift-rosa-hcp[] * You created an {product-title} cluster. endif::[] * You have an existing machine pool. .Procedure ifdef::openshift-rosa,openshift-rosa-hcp[] . List the machine pools in the cluster: + [source,terminal] ---- $ rosa list machinepools --cluster= ---- + .Example output + ifdef::openshift-rosa[] [source,terminal] ---- ID AUTOSCALING REPLICAS INSTANCE TYPE LABELS TAINTS AVAILABILITY ZONES SPOT INSTANCES Default No 2 m5.xlarge us-east-1a N/A db-nodes-mp No 2 m5.xlarge us-east-1a No ---- endif::openshift-rosa[] ifdef::openshift-rosa-hcp[] [source,terminal] ---- ID AUTOSCALING REPLICAS INSTANCE TYPE LABELS TAINTS AVAILABILITY ZONE SUBNET VERSION AUTOREPAIR workers No 2/2 m5.xlarge us-east-2a subnet-0df2ec3377847164f 4.16.6 Yes db-nodes-mp No 2/2 m5.xlarge us-east-2a subnet-0df2ec3377847164f 4.16.6 Yes ---- endif::openshift-rosa-hcp[] . Add or update the node labels for a machine pool: * To add or update node labels for a machine pool that does not use autoscaling, run the following command: + [source,terminal] ---- $ rosa edit machinepool --cluster= \ --labels==,= \// <1> ---- <1> Replace `=,=` with a comma-delimited list of key-value pairs, for example `--labels=key1=value1,key2=value2`. This list overwrites any modifications made to node labels on an ongoing basis. + The following example adds labels to the `db-nodes-mp` machine pool: + [source,terminal] ---- $ rosa edit machinepool --cluster=mycluster --replicas=2 --labels=app=db,tier=backend db-nodes-mp ---- + .Example output [source,terminal] ---- I: Updated machine pool 'db-nodes-mp' on cluster 'mycluster' ---- .Verification . Describe the details of the machine pool with the new labels: + [source,terminal] ---- $ rosa describe machinepool --cluster= --machinepool= ---- + .Example output ifdef::openshift-rosa[] [source,terminal] ---- ID: db-nodes-mp Cluster ID: Autoscaling: No Replicas: 2 Instance type: m5.xlarge Labels: app=db, tier=backend Taints: Availability zones: us-east-1a Subnets: Spot instances: No Disk size: 300 GiB Security Group IDs: ---- endif::openshift-rosa[] ifdef::openshift-rosa-hcp[] [source,terminal] ---- ID: db-nodes-mp Cluster ID: Autoscaling: No Desired replicas: 2 Current replicas: 2 Instance type: m5.xlarge Labels: app=db, tier=backend Tags: Taints: Availability zone: us-east-2a Subnet: subnet-0df2ec3377847164f Disk size: 300 GiB Version: 4.16.6 EC2 Metadata Http Tokens: optional Autorepair: Yes Tuning configs: Kubelet configs: Additional security group IDs: Node drain grace period: Management upgrade: - Type: Replace - Max surge: 1 - Max unavailable: 0 Message: ---- endif::openshift-rosa-hcp[] . Verify that the labels are included for your machine pool in the output. endif::openshift-rosa,openshift-rosa-hcp[] ifdef::openshift-dedicated[] . Navigate to {cluster-manager-url} and select your cluster. . Under the *Machine pools* tab, click the Options menu {kebab} for the machine pool that you want to add a label to. . Select *Edit labels*. . If you have existing labels in the machine pool that you want to remove, select *x* next to the label to delete it. . Add a label using the format `=` and press enter. For example, add `app=db` and then press Enter. If the format is correct, the key value pair is then highlighted. . Repeat the previous step if you want to add additional labels. . Click *Save* to apply the labels to the machine pool. .Verification . Under the *Machine pools* tab, select *>* next to your machine pool to expand the view. . Verify that your labels are listed under *Labels* in the expanded view. endif::[]