Chapter 6. Labels and Annotations Flashcards
What are labels ?
Labels provide identifying metadata for objects. These are fundamental qualities of the object that will be used for grouping, viewing, and operating.
Command to create labels:
kubectl run alpaca-prod \
- -image=gcr.io/kuar-demo/kuard-amd64:blue \
- -replicas=2 \
- -labels=”ver=1,app=alpaca,env=prod”
Command to show labels:
kubectl get deployments –show-labels
Command to edit labels:
kubectl label deployments alpaca-test “canary=true”
Command to show a label value as a column:
kubectl get deployments -L canary
Command to remove a label:
kubectl label deployments alpaca-test “canary-“
Command to list pods based on a specific label:
kubectl get pods –selector=”ver=2”
Command to specify to selector ( will behave as an AND operation):
kubectl get pods –selector=”app=bandicoot,ver=2”
Command to ask if a label is in a set of values:
kubectl get pods –selector=”app in (alpaca,bandicoot)”
Command to ask if a label is set at all:
kubectl get deployments –selector=”canary”
What are annotations ?
Annotations provide a place to store additional metadata for Kubernetes objects with the sole purpose of assisting tools and libraries.
What are labels selectors ?
Label selectors are used to filter Kubernetes objects based on a set of labels.
Command to clean all deployments:
kubectl delete deployments –all