Connect 2 pods

0 votes
I have two Kubernetes-pods one is an application pod and another one is a database pod. How can i connect my application pod with the database pod?
Jul 18 in Kubernetes by Sam
• 1,520 points
9 views

1 answer to this question.

0 votes
  • You can connect those two pods by using a service object. 

  • The reason being, if the database pod goes away, it's going to come up with a different name and IP address, which means the connection string would need to be updated every time, managing that is difficult. 

  • The service proxies traffic to pods and it also helps in load balancing of traffic if you have multiple pods to talk to. 

  • It has its own IP and as long as service exists pod referencing this service in upstream will work and if the pods behind the service are not running, a pod will not see that and will try to forward the traffic but it will return a 502 bad gateway.

  • So just define the Service and then bring up your Pods with the proper label so the Service will pick them up.

answered Jul 18 by Sirajul
• 19,070 points

Related Questions In Kubernetes

0 votes
1 answer

Is possible to have same k8s service for multiple pods?

Reserve a static IP and then assign ...READ MORE

answered Jul 20, 2018 in Kubernetes by Kalgi
• 39,310 points
31 views
0 votes
1 answer

deleting pods using kubernetes replication controller

The pods which are managed by ReplicationController ...READ MORE

answered Jul 24, 2018 in Kubernetes by DareDev
• 6,810 points
195 views
0 votes
1 answer
0 votes
1 answer

Getting the pod's ip address for the container inside of it

You can make sure that the replication ...READ MORE

answered Aug 24, 2018 in Kubernetes by DareDev
• 6,810 points
59 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
1,648 views
+3 votes
1 answer
0 votes
1 answer

Pods in Kubernetes

Pod is a single or bunch of ...READ MORE

answered Jul 12 in Kubernetes by Sirajul
• 19,070 points
18 views
0 votes
1 answer

How do I update all my pods if the image is changed but the tag is the same?

Make sure your imagePullPolicy is set to ...READ MORE

answered Jul 12 in Kubernetes by Sirajul
• 19,070 points
38 views