having a pod with two containers, can i ping each other using the container name?

0 votes
How can the conatiners in a kubernetes pod ping each other? Can I do it using the container name?
Jul 19 in Kubernetes by Amy
31 views

1 answer to this question.

0 votes
  • Containers on same pod act as if they are on the same machine. 

  • You can ping them using localhost:port itself.

  •  Every container in a pod shares the same IP. You can `ping localhost` inside a pod. 

  • Two containers in the same pod share an IP and a network namespace and They are both localhost to each other. 

  • Discovery works like this: 

  • Component A's pods -> Service Of Component B -> Component B's pods and Services have domain names servicename.namespace.svc.cluster.local, the dns search path of pods by default includes that stuff, so a pod in namespace Foo can find a Service bar in same namespace Foo by connecting to `bar`​.

answered Jul 19 by Sirajul
• 31,980 points

Related Questions In Kubernetes

+1 vote
1 answer
0 votes
1 answer

Pods IP address from inside a container in the pod

Make sure that your pod yaml file ...READ MORE

answered Aug 29, 2018 in Kubernetes by Kalgi
• 41,820 points
144 views
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17 in Others by anonymous
2,665 views
+3 votes
1 answer
0 votes
1 answer

how can i access two containers that are inside a pod from the browser with IP address?

Just do port forward. kubectl port-forward [nginx-pod-name] 80:80 kubectl ...READ MORE

answered Jul 18 in Kubernetes by Sirajul
• 31,980 points
48 views
0 votes
1 answer