1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 21:46:22 +01:00
Files
openshift-docs/modules/rosa-adding-node-labels.adoc
2023-10-30 10:13:25 -04:00

134 lines
6.0 KiB
Plaintext

// 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[]
* You installed and configured the latest {product-title} (ROSA) CLI, `rosa`, on your workstation.
* You logged in to your Red Hat account using the ROSA CLI (`rosa`).
* You created a {product-title} (ROSA) cluster.
endif::openshift-rosa[]
ifndef::openshift-rosa[]
* You created an {product-title} cluster.
endif::[]
* You have an existing machine pool.
.Procedure
ifdef::openshift-rosa[]
. List the machine pools in the cluster:
+
[source,terminal]
----
$ rosa list machinepools --cluster=<cluster_name>
----
+
.Example output
+
[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
----
. 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=<cluster_name> \
--replicas=<replica_count> \ <1>
--labels=<key>=<value>,<key>=<value> \ <2>
<machine_pool_id>
----
<1> For machine pools that do not use autoscaling, you must provide a replica count when adding node labels. If you do not specify the `--replicas` argument, you are prompted for a replica count before the command completes. If you deployed {product-title} (ROSA) using a single availability zone, the replica count defines the number of compute nodes to provision to the machine pool for the zone. If you deployed your cluster using multiple availability zones, the count defines the total number of compute nodes in the machine pool across all zones and must be a multiple of 3.
<2> Replace `<key>=<value>,<key>=<value>` 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'
----
* To add or update node labels for a machine pool that uses autoscaling, run the following command:
+
[source,terminal]
----
$ rosa edit machinepool --cluster=<cluster_name> \
--min-replicas=<minimum_replica_count> \ <1>
--max-replicas=<maximum_replica_count> \ <1>
--labels=<key>=<value>,<key>=<value> \ <2>
<machine_pool_id>
----
<1> For machine pools that use autoscaling, you must provide minimum and maximum compute node replica limits. If you do not specify the arguments, you are prompted for the values before the command completes. The cluster autoscaler does not reduce or increase the machine pool node count beyond the limits that you specify. If you deployed ROSA using a single availability zone, the `--min-replicas` and `--max-replicas` arguments define the autoscaling limits in the machine pool for the zone. If you deployed your cluster using multiple availability zones, the arguments define the autoscaling limits in total across all zones and the counts must be multiples of 3.
<2> Replace `<key>=<value>,<key>=<value>` 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 --min-replicas=2 --max-replicas=3 --labels=app=db,tier=backend db-nodes-mp
----
+
.Example output
[source,terminal]
----
I: Updated machine pool 'db-nodes-mp' on cluster 'mycluster'
----
.Verification
. List the available machine pools in your cluster:
+
[source,terminal]
----
$ rosa list machinepools --cluster=<cluster_name>
----
+
.Example output
[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 app=db, tier=backend us-east-1a No
----
. Verify that the labels are included for your machine pool in the output.
endif::[]
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 `<key>=<value>` 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::[]