Getting list of pod name

Hello all,

i’m actually preparing the cka and i have a little issue with listing pod name and pass pod name to command.

i wrote the below command:

export POD_NAME=$(kubectl get pods -n dns-ns -o jsonpath='{.items[*].metadata.name}')

to get the list of pod and pass it to the below command:

k exec -i -t $POD_NAME -- nslookup kubernetes.default

the command result with below message:

Error from server (NotFound): pods "dns-deploy-cka-fd5f8fbf5-9swpn" not found```

does anyone can help me on this please ?

Thank you,

Hi @pi3rre.hernandez

Your second command looks for a Pod by the name $POD_NAME in the Default namespace, as you haven’t provided the Pods namespace in the command.

Try:

k -n dns-ns exec -i -t $POD_NAME -- nslookup kubernetes.default

Regards.

Hello @Santosh_KodeKloud

Thank you taking time.

I figured it out my mistake after posting my request.

Thank you very much