Kubernetes - Labels, Selectors, and Annotations đˇī¸
Description đ
Filter and group pods
using labels
and selectors
. Annotations
are used to add metadata to pods
.
Basic Commands
đ
-
select
pods
with labelkubectl get pods --selector <label-name>=<label-value>
-
count
pods
with labelkubectl get pods --selector <label-name>=<label-value> --no-headers | wc -l
-
select all with multiple labels
kubectl get all --selector <label-name>=<label-value>,<label-name>=<label-value>
Examples đ§Š
-
sample
pod
withlabel
apiVersion: v1 kind: Pod metadata: name: app-1 labels: app: app-1 function: front-end spec: containers: - name: nginx-app-1 image: nginx:1.7.9 ports: - containerPort: 8080