I know we can do the following commands:
kubectl get pods -l app==<kafka>
gets pods with kafka labelkubectl get pods -l app!=<kafka>
gets pods without kafka labelkubectl get pods -l app=kafka,env=staging
gets pods with both kafka and staging labelsBut what about if I want to list all the pods which have either kafka
or zookeeper
label. Something like -l app==kafka||zookeeper
.
Is this even possible with -l
kubectl option...?
Have you tried this?
kubectl get pods -l 'app in (kafka, zookeeper)'
See: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api