Kubernetes - Communicating b/w services

3/22/2018

I have a Kubernetes cluster with 2 services deployed and the services are exposed to internet thru ingress. I am able to access the services outside the cluster using the ingress host. How to access the service within the cluster? Do i need to use the same ingress host approach for the service to access within the cluster?

So, If i deploy 2 services( Service A & Service B) in parallel, How can i configure service A to talk to service B in the service A property file?

Currently, we have deployed our applications into Linux VM's and service A proeprty file will have http:<serviceB_VIP>/api/v1/...

How to achieve the same thing kubernetes cluster? How to configure the service B URL in service A property before the deployment so that both the service can be deployed in parallel.

Thanks

-- user1578872
kubernetes

2 Answers

3/22/2018

You can expose service within the cluster via ClusterIP.

There are 4 types of service in kubernetes.

  1. NodePort:- expose service on Kubernetes Nodes port.

  2. ClusterIP:- You can expose your service with the cluster only

  3. LoadBalancer:- You can expose your service on Load Balancer which creates one nginx load balancer in GCP.

  4. External name

-- Sachin Arote
Source: StackOverflow

3/22/2018

The serviceName: and servicePort: in Ingress backend: are the same objects one would use to communicate from within the cluster. In fact, that's why almost every object's name in kubernetes must be DNS-compatible: because they are often exposed by kube-dns.

So, for a Service with metadata.name: foo and metadata.namespace: bar, the service is accessible from within the cluster as foo.bar.svc.cluster.local, containing all the port:s from that same Service.

I highly, highly, highly recommend reading the kubernetes documentation about Services

-- mdaniel
Source: StackOverflow