Technical questionAccepted answer
kubectl exec into a container without using the random guid at the end of the pod name
Johnny Metz
Aug 28
0 views1
To exec into a container in a pod, I use the following two commands (note the template flag in the first command trims the output to print just the name of the pods):
$ kubectl get pods --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'
app-api-6421cdf4fd-x9tbk
app-worker-432f86f54-fknxw
app-frontend-87dd65d49c-6b4mn
app-rabbit-413632c874-s2ptw
$ kubectl exec -it app-api-6421cdf4fd-x9tbk -- bash
It would be nice to exec into the container without having to discover the random guid at the end of the pod name every single time. How can I do this?
1 answer
Accepted answer · original discussion
Ahmed Akrout
PermalinkJan 31
You can exec into a pod using the deployment.
You can use the following command:
kubectl exec -it deploy/<deployment-name> -- bash
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.