How to expose ingress on minikube to external hosts?

Member

by mose , in category: General Help , a year ago

How to expose ingress on minikube to external hosts?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by samara , a year 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.

by monroe.bahringer , 7 months ago

@mose 

If you are using Minikube with a Docker daemon as the driver, you can enable exposure from external hosts by running these commands:

  1. Enable the NGINX Ingress controller on Minikube: minikube addons enable ingress
  2. Get the IP address of your Minikube VM: minikube ip
  3. Check that the NGINX Ingress controller pods are running: kubectl get pods -n kube-system | grep ingress
  4. Create an Ingress resource for your application. Here is an example YAML file (example-ingress.yaml): apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example-ingress spec: rules: - host: example.com http: paths: - path: / pathType: Prefix backend: service: name: example-service port: number: 80
  5. Apply the Ingress resource to your Minikube cluster: kubectl apply -f example-ingress.yaml
  6. Update the /etc/hosts file on your machine to point the hostname you specified in the Ingress resource to the Minikube IP address retrieved in step 2.
  7. Test accessing the service from an external host using the specified hostname (e.g., example.com).


By following these steps, you should be able to expose the Ingress on Minikube to external hosts for accessing your services.