How to expose ingress on minikube to external hosts?

Member

by mose , in category: General Help , 3 months ago

How to expose ingress on minikube to external hosts?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by samara , 3 months ago

@mose 

To expose ingress on Minikube to external hosts, you can follow these steps:

  1. 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
  2. Verify that the ingress addon is enabled: minikube addons list
  3. 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
  4. Apply the ingress resource to your Minikube cluster: kubectl apply -f example-ingress.yaml
  5. 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:
  6. 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.