<p>I am trying to run an application locally on k8s but I am not able to reach it.</p>
<p>here is my deloyment:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: listings
  labels:
    app: listings
spec:
  replicas: 2
  selector:
    matchLabels:
      app: listings
  template:
    metadata:
      labels:
        app: listings
    spec:
      containers:
        - image: mydockerhub/listings:latest
          name: listings
          envFrom:
            - secretRef:
                name: listings-secret
            - configMapRef:
                name: listings-config
          ports:
            - containerPort: 8000
              name: django-port

</code></pre>
<p>and it is my service</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: listings
  labels:
    app: listings
spec:
  type: NodePort
  selector:
    app: listings
  ports:
    - name: http
      port: 8000
      targetPort: 8000
      nodePort: 30036
      protocol: TCP
</code></pre>
<p>At this stage, I don't want to use other methods like ingress or ClusterIP, or load balancer. I want to make nodePort work because I am trying to learn.</p>
<p>When I run <code>kubectl get svc -o wide</code> I see</p>
<pre><code>NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE   SELECTOR
listings     NodePort    10.107.77.231   &lt;none&gt;        8000:30036/TCP   28s   app=listings
</code></pre>
<p>When I run <code>kubectl get node -o wide</code> I see</p>
<pre><code>NAME       STATUS   ROLES                  AGE   VERSION   INTERNAL-IP    EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION                      CONTAINER-RUNTIME
minikube   Ready    control-plane,master   85d   v1.23.3   192.168.49.2   &lt;none&gt;        Ubuntu 20.04.2 LTS   5.10.16.3-microsoft-standard-WSL2   docker://20.10.12
</code></pre>
<p>and when I run <code>minikube ip</code> it shows <code>192.168.49.2</code></p>
<p>I try to open <code>http://192.168.49.2:30036/health</code> it is not opening <code>This site can’t be reached</code></p>
<p>How should expose my application externally?</p>
<p>note that I have created the required configmap and secret objects. also note that this is a simple django restful application that if you hit the /health endpoint, it returns success. and that's it. so there is no problem with the application</p>

Amin Ba
<p>That is because your local and minikube are not in the same network segment,
you must do something more to access minikube service on windows.</p>
<p>First</p>
<pre><code>$ minikube service list
</code></pre>
<p>That will show your service detail which include name, url, nodePort, targetPort.</p>
<p>Then</p>
<pre><code>$ minikube service --url listings
</code></pre>
<p>It will open a port to listen on your windows machine that can forward the traffic to minikube node port.</p>
<p>Or you can use command <code>kubectl port-forward</code> to expose service on host port, like:</p>
<pre><code>kubectl port-forward --address 0.0.0.0 -n default service/listings 30036:8000
</code></pre>
<p>Then try with <code>http://localhost:30036/health</code></p>
