I am learning Kubernetes and trying to deploy an app using MiniKube.
I have managed to expose the service mapped to nginx pod on Minikube IP. I can access the nginx service on url $(minikube ip):$(serviceport). which is fine, however I am looking to expose this to the public network. Currently this service is only accessible via my local machine, any other machine on my wifi network is not able to access it as it is exposed only on minikube ip. I dont want to forward the port in my local linux via IPtables, and I am looking for a built in solution to expose the port to world (and not just on minikube ip). I know it can be achieved as minikube dashboard by default expose the service on localhost, this implies that minikube can talk to other network adapters and can register the port, I am not sure how.
Here is my service yaml:
apiVersion: v1
kind: Service
metadata:
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
name: nginxservice
labels:
app: nginxservice
spec:
type: NodePort
ports:
- port: 80
name: http
targetPort: 80
nodePort: 32756
selector:
app: nginxcontainer
2
Answers
You have to create ingress.
Follow the steps in this doc – https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/
@subudear is right – you need Ingress.
To be able use regularly use ingress(Im not talking about
minikube
right now) – it is not enough simply createIngress
object. You should first install related ingress controller.There are lot of them, most popular are:
NGINX Ingress Controller
Kubernetes Nginx Ingress Controller
Traefik
Istio Ingress Controller
First 2 are very similar, but use absolutely different annotations. It often happens people confuse them
Talking about
minikube
:As per guidelines, in order to install ingress the only you have to do is
minikube addons enable ingress
Please note that by default,
minikube
installing exactly NGINX Ingress controllernginx-ingress-controller-5984b97644-rnkrg 1/1 Running 0 1m