Lab 06 - Labels, selectors and annotations
Lab 06 - Labels, selectors and annotations
InfodiscoverGoal: slice a pile of Pods any way you need. Chapter: Labels, selectors and annotations
Set-up - six Pods with different labels:
cd ~
kubectl create ns shop
for p in "web-1 app=web,env=prod,tier=frontend" "web-2 app=web,env=dev,tier=frontend" \
"api-1 app=api,env=prod,tier=backend" "api-2 app=api,env=test,tier=backend" \
"db-1 app=db,env=prod" "cache-1 app=cache,env=dev"; do
set -- $p
kubectl run $1 -n shop --image nginx:1.27 --labels $2
done
kubectl config set-context --current --namespace=shop
Task 1. List all Pods with their labels. Then show only app and env as
columns.
Task 2. Show only production Pods. Expected: web-1, api-1, db-1.
Task 3. Show production frontend Pods. Expected: web-1.
Task 4. Show Pods in dev or test. Expected: 3 Pods.
Task 5. Show Pods that have no tier label. Expected: db-1, cache-1.
Task 6. Promote api-2 from test to prod, and give db-1 the label
tier=data.
Task 7. Remove the env label from cache-1.
Task 8. Add the annotation owner=team-a@example.com to every web Pod,
then read it back from one of them.
Task 9. Try to select Pods by the annotation with -l owner=.... Why does
it return nothing?
Task 10. Delete all dev Pods with one command.
Clean up
kubectl config set-context --current --namespace=default
kubectl delete ns shop