How can we get the name of the pod and namespace using an imperative command and write to a file? (this was part of a qa in my last CKAD exam) I have read somewhere that metadata of pod contains the name of the pod and namespace but don’t know what is the command
It is not allowed to share the exam questions. it is against the NDA.
@Mayank Agarwal outside of the NDA issues, imperative way to get the names of pods and namespaces should be very straightforward / one of the simplest get commands:
kubectl get pods,namespaces
Or you can use the short forms:
kubectl get po,ns