CyberKeeda In Social Media
Showing posts with label Kubernetes. Show all posts
Showing posts with label Kubernetes. Show all posts

Kubernetes Inter-pod communication within a cluster.

 

In this post, what are the ways through which we can configure our pods to communicate with each other within the same Kubernetes cluster.

In order to understand the same, we have create a lab scenario where we have two pods running inside the same cluster.


We will focus on two namespace 
  • default
  • web-apps
Let's see what are the pods running in both namespaces.
  • Pods running under default namespace.


  • Pods running under web-apps namespace.


What's the application - So we have our application pod named as "genache-cli-deploymnet" running under default namespace, within this lab environment we will know how we can establish communication between microservices like my-shell and weapp-shell to genache-cli-core.

Here are the different ways..

Using Pod's IP.

Every pod gets an IP from the defined CIDR range, which can be used to communicate directly from each other, irrespective of namespaces.
Thus a simple pattern of http://<pod-ip-address>:<container-port-number>

So as per our lab environment, we will try to establish a connection to genache-cli running with IP Address as curl 10.1.1.160 and on Port 8545

> kubectl get pods -o wide

NAME                                     READY   STATUS    RESTARTS         AGE   IP           NODE             NOMINATED NODE   READINESS GATES
genache-cli-deployment-8f48b88fb-dqnkx   1/1     Running   20 (2d10h ago)   30d   10.1.1.160   docker-desktop   <none>           <none>
my-shell                                 1/1     Running   0                37m   10.1.1.162   docker-desktop   <none>           <none>
Output from my-shell running on web-apps namespace
root@webapp-shell:/# curl http://10.1.1.160:8545/
400 Bad Request 

Output from webapp-shell running on default namespace.

root@my-shell:/# curl http://10.1.1.160:8545/
400 Bad Request

Read more ...
Designed By Jackuna