☁️ Label and Taint Management on Huawei Cloud CCE Service
Introduction
Kubernetes is becoming increasingly popular for deploying and managing modern software applications. Huawei Cloud’s Container Cloud Engine (CCE) service simplifies application deployment and management in a cloud environment using Kubernetes. In this article, we will focus on label (tag) and taint management issues in Huawei Cloud CCE service.
What are Taints — Labels and Why We Need
Kubernetes tags are text tags that are used to identify and group resources. from each source. (for example, pod, service, storage unit, etc.) Many labels can be assigned. Labels provide a versatile way to identify and process resources.
Label and taint values are important concepts used in Kubernetes for different purposes.
Label:
- Grouping and Organization: Tags are used to group resources into logical groups. For example, by labeling resources with labels such as “app: frontend” or “environment: production” It is possible to specify which application or environment these resources belong to.
- Process Selection: Tags are used to select resources that have specific criteria. For example, we can use this tag to select all the pods that a service has a specific tag.
- Tracking and Troubleshooting: Tags can track resources and identify issues. For example, we can do a bug search between pods with a specific label.
Pod Labeling: Add tags to a pod to the metadata section in your pod definition file. For example:
apiVersion: v1
kind: Pod
metadata:
name: my-pod
labels:
app: frontend
environment: production
spec:
containers:
- name: my-container
image: nginx
In the example above, the labels “app: frontend” and “environment: production” are added to the pod named “my-pod”. Labeling Other Resources: Similarly, other Kubernetes resources. (for example, services, storage units, replicas) Add relevant tags to the metadata section to add tags.
Tainting a Node: To add a taint to a node, you can use a command like this using kubectl:
kubectl taint nodes <node-name> key=value:taint-effect
kubectl taint nodes node1 disktype=ssd:NoSchedule
Taint:
- Determining the Physical Location of Resources: Taint values by ensuring that certain nodes have certain taint values It is used to determine the physical location of resources. For example, a taint value can be used to indicate that a node has specialized hardware for storing data.
- Determining the Relation of Resources to Resources: Taint values can be used to prevent specific resources from being assigned to specific nodes. This can be especially useful when you want to restrict certain types of workloads to certain types of nodes. For example, database pods can be placed on nodes with a certain taint value.
For these reasons, label and taint values are important to optimize the organization, management, and performance of resources in the Kubernetes environment. Labels are used to identify resources, and taint values are used to direct the placement of resources on nodes.
To Define Label and Taint in the Huawei Cloud Console:
What we need before we start:
Select any node from the nodes tab and select the Manage taint option from the “More” section.
spec:
containers:
- name: my-container
image: nginx:latest
tolerations:
- key: "example.com/node1-test-taint " # Taint anahtarı
operator: Exists
effect: NoSchedule # Podlar bu taint'i tolere etmeli (NoSchedule, PreferNoSchedule veya NoExecute olabilir)
The label can be added by selecting any node from the nodes tab again and selecting the Manage label option from the “More” section.
We can check the taint and label as in the image below.
If you don’t look like this, You can click on the settings on the same page and check that it is selected as below.
We can access the node information from the pod list to check which node the pod is working on.
Deployment:
I created an Nginx deployment without any changes. It works on a node I have not added the label and taint.
By changing the information from the pod yaml file as follows, we can give the node information label information that the pod needs to work physically. Below is just an example. Please change it according to your system and label information.
The pode label I created started working on the node I assigned.
The pod was initially working on a node so I didn’t add a label to it. Add the YAML file and node label information to the pod, and this time the pod started working on the other node. Now we will test this process by deleting the label and taint information that I have added on the node and making the pod give an error.
The label and taint I assigned to Node1 also started to give errors and did not work.
Error when label and taint information on the node is deleted. We see that it is not scheduled on another node. Because there is no label and taint information on the other node to create a running state of the pod.
Conclusion
Huawei Cloud CCE service optimizes application deployment and management in the cloud environment by facilitating tag and tag management on Kubernetes. Tags and taints are powerful tools for identifying, grouping and organizing resources, and Huawei Cloud CCE uses these features to help users manage their cloud-based applications more efficiently.