@mose
To expose ingress on Minikube to external hosts, you can follow these steps:
- Start Minikube with additional flags to enable the ingress addon and to set the IP address that external hosts can access:
minikube start --addons=ingress --extra-config=apiserver.service-node-port-range=1-35000
- Verify that the ingress addon is enabled:
minikube addons list
- Create an ingress resource YAML file. For example, create example-ingress.yaml with the following content:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
spec:
rules:
- host: example.com # Your external hostname
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: example-service # Name of the service you want to expose
port:
number: 80 # Port number of the service
- Apply the ingress resource to your Minikube cluster:
kubectl apply -f example-ingress.yaml
- Update your /etc/hosts (or equivalent) file to map the specified host in the ingress resource to the Minikube IP address. For example, add the following line:
- Once the ingress controller is running and the /etc/hosts file is updated, you should be able to access the service from an external host using the specified host name (e.g., example.com).
Note: If you're on Windows and using Docker Desktop, make sure to enable Kubernetes in Docker Desktop settings, as that will be used to expose the ingress externally.