How to access minikube IP and service port in container?

8/19/2020

I have a minikube cluster containing multiple services:

# kubectl get services
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
service1     NodePort    10.96.123.85     <none>        8080:32157/TCP   13d
service2     ClusterIP   10.96.0.1        <none>        8081/TCP         13d


# minikube ip
172.18.77.222

# kubectl get pods
NAME                        READY   STATUS             RESTARTS   AGE
application1-aaaaa-bbbbb    1/1     Running            1          121m
application2-aaaaa-bbbbb    1/1     Running            1          112m

I want to call application1 from application2 via minikube ip and NodePort. (http://172.18.77.222:32157)

(Application1 is a Keycloak server. The issuer field in ACCESS_TOKEN contains the "external" minikube url "http://172.18.77.222:32157", therefore keycloak accept only calls sent to 172.18.77.222:32157)

How can I access

  • the minikube ip and
  • the NodePort of service1

from application2?

-- user1552545
keycloak
kubectl
kubernetes
minikube

1 Answer

8/20/2020

You can use consul for service discovery if you want to call functionality from another service . The Consul helm chart must be deployed (once in the Cluster) to allow Service Discovery between the your services. https://www.consul.io/docs/k8s

-- Dhiraj Surve
Source: StackOverflow