Labels and Selectors
Tips and Tricks
For simulated Practice problems visit KillerCoda.
-
Solution
k run sumo --image=nginx --labels=tier=frontend
--OR--
# update metadata of pod yaml apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: # add label tier: frontend name: sumo spec: containers: - image: nginx name: sumo resources: {} dnsPolicy: ClusterFirst restartPolicy: Always status: {}
verify labels on pods running
k get po --show-labels
-
create 3 pods named
one
,two
andthree
with imagenginx:alpine
and label themresource=alpha
,resource=beta
andresource=gama
respectively.Solution
k run one --image=nginx:alpine --labels=resource=alpha k run two --image=nginx:alpine --labels=resource=beta k run three --image=nginx:alpine --labels=resource=gama
-
Solution
k label pod one two three tier=backend
-
Solution
k label pod -l "tier in (frontend,backend)" app_version=v1
-
Solution
k label pod two app_version=v2 --overwrite
-
Solution
k label pod one app_version-