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
• 4,330 points
33 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
• 41,000 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
• 46,110 points
53 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
267 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
133 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
3,501 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
• 41,000 points
42 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
• 41,000 points
65 views