<p>I am setting up kubernetes on my Laptop (Windows 10 OS) to work on the Containers and it's Orchestration. <strong>I have created Minikube VM using the below command and it got succeeded.</strong></p>

<pre><code>minikube start --vm-driver hyperv --hyperv-virtual-switch "Primary Virtual Switch"
</code></pre>

<p>I am able to Launch Kubernetes and <strong>able to launch the Minikube dashboard as well</strong></p>

<p>I started the Kubernetes cluster and deployed nginx app into Cluster. Below are the commands.</p>

<pre><code>kubectl run hello-nginx --image=nginx --port=8020
kubectl expose deployment hello-nginx --type=NodePort --port=8020 --target-port=8020
</code></pre>

<p>I am able to view PODs and Services using the below commands.</p>

<pre><code>kubectl get pods
kubectl get services
</code></pre>

<p><strong>it works perfect up to here</strong>. I am able to view deployment, PODs and Service information in the Minikube dashboard.</p>

<p>When i run the below command to launch the application in the browser, browser is throwing a message as "Resource Not Found" but I am able to view POD and Service information in the MiniKube Dashboard.</p>

<pre><code>minikube service hello-nginx
</code></pre>

<p>URL: <a href="http://192.168.43.20:32087/" rel="nofollow noreferrer">http://192.168.43.20:32087/</a></p>

<p>getting exception in a browser</p>

<pre><code>This website could not be found.
Error Code: INET_E_RESOURCE_NOT_FOUND
</code></pre>

<p>Below given the deployment YAML file,</p>

<pre><code>{
  "kind": "Deployment",
  "apiVersion": "extensions/v1beta1",
  "metadata": {
    "name": "hello-nginx",
    "namespace": "default",
    "selfLink": "/apis/extensions/v1beta1/namespaces/default/deployments/hello-nginx",
    "uid": "5629038e-93e5-11e9-ad2e-00155d162e0e",
    "resourceVersion": "49313",
    "generation": 1,
    "creationTimestamp": "2019-06-21T05:28:01Z",
    "labels": {
      "run": "hello-nginx"
    },
    "annotations": {
      "deployment.kubernetes.io/revision": "1"
    }
  },
  "spec": {
    "replicas": 1,
    "selector": {
      "matchLabels": {
        "run": "hello-nginx"
      }
    },
    "template": {
      "metadata": {
        "creationTimestamp": null,
        "labels": {
          "run": "hello-nginx"
        }
      },
      "spec": {
        "containers": [
          {
            "name": "hello-nginx",
            "image": "nginx",
            "ports": [
              {
                "containerPort": 8020,
                "protocol": "TCP"
              }
            ],
            "resources": {},
            "terminationMessagePath": "/dev/termination-log",
            "terminationMessagePolicy": "File",
            "imagePullPolicy": "Always"
          }
        ],
        "restartPolicy": "Always",
        "terminationGracePeriodSeconds": 30,
        "dnsPolicy": "ClusterFirst",
        "securityContext": {},
        "schedulerName": "default-scheduler"
      }
    },
    "strategy": {
      "type": "RollingUpdate",
      "rollingUpdate": {
        "maxUnavailable": 1,
        "maxSurge": 1
      }
    },
    "revisionHistoryLimit": 2147483647,
    "progressDeadlineSeconds": 2147483647
  },
  "status": {
    "observedGeneration": 1,
    "replicas": 1,
    "updatedReplicas": 1,
    "readyReplicas": 1,
    "availableReplicas": 1,
    "conditions": [
      {
        "type": "Available",
        "status": "True",
        "lastUpdateTime": "2019-06-21T05:28:01Z",
        "lastTransitionTime": "2019-06-21T05:28:01Z",
        "reason": "MinimumReplicasAvailable",
        "message": "Deployment has minimum availability."
      }
    ]
  }
}
</code></pre>

<p>Below given the replica set YAML file info,</p>

<pre><code>{
  "kind": "ReplicaSet",
  "apiVersion": "extensions/v1beta1",
  "metadata": {
    "name": "hello-nginx-76696c698f",
    "namespace": "default",
    "selfLink": "/apis/extensions/v1beta1/namespaces/default/replicasets/hello-nginx-76696c698f",
    "uid": "562be1e8-93e5-11e9-ad2e-00155d162e0e",
    "resourceVersion": "49310",
    "generation": 3,
    "creationTimestamp": "2019-06-21T05:28:01Z",
    "labels": {
      "pod-template-hash": "76696c698f",
      "run": "hello-nginx"
    },
    "annotations": {
      "deployment.kubernetes.io/desired-replicas": "1",
      "deployment.kubernetes.io/max-replicas": "2",
      "deployment.kubernetes.io/revision": "1"
    },
    "ownerReferences": [
      {
        "apiVersion": "apps/v1",
        "kind": "Deployment",
        "name": "hello-nginx",
        "uid": "5629038e-93e5-11e9-ad2e-00155d162e0e",
        "controller": true,
        "blockOwnerDeletion": true
      }
    ]
  },
  "spec": {
    "replicas": 1,
    "selector": {
      "matchLabels": {
        "pod-template-hash": "76696c698f",
        "run": "hello-nginx"
      }
    },
    "template": {
      "metadata": {
        "creationTimestamp": null,
        "labels": {
          "pod-template-hash": "76696c698f",
          "run": "hello-nginx"
        }
      },
      "spec": {
        "containers": [
          {
            "name": "hello-nginx",
            "image": "nginx",
            "ports": [
              {
                "containerPort": 8020,
                "protocol": "TCP"
              }
            ],
            "resources": {},
            "terminationMessagePath": "/dev/termination-log",
            "terminationMessagePolicy": "File",
            "imagePullPolicy": "Always"
          }
        ],
        "restartPolicy": "Always",
        "terminationGracePeriodSeconds": 30,
        "dnsPolicy": "ClusterFirst",
        "securityContext": {},
        "schedulerName": "default-scheduler"
      }
    }
  },
  "status": {
    "replicas": 1,
    "fullyLabeledReplicas": 1,
    "readyReplicas": 1,
    "availableReplicas": 1,
    "observedGeneration": 3
  }
}
</code></pre>

<p>Now I am trying out the Port Forwarding option to route the request to POD, but it is not working.</p>

<pre><code>kubectl port-forward deployment/hello-nginx 8020:8020
</code></pre>

<p>I am getting the below exception when i try to access the URL "<a href="http://127.0.0.1:8020" rel="nofollow noreferrer">http://127.0.0.1:8020</a>"</p>

<pre><code>Handling connection for 8020
E0622 01:07:06.306320   18888 portforward.go:331] an error occurred forwarding 8020 -&gt; 8020: error forwarding port 8020 to pod c54d6faaa545992dce02f58490a26154134843eb7426a51e78df2cda172b514c, uid : exit status 1: 2019/06/21 08:01:18 socat[4535] E connect(5, AF=2 127.0.0.1:8020, 16): Connection refused
</code></pre>

<p>I have read many articles on this but couldn't found the root cause for this issue. Am i missing anything important here? </p>

<p>Thanks for your help in Advance.</p>

rajswastik
<p>Your issue is actually unrelated to Minikube or port forwarding. You expose the port <code>8020</code>, however the application <code>hello-nginx</code> uses <code>80</code>. So you should use <code>80</code> everywhere instead of <code>8020</code>. For example:</p>

<pre><code>kubectl run hello-nginx --image=nginx --port=80
</code></pre>

<hr>

<p>Saying that, using Minikube is not the best option for Windows. Much better is to use <a href="https://www.docker.com/products/docker-desktop" rel="nofollow noreferrer">Docker Desktop</a>, then everything you run on Kubernetes is available on your <code>localhost</code>.</p>
