Kubectl get pods - How to filter pods by partial name

Viewed 5407

The command kubectl get pods <POD NAME> will return the specific pod with that name. I wonder if there is a way that I can use part of the name, for instance, a command that returns all pods that start with j.

3 Answers

Found it. in PS:

kubectl get pods | Select-String '^j'

in bash:

kubectl get pods | grep ^j

If you have crictl installed in your node:

 crictl pods --name '^j'

Filter without grep (unfortunately requires full name):

kubectl get pods --field-selector metadata.name=<your_pod_name>

this works for me. Of course you have to precise the namespace if not set in the current-context

Related