Home > OS >  how do resources talk to each other from different namespaces
how do resources talk to each other from different namespaces

Time:12-07

Conditions: I have a 3 tier application to deploy using Kubernetes. I have created two namespaces for backend and frontend respectively.

Problem: I want to know how would my backend talk to the frontend or vice versa.

In simple words, how do backend and frontend communicate if they are in different namespaces?

Kindly help.

CodePudding user response:

There's two ways: internal-only and external.

For both, create a kubernetes service for the front and back end services.

For external, the service type must LoadBalancer. You install the External DNS plugin which will let you create an external DNS name that you can access by the other service. This will also allow you to access the service outside the cluster if you wish.

For internal, you make the service type ClusterIP or NodePort. When you create the service, you can then access them using the format: service-name.namespace.svc.cluster.local

For example, an nginx service running on the namespace internal would be accessed as the DNS name nginx.internal.svc.cluster.local

This service cannot be accessed outside of the cluster.

You can sometimes drop the cluster.local part, but I include it as habit.

CodePudding user response:

applications can communicate with other services outside their namespace , just use the correct dns name

<Service Aame>.<Namespace Name>.svc.cluster.local
  • Related