The following explanations are done for Minikube environment installed on Ubuntu.
I have used the following references:
- https://stackoverflow.com/questions/62162209/ingress-nginx-errors-connection-refused
- https://medium.com/faun/metallb-configuration-in-minikube-to-enable-kubernetes-service-of-type-loadbalancer-9559739787df
The problem that we try to solve
In order for the code running inside of a pod (the name of the pod could be client) to make a sync call over HTTP to a Kubernetes service located in the default namespace (the name of the service could be auth-srv) there are two options that can be uses:
- client can call directly into the auth-srv using an URL that has the following format: http://auth-srv:port/path
- client can call the auth-srv through ingress-nginx and this option allows one to take advantage of all the configured routing rules that route the request to the appropriate service. In this case one will use cross namespace service communication since the ingress-nginx-controller is deployed in another namespace kube-system
To make the second option work one should make sure that the ingress and metallb addons are enabled in Minikube:
$ minikube addons enable ingress
$ minikube addons enable metallb
Than make sure to apply all the configuration files to your k8s cluster:
$ kubectl apply -f .
In my case I am using Skaffold to handle my k8s configuration files, so I will use instead:
$ skaffold dev
Check the objects created in kube-system namespace:
$ kubectl get all -n kube-system
Next create in kube-system a LoadBalancer service that will expose the ingress-nginx-controller:
$ kubectl expose deployment ingress-nginx-controller --target-port=80 --type=LoadBalancer -n kube-system
Check that the service has been created:
$ kubectl get services -n kube-system
Now everything is set up and you can use inside the client pod the following URL to make sync calls through ingress-nginx: http://ingress-nginx-controller.kube-system.svc.cluster.local/path
The URL above respects the following format http://SERVICENAME.NAMESPACE.svc.cluster.local