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, 2019 in Kubernetes by Sam
• 6,260 points
758 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, 2019 by Sirajul
• 59,230 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
• 52,350 points
3,151 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,890 points
1,075 views
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,890 points
2,878 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

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

answered Jan 17, 2019 in Others by anonymous
15,476 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,034 views
0 votes
1 answer

Pods in Kubernetes

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

answered Jul 12, 2019 in Kubernetes by Sirajul
• 59,230 points
919 views
0 votes
2 answers

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

since K8s 1.15 kubectl rollout restart do the ...READ MORE

answered Jul 24, 2020 in Kubernetes by Mathieu V
7,199 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP