Calls between 2 APIs on the same Kubernetes cluster

10/21/2021

I have two Api's on the same cluster and when I run the get services I get the following.

dh-service       ClusterIP   10.233.48.45    <none>        15012/TCP           70d
api-service      ClusterIP   10.233.54.208   <none>        15012/TCP      

Now I want to make a Api call from one API to the other, When I do it using the Ingress address for the two Images I get 404 Not Found.

What address should I use for my post calls? Will the cluster ip work ?

-- Mr.Gomer
api
kubernetes

1 Answer

10/21/2021

I want to make a Api call from one API to the other

If they are in the same namespace and you use http, you can use:

http://dh-service
http://api-service

to access them.

If e.g. the api-service is located in a different namespace e.g. blue-namespace you can access it with:

http://api-service.blue-namespace

See more on DNS for Services and Pods

-- Jonas
Source: StackOverflow