In this blog, we will explore about Labels and Annotation. We will explain their use cases so that we can decide whether to use labels or annotation for a particular use case.
In my previous blog we have already seen different kinds of pods and their life cycle.
In general, we always want to organize our pods based on some properties so that we can query against specific pods. To do so we will be add labels to the pods.
Prerequisite:
- Functional Kubernetes Cluster configured
- Kubernetes’ command-line tool, kubectl, which is the command-line interface for running commands against Kubernetes clusters.
- Clone this git repo for all the yaml files which we will be using in this blog
Agenda:
- Labels
- Pod Create with Labels
- Adding Labels to a Running Pod
- Select Kubernetes objects using Label selector
- Modify/Delete the Label
- Annotation
- Pod create with Annotation
- Modify/Delete the annotation
Labels
- They are are the metadata which contain unique information of the Kubernetes objects
- key-value pair attached to the objects like pod
- We can attach the label at the time of creation or we can update it at runtime