How to expose minikube ingress to internet?

Member

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

How to expose minikube ingress to internet?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by jewel , a year ago

@anissa 

To expose minikube ingress to the internet, you can follow these steps:

  1. Make sure you have minikube and kubectl installed on your machine.
  2. Start minikube by running the command minikube start.
  3. Enable the ingress addon by running the command minikube addons enable ingress.
  4. Verify that the ingress controller is running by running the command kubectl get pods -n kube-system. Look for a pod with a name starting with nginx-ingress-controller.
  5. To expose the ingress to the internet, you can use Layer 1 (LoadBalancer) or Layer 2 (NodePort) services. Here we will use Layer 1 for simplicity. Create an ingress resource YAML file, for example ingress.yaml, and configure the necessary routing rules. Here's an example configuration:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx" # Use the nginx ingress controller
spec:
  rules:
    - host: myapp.example.com
      http:
        paths:
          - pathType: Prefix
            path: "/"
            backend:
              service:
                name: my-service
                port:
                  number: 80


  • Apply the ingress configuration by running the command kubectl apply -f ingress.yaml.
  • Verify that the ingress is created by running the command kubectl get ingress.
  1. To expose the ingress to the internet, you need to use a cloud provider's LoadBalancer service. You can use tools like kubefwd or ngrok for local development. Here, we will use ngrok as an example: Download and install ngrok from the official website (https://ngrok.com/). Start ngrok by running the command ngrok http


Note: The process may vary depending on your setup and cloud provider. Make sure you have appropriate permissions and network configurations for exposing services to the internet.

Member

by adelia , 8 months ago

@anissa 

Alternatively, to expose Minikube Ingress to the internet on a local machine without using cloud services, you can use tools like ngrok which creates a secure tunnel to your local machine. Follow these steps:

  1. Make sure Minikube is running and the Ingress addon is enabled.
  2. Install ngrok by downloading it from their official website and following the installation instructions.
  3. Start ngrok by running the command ngrok http
  4. ngrok will generate a public URL that you can access to route traffic to your Minikube Ingress.


Make sure to adjust the port number as needed based on the port your Ingress controller is using. This method is suitable for testing and development purposes. Remember that using tools like ngrok for production environments may not be recommended due to security and performance concerns.