kubectl run nginx --image=nginx:1.21.1 --labels "ver=1,app=nginx"
kubectl run nginx2 --image=nginx:1.21.1 --labels "ver=2,app=nginx"
Lets get the pods kubectl get pods --show-labels
Label selectors
kubectl get pods --selector="app in (nginx, httpd)"
kubectl get pods --selector="ver in (nginx, httpd)"
kubectl get pods --selector="ver in (1,5)"
kubectl get pods --selector='app!=nginx'
kubectl get pods --selector="ver notin (1,5)"
kubectl get pods --selector='!env' # doesnt have label with key env
kubectl get pods --selector='env' # has a label env with any value
Replica Set
Till now we have run individual container as Pods.
More often we want multiple replicas of our application to be running
Redundancy: mean failure can be tolerated
Scale: More requests can be served by your application.
In ReplicaSets, we can specify the desired state in terms of how many replicas we want and kubernetes will ensure that all the replicas are working