Answers: <h1><strong>TLDR;</strong></h1>
  <p><em>Look at <strong><code>NodePort</code></strong> or <strong><code>Ingress</code></strong> to expose a Kubernetes <code>minikube</code> service externally</em>.</p>
  <p>For <code>minikube</code> specifically, there is one last networking layer between the <code>minikube</code> VM and the host. You need to enable port forwarding from the Host into the VM.  To forward <a href="https://minikube.sigs.k8s.io/docs/handbook/accessing/#increasing-the-nodeport-range" rel="nofollow noreferrer">the entire default <code>minikube</code> <code>NodePort</code> range</a>:</p>
  <pre><code>for port in {30000..32767}; do VBoxManage controlvm minikube natpf1 &quot;NodePort$port,tcp,,$port,,$port&quot;; done
  </code></pre>
  <p>To disable the port forwarding when you're done:</p>
  <pre><code>for port in {30000..32767}; do VBoxManage controlvm minikube natpf1 delete &quot;NodePort$port&quot;; done
  </code></pre>
  <h2>Long Answer</h2>
  <p>The default <code>Service</code> type is <code>ClusterIP</code>, which only exposes the Service <strong><em>inside</em></strong> the cluster via a cluster-internal IP.</p>
  <p>To expose a <code>Service</code> <strong><em>outside</em></strong> the <code>minikube</code> cluster, there are a few options provided by Kubernetes.</p>
  <p>First, <a href="https://v1-20.docs.kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">we can look at <code>ServiceTypes</code></a>:</p>
  <ol>
  <li><strong><code>NodePort</code></strong> - Exposes a service on each cluster node at a specific port. Cluster networking routes the packets to the target <code>Service</code>'s <code>Pod</code>s.  This is the most basic way to expose a service externally.  It has existed for many years in Kubernetes.  <strong><em>This is probably the simplest way to expose a <code>Service</code></em> for testing in <code>minikube</code></strong>.  However, if you want to do anything fancy such as TLS/SSL termination, load balacning, virtual hosts, or routing rules... use an <code>Ingress</code>.</li>
  <li><code>LoadBalancer</code> - Exposes a service using a cloud-native Load Balancer.  This is for production clusters, and probably not useful for your <code>minikube</code> use case.  It usually creates a dynamic <code>NodePort</code> for use as the cloud Load Balancer's backend target port.</li>
  <li><code>ExternalName</code> - A way to use externally hosted services through a cluster DNS <code>CNAME</code> record. Maps the service name directly to an outside DNS address, and bypasses the need for endpoint records.  <em>Although it's good to know this exists, this is not very useful for your use case of exposing a cluster service externally</em>.</li>
  </ol>
  <p>Next, <a href="https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/" rel="nofollow noreferrer">we can look at port forwarding</a>:</p>
  <ul>
  <li><p><code>kubectl port-forward</code> command is a way to forward local traffic into a <code>Pod</code> within a Kubernetes cluster.  This feature is built into <code>kubectl</code>, and is mostly useful for local development and one-off tasks where you need to access a <code>Pod</code> directly.  This works with <code>Pod</code> names, <code>Deployment</code>s, and <code>ReplicaSets</code>.</p>
  <pre><code> kubectl port-forward podname-nnnnn-xxxx $LOCALPORT:$CONTAINERPORT
  </code></pre>
  </li>
  </ul>
  <p>This is probably the simplest method for accessing a <code>Pod</code> providing a <code>Service</code> quickly in order to test that it's working properly and accepting traffic.</p>
  <p>Finally, <a href="https://v1-20.docs.kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">we can look at <code>Ingress</code></a> and <a href="https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/" rel="nofollow noreferrer">Ingress Controllers</a> (default: <code>nginx</code>):</p>
  <ul>
  <li><code>Ingress</code>: An Ingress may be configured to give Services externally-reachable URLs, load balance traffic, terminate SSL / TLS, and offer name-based virtual hosting.  An <code>Ingress Controller</code> usually runs inside a <code>Pod</code> in the <code>kube-system</code> namespace and provides these features which are configurable through the <code>Ingress</code> Kubernetes API object.</li>
  </ul>
  <p>For <code>minikube</code>, you need to enable it as an addon:</p>
  <pre><code>minikube addons enable ingress
  </code></pre>
  <p>Follow the <a href="https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/" rel="nofollow noreferrer"><code>minikube</code> <code>Ingress</code> tutorial here</a> to get started using <code>ingress-nginx</code>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-11-02T09:12:52.540Z
Answers: I really appreciate your answer but can ingress-nginx help me to expose the service outside my machine for all devices connected to the network?
Answers: Ali Ourag
Answers: CC BY-SA 4.0
Answers: 2021-11-03T11:04:20.577Z
Answers: Specifically for `minikube` LAN access, there is one more networking layer to be aware of:  LAN --> Host --> minikube VM.  For this, you're probably using VirtualBox and can enable the port forwarding NAT feature to route the LAN traffic to the `minikube` VM.  (See edited answer above for commands)
Answers: TrinitronX
Answers: CC BY-SA 4.0
Answers: 2021-11-01T23:35:28.643Z
Answers: 2021-11-03T11:11:55.943Z
Answers: 2021-11-03T11:11:55.943Z
Answers: TrinitronX
Answers: <p>One easy way is to have proxy for outside your machine, I can not comment due to low reputation. You can use apache or any other like HA, nginx</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-11-01T10:52:31.247Z
Answers: sorry, brother for the late reply but can you give me more details on how to setup a reverse proxy using Nginx ? like should I have to install it on my windows machine or in minikube ?
Answers: Ali Ourag
Answers: CC BY-SA 4.0
Answers: 2021-11-01T19:54:42.943Z
Answers: on your Windows machine
Answers: Siddique Ahmad
Answers: CC BY-SA 4.0
Answers: 2021-11-02T09:16:01.343Z
Answers: i alrady installed nginx and used this  =====>                                                                 ` server {
          listen       80;
          server_name  localhost;
          location / {
                  proxy_pass http://localhost:3000/api/;
                  }
          error_page   500 502 503 504  /50x.html;
          location = /50x.html {
              root   html;
          }`     in my nginx.conf but it not redirect !!
Answers: Ali Ourag
Answers: CC BY-SA 4.0
Answers: 2021-10-30T11:44:49.937Z
Answers: 2021-10-30T11:44:49.937Z
Answers: Siddique Ahmad
Answers: <p>It heavily depends on minikube's start <code>--driver</code> option. I was able to handle it with <code>--driver=none</code>, which requested the <code>cri-docker.service</code> to be running. Summarizing:
  Preinstall cri-docker service: e.g. Ubuntu 20:</p>
  <pre><code>sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
  echo &quot;deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main&quot; | sudo tee /etc/apt/sources.list.d/kubernetes.list
  
  
  sudo apt-get update -y
  sudo apt-get install -y kubelet kubeadm kubectl
  sudo apt-mark hold kubelet kubeadm kubectl
  
  
  wget https://github.com/Mirantis/cri-dockerd/releases/download/v${VER}/cri-dockerd-${VER}.amd64.tgz
  tar xvf cri-dockerd-${VER}.amd64.tgz
  sudo mv cri-dockerd/cri-dockerd /usr/local/bin/
  tar xvf cri-dockerd-${VER}.amd64.tgz
  sudo mv cri-dockerd/cri-dockerd /usr/bin/
  wget https://raw.githubusercontent.com/Mirantis/cri-dockerd/master/packaging/systemd/cri-docker.service
  wget https://raw.githubusercontent.com/Mirantis/cri-dockerd/master/packaging/systemd/cri-docker.socket
  sudo mv cri-docker.socket cri-docker.service /etc/systemd/system/
  sudo sed -i -e 's,/usr/bin/cri-dockerd,/usr/local/bin/cri-dockerd,' /etc/systemd/system/cri-docker.service
  sudo systemctl daemon-reload
  sudo systemctl enable cri-docker.service
  sudo systemctl start cri-docker.socket
  </code></pre>
  <ol start="0">
  <li>run your minikube, e.g. <code>minikube start --driver=none --container-runtime=docker</code>
  , also check <code>minikube ip</code></li>
  <li>deploy app - run your service</li>
  <li>expose the service</li>
  <li>run ingress ( as suggestet above - <code>minikube addons enable ingress</code> )</li>
  <li>you should now be able to access it externally.</li>
  </ol>
  <p>PS Many thanks to the post creator: <a href="https://stackoverflow.com/a/60726849/6571708">https://stackoverflow.com/a/60726849/6571708</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2022-07-28T08:53:46.140Z
Answers: 2022-07-28T08:53:46.140Z
Answers: Dr. Alexander
Body: <p>I've created a service inside minikube (expressjs API) running on my local machine, so when I launch the service using   <code>minikube service wedeliverapi --url</code>   i can access it from my browser with   <code>localhost:port/api</code></p>
  <p>minikube IP : 192.168.49.2</p>
  <p><a href="https://i.sstatic.net/78FFE.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/78FFE.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.sstatic.net/OMQ5e.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/OMQ5e.png" alt="enter image description here" /></a></p>
  <p>But I also want to access that service from another device so I can use my API from a flutter mobile application, how can I achieve this goal?</p>
  
Comments: CC BY-SA 4.0
Comments: 2021-10-30T07:48:52.453Z
Comments: Could you please replace the screenshots with text?
Comments: Bruce Becker
Comments: CC BY-SA 4.0
Comments: 2021-11-01T12:06:24.767Z
Comments: which one? minikube service wedeliverapi --url output ?
Comments: Ali Ourag
Tags: <docker><kubernetes><kubectl><minikube>
Title: How to expose a service ( Experssjs Api ) deployed on minikube ( 192.168.49.2 ) to be able to access it from another device in the same network?
UserDisplayName: Ali Ourag
ThreadText: # How to expose a service ( Experssjs Api ) deployed on minikube ( 192.168.49.2 ) to be able to access it from another device in the same network?
  
  (Asked by: username_0 on 2021-10-29)
  
  I've created a service inside minikube (expressjs API) running on my local machine, so when I launch the service using `minikube service wedeliverapi --url` i can access it from my browser with `localhost:port/api`
  
  minikube IP : 192.168.49.2
  
  [![enter image description here](https://i.sstatic.net/78FFE.png)](https://i.sstatic.net/78FFE.png)
  
  [![enter image description here](https://i.sstatic.net/OMQ5e.png)](https://i.sstatic.net/OMQ5e.png)
  
  But I also want to access that service from another device so I can use my API from a flutter mobile application, how can I achieve this goal?
  
  **Tags:** docker, kubernetes, kubectl, minikube
  
  > **Comments:**
  > **username_1**: Could you please replace the screenshots with text?  
  > **username_0**: which one? minikube service wedeliverapi --url output ?  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2021-11-01. Score: 0 | Accepted answer
  
  # **TLDR;**
  
  *Look at **`NodePort`** or **`Ingress`** to expose a Kubernetes `minikube` service externally*.
  
  For `minikube` specifically, there is one last networking layer between the `minikube` VM and the host. You need to enable port forwarding from the Host into the VM. To forward [the entire default `minikube` `NodePort` range](https://minikube.sigs.k8s.io/docs/handbook/accessing/#increasing-the-nodeport-range):
  
  ```
  for port in {30000..32767}; do VBoxManage controlvm minikube natpf1 "NodePort$port,tcp,,$port,,$port"; done
  
  ```
  
  To disable the port forwarding when you're done:
  
  ```
  for port in {30000..32767}; do VBoxManage controlvm minikube natpf1 delete "NodePort$port"; done
  
  ```
  
  ## Long Answer
  
  The default `Service` type is `ClusterIP`, which only exposes the Service ***inside*** the cluster via a cluster-internal IP.
  
  To expose a `Service` ***outside*** the `minikube` cluster, there are a few options provided by Kubernetes.
  
  First, [we can look at `ServiceTypes`](https://v1-20.docs.kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types):
  
  1. **`NodePort`** - Exposes a service on each cluster node at a specific port. Cluster networking routes the packets to the target `Service`'s `Pod`s. This is the most basic way to expose a service externally. It has existed for many years in Kubernetes. ***This is probably the simplest way to expose a `Service`* for testing in `minikube`**. However, if you want to do anything fancy such as TLS/SSL termination, load balacning, virtual hosts, or routing rules... use an `Ingress`.
  2. `LoadBalancer` - Exposes a service using a cloud-native Load Balancer. This is for production clusters, and probably not useful for your `minikube` use case. It usually creates a dynamic `NodePort` for use as the cloud Load Balancer's backend target port.
  3. `ExternalName` - A way to use externally hosted services through a cluster DNS `CNAME` record. Maps the service name directly to an outside DNS address, and bypasses the need for endpoint records. *Although it's good to know this exists, this is not very useful for your use case of exposing a cluster service externally*.
  
  Next, [we can look at port forwarding](https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/):
  
  * `kubectl port-forward` command is a way to forward local traffic into a `Pod` within a Kubernetes cluster. This feature is built into `kubectl`, and is mostly useful for local development and one-off tasks where you need to access a `Pod` directly. This works with `Pod` names, `Deployment`s, and `ReplicaSets`.
  
    ```
     kubectl port-forward podname-nnnnn-xxxx $LOCALPORT:$CONTAINERPORT
  
    ```
  
  This is probably the simplest method for accessing a `Pod` providing a `Service` quickly in order to test that it's working properly and accepting traffic.
  
  Finally, [we can look at `Ingress`](https://v1-20.docs.kubernetes.io/docs/concepts/services-networking/ingress/) and [Ingress Controllers](https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/) (default: `nginx`):
  
  * `Ingress`: An Ingress may be configured to give Services externally-reachable URLs, load balance traffic, terminate SSL / TLS, and offer name-based virtual hosting. An `Ingress Controller` usually runs inside a `Pod` in the `kube-system` namespace and provides these features which are configurable through the `Ingress` Kubernetes API object.
  
  For `minikube`, you need to enable it as an addon:
  
  ```
  minikube addons enable ingress
  
  ```
  
  Follow the [`minikube` `Ingress` tutorial here](https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/) to get started using `ingress-nginx`.
  
  > **Comments:**
  > **username_0**: I really appreciate your answer but can ingress-nginx help me to expose the service outside my machine for all devices connected to the network?  
  > **username_2**: Specifically for `minikube` LAN access, there is one more networking layer to be aware of:  LAN --> Host --> minikube VM.  For this, you're probably using VirtualBox and can enable the port forwarding NAT feature to route the LAN traffic to the `minikube` VM.  (See edited answer above for commands)  
  
  ---
  
  ### Answer by username_3 on 2021-10-30. Score: 0
  
  One easy way is to have proxy for outside your machine, I can not comment due to low reputation. You can use apache or any other like HA, nginx
  
  > **Comments:**
  > **username_0**: sorry, brother for the late reply but can you give me more details on how to setup a reverse proxy using Nginx ? like should I have to install it on my windows machine or in minikube ?  
  > **username_3**: on your Windows machine  
  > **username_0**: i alrady installed nginx and used this  =====>                                                                 ` server {         listen       80;         server_name  localhost;         location / {                 proxy_pass http://localhost:3000/api/;                 }         error_page   500 502 503 504  /50x.html;         location = /50x.html {             root   html;         }`     in my nginx.conf but it not redirect !!  
  
  ---
  
  ### Answer by username_4 on 2022-07-28. Score: 0
  
  It heavily depends on minikube's start `--driver` option. I was able to handle it with `--driver=none`, which requested the `cri-docker.service` to be running. Summarizing:
  Preinstall cri-docker service: e.g. Ubuntu 20:
  
  ```
  sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
  echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
  
  sudo apt-get update -y
  sudo apt-get install -y kubelet kubeadm kubectl
  sudo apt-mark hold kubelet kubeadm kubectl
  
  wget https://github.com/Mirantis/cri-dockerd/releases/download/v${VER}/cri-dockerd-${VER}.amd64.tgz
  tar xvf cri-dockerd-${VER}.amd64.tgz
  sudo mv cri-dockerd/cri-dockerd /usr/local/bin/
  tar xvf cri-dockerd-${VER}.amd64.tgz
  sudo mv cri-dockerd/cri-dockerd /usr/bin/
  wget https://raw.githubusercontent.com/Mirantis/cri-dockerd/master/packaging/systemd/cri-docker.service
  wget https://raw.githubusercontent.com/Mirantis/cri-dockerd/master/packaging/systemd/cri-docker.socket
  sudo mv cri-docker.socket cri-docker.service /etc/systemd/system/
  sudo sed -i -e 's,/usr/bin/cri-dockerd,/usr/local/bin/cri-dockerd,' /etc/systemd/system/cri-docker.service
  sudo systemctl daemon-reload
  sudo systemctl enable cri-docker.service
  sudo systemctl start cri-docker.socket
  
  ```
  
  0. run your minikube, e.g. `minikube start --driver=none --container-runtime=docker`
     , also check `minikube ip`
  1. deploy app - run your service
  2. expose the service
  3. run ingress ( as suggestet above - `minikube addons enable ingress` )
  4. you should now be able to access it externally.
  
  PS Many thanks to the post creator: <https://stackoverflow.com/a/60726849/6571708>
  
  
  ---
  
  