Selectors
Selectors help to choose and find the resources that you are particularly looking for using labels.
For working with selectors, here is an example find you can proceed with. The same can be extended to deployments and services.
$ kubectl create -f <file name for deployment>
$ kubectl get pods - -show-labels
$ kubectl get pods - -selector env=production
$ kubectl get pods --selector dev-lead=carisa
Working with Multiple Selectors
$ kubectl get pods --selector env=production,dev-lead=carisa
$ kubectl get pods --selector env=production,dev-lead!=carisa
In and Not In Operator
$ kubectl get pods -l 'release-version in (1.0,2.0)'
$ kubectl get pods -l 'release-version notin (1.0,2.0)'
Deleting pods with labels
$ kubectl delete pods -l dev-lead=carisa
Last updated
Was this helpful?