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
• 5,970 points
139 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
• 55,750 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
• 51,890 points
403 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,850 points
393 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,850 points
508 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, 2019 in Others by anonymous
7,673 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 11, 2019 in Kubernetes by Kalgi
• 51,890 points

reshown Apr 12, 2019 by Kalgi 2,269 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
• 55,750 points
76 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 23 in Kubernetes by Mathieu V
370 views