we are using labels in k8s to map the communications between the objects. here in Deployment object we are using the labels under the metadata, selector and template/metadata. I understood that labels under template (pod) match with labels under selector so that Replica set controller use pod labels to achieve HA (high availability). The question here is what is the use case of labels that we defined under the Demployment/metadata/labels? where it is being used.
The labels under the top-level medatdata.labels might be used to manage the deployment objects themselves – search for them, or if you had some kind of custom controller to modify deployments (say, a custom horizontal scaler), you could use the labels to local deployments that belonged to different groups in your organization, part of a larger application, or what the purpose of the deployment might be.
Hi Rob, Thanks you. I just started k8s beginner, I am bit confuse to understand what your are saying now. I understand that there are some cases custom controllers to modify the deployment object. such cases we could use deployment top level labels to modify.
I have no idea about controllers what does. I just heard during Replicaset topic about controller.
A controller is just a piece of software that watches a K8s cluster, sees things happen and does something in response. It’s an advanced topic, so don’t worry that it’s unfamiliar.
Labels are used everywere in Kubernetes to help find things and to help document what things do. And deployments can use them too.