Tagging and labeling clusters and services
When you create a cluster, services or resources that are created and used by that cluster are tagged to indicate which cluster is using them. You can also manually tag Red Hat OpenShift on IBM Cloud clusters to help manage your IBM Cloud resources.
For example, you might add key:value tags to your cluster and other cloud resources so that your billing department track resources, such as costctr:1234. Tags are visible account-wide. For more information, see
Working with tags.
- Service tags added to services used by Red Hat OpenShift on IBM Cloud are in the format
containers-kubernetes:cluster:CLUSTER-ID. - Service tags are added asynchronously after services are provisioned and can take some time to appear.
- Service tags cannot be modified or deleted by the customer only the service that creates them.
- User tags are added manually by users in the account.
- The following resources are tagged with Red Hat OpenShift on IBM Cloud service tags.
- Secondary storage volumes.
Tags are not the same thing as Kubernetes labels. Kubernetes labels are key:value pairs that can be used as selectors
for the resources that are in your cluster, such as adding a label to worker pool to deploy an app to only certain worker nodes. Tags are an IBM Cloud tool that you can use
to filter your IBM Cloud resources, such as clusters, storage devices, or Watson services.
Do not include personal information in your tags. Learn more about securing your personal information when you work with Kubernetes resources.
Manually adding labels to existing worker pools
You can assign a worker pool a label when you create the worker pool, or later by following these steps. After a worker pool is labeled, all existing and subsequent worker nodes get this label. You might use labels to deploy specific workloads only to worker nodes in the worker pool, such as edge nodes for load balancer network traffic.
Do not include personal information in your labels. Learn more about securing your personal information when you work with Kubernetes resources.
Before you begin: Access your Red Hat OpenShift cluster.
-
List the worker pools in your cluster.
ibmcloud oc worker-pool ls --cluster <cluster_name_or_ID> -
List the existing custom labels on worker nodes in the worker pool that you want to label.
ibmcloud oc worker-pool get --cluster <cluster_name_or_ID> --worker-pool <pool> -
Label the worker pool with a
key=valuelabel. When you set a worker pool label, all the existing custom labels are replaced. To keep any existing custom labels on the worker pool, include those labels with this option.You can also rename an existing label by assigning the same key a new value. However, don't modify the worker pool or worker node labels that are provided by default because these labels are required for worker pools to function properly. Modify only custom labels that you previously added.
ibmcloud oc worker-pool label set --cluster <cluster_name_or_ID> --worker-pool <worker_pool_name_or_ID> --label <key=value>Example to set
<key>: <value>as a new custom label in a worker pool with existing labelsteam: DevOpsandapp: test:ibmcloud oc worker-pool label set --cluster <cluster_name_or_ID> --worker-pool <worker_pool_name_or_ID> --label <key=value> --label team=DevOps --label app=test -
Verify that the worker pool and worker node have the
key=valuelabel that you assigned.- To check worker pools:
ibmcloud oc worker-pool get --cluster <cluster_name_or_ID> --worker-pool <worker_pool_name_or_ID> - To check worker nodes:
- List the worker nodes in the worker pool and note the Private IP.
ibmcloud oc worker ls --cluster <cluster_name_or_ID> --worker-pool <worker_pool_name_or_ID> - Review the Labels field of the output.
Example output for an added label (oc describe node <worker_node_private_IP>app=test):Example output for a removed label (theLabels: app=test arch=amd64 ...app=testlabel is gone):Labels: arch=amd64 ...
- List the worker nodes in the worker pool and note the Private IP.
- To check worker pools:
-
Optional: To remove an individual label from a worker pool, you can run the
ibmcloud oc worker-pool label setcommand with only the custom labels that you want to keep. To remove all custom labels from a worker pool, you can run theibmcloud oc worker-pool label rmcommand.Do not remove the worker pool and worker node labels that are provided by default because these labels are required for worker pools to function properly. Remove only custom labels that you previously added.
Example to keep only the
team: DevOpsandapp: testlabels and remove all other custom labels from a worker pool:ibmcloud oc worker-pool label set --cluster <cluster_name_or_ID> --worker-pool <worker_pool_name_or_ID> --label team=DevOps --label app=testExample to remove all custom label from a worker pool:
ibmcloud oc worker-pool label rm --cluster <cluster_name_or_ID> --worker-pool <worker_pool_name_or_ID>
After you label your worker pool, you can use the label in your app deployments so that your workloads run on only these worker nodes, or taints to prevent deployments from running on these worker nodes.