Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubectl exec into container of a multi container pod

Tags:

kubernetes

I have problem login into one container of a multi-container pod. I get the container id from the kubectl describe pod <pod-name>

kubectl describe pod ipengine-net-benchmark-488656591-gjrpc -c <container id>  

When i try:

kubectl exec -ti ipengine-net-benchmark-488656591-gjrpc -c 70761432854f /bin/bash 

It says: Error from server: container 70761432854f is not valid for pod ipengine-net-benchmark-488656591-gjrpc

like image 795
PlagTag Avatar asked Oct 11 '16 14:10

PlagTag


People also ask

How do you communicate between two containers in a pod?

Multiple containers in the same Pod share the same IP address. They can communicate with each other by addressing localhost . For example, if a container in a Pod wants to reach another container in the same Pod on port 8080, it can use the address localhost:8080 .

Can Kubernetes pod run multiple containers?

In other words, if you need to run a single container in Kubernetes, then you need to create a Pod for that container. At the same time, a Pod can contain more than one container, usually because these containers are relatively tightly coupled.

How do you connect two containers in Kubernetes?

In Kubernetes, you can use a shared Kubernetes Volume as a simple and efficient way to share data between containers in a Pod. For most cases, it is sufficient to use a directory on the host that is shared with all containers within a Pod.


1 Answers

ah once more detailed reading the man page of kubectl exec :

Flags:

  -c, --container="": Container name. If omitted, the first container in the pod will be chosen   -p, --pod="": Pod name   -i, --stdin[=false]: Pass stdin to the container   -t, --tty[=false]: Stdin is a TTY 

So i just used the container name from my manifest.yaml and it worked like charm. Hope this helps others ...

Name of the container: ipengine-net-benchmark-iperf-server

kubectl exec -ti ipengine-net-benchmark-488656591-gjrpc -c ipengine-net-benchmark-iperf-server /bin/bash 
like image 193
PlagTag Avatar answered Sep 22 '22 15:09

PlagTag