Hi I am having a shell script.
i am trying the following command to get a pod name
K6_POD=$(kubectl get pod -l 'app.kubernetes.io/component=k6' -n k6 -o jsonpath="{.items[0].metadata.name}")
however with the above command, it returns the name of a terminating pod instead of a pod with status Running appreciate if you can help
You can add the --field-selector
flag e.g. kubectl get pods --field-selector=status.phase=Running
source: https://kubernetes.io/docs/reference/kubectl/cheatsheet/