Communication issue between frontend and backend pods using cluster IP, it works with Nodeport or Loadbalancer IP

Mani, Subhash 0 Reputation points
2024-10-15T12:26:58.0266667+00:00

Communication issue between frontend and backend pods using cluster IP, it works with Node port or Load balancer IP.

I have a three-tier application which we have deployed as pods in AKS cluster. Front end is running using tomcat and backend is using jdk 11. Frontend pod is able to communicate with the backend pod only with public IP(either nodeport or LoadbalancerIP) it is not working with Cluster IP.
I do not want to expose the backend and the DB over the public IP but for some reason it is not working with cluster IP.

Azure Kubernetes Service
Azure Kubernetes Service
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
{count} votes

1 answer

Sort by: Most helpful
  1. Mounika Reddy Anumandla 7,135 Reputation points Moderator
    2024-10-17T13:44:12.8533333+00:00

    Hi Mani, Subhash,

    Thank you for reaching to us again!

    I have investigated more on this context and thought this would help you.
    As per my understanding, I think it would be better you go with headless services.
    A Kubernetes headless service is a form of service that doesn’t allocate a cluster IP to represent a set of pods. Instead of load-balancing traffic across a group of pods, a headless service allows DNS queries for the service to go back to the individual IP addresses of all the pods associated with it. Headless service are useful in scenarios in which databases or other clustered applications want to discover and communicate with each other.

    Unfortunately, if the pod is killed, in deployment a new pod will spin up but the pod name changes. So, we suggest you use stateful sets so that the pod name can't be changed if pod is killed. The new pod will spin up with the same name.

    Headless services are usually used with StatefulSets, where every pod has a unique identity. This allows for direct conversation with particular pods. It’s also useful in scenarios requiring custom load balancing or direct communication with individual pods, such as in database clustering setups.
    Additionally, I can provide you with some documents:
    https://kubernetes.io/docs/concepts/services-networking/service/#headless-services
    https://stackoverflow.com/questions/52707840/what-is-a-headless-service-what-does-it-do-accomplish-and-what-are-some-legiti

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.