title: Accessing kubernetes External IP ( LoadBalancer ) from windows 10 when the cluster running under WSL 2
body: <p>I have nifi container (pods) configured on Kubernetes( Rancher k3d cluster ) on top of WSL 2 Windows 10 ( not with docker desktop ).</p>
  <p><a href="https://yannalbou.medium.com/k3d-k3s-k8s-perfect-match-for-dev-and-testing-896c8953acc0" rel="nofollow noreferrer">https://yannalbou.medium.com/k3d-k3s-k8s-perfect-match-for-dev-and-testing-896c8953acc0</a></p>
  <p>Deployed the nifi and below is the service yaml</p>
  <pre><code>$ cat nifi-service.yaml
  apiVersion: v1
  kind: Service
  metadata:
    annotations:
      kompose.cmd: kompose convert
      kompose.version: 1.21.0 (992df58d8)
    creationTimestamp: null
    labels:
      io.kompose.service: nifi
    name: nifi
  spec:
    type: LoadBalancer
    ports:
    - name: &quot;8080&quot;
      port: 8080
      targetPort: 8080
    selector:
      io.kompose.service: nifi
  status:
    loadBalancer: {}
  
  
  
  $ kubectl get service
  NAME         TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
  kubernetes   ClusterIP      10.43.0.1       &lt;none&gt;        443/TCP          14m
  nifi         LoadBalancer   10.43.240.177   172.24.0.2    8080:31123/TCP   12m
  
  
  
  $ kubectl get pods
  NAME                    READY   STATUS    RESTARTS   AGE
  svclb-nifi-48sm9        1/1     Running   0          12m
  nifi-6c9856f676-tjzfk   1/1     Running   0          13m
  
  
  $ kubectl describe pods nifi-6c9856f676-tjzfk
  Name:         nifi-6c9856f676-tjzfk
  Namespace:    default
  Priority:     0
  Node:         k3d-k3s-default-server-0/172.24.0.2
  Start Time:   Wed, 09 Dec 2020 20:44:36 -0800
  Labels:       io.kompose.network/odfe-net=true
                io.kompose.service=nifi
                pod-template-hash=6c9856f676
  Annotations:  kompose.cmd: kompose convert
                kompose.version: 1.21.0 (992df58d8)
  Status:       Running
  IP:           10.42.0.9
  IPs:
    IP:           10.42.0.9
  Controlled By:  ReplicaSet/nifi-6c9856f676
  Containers:
    nifi:
      Container ID:   containerd://a706883ccd30cfe2bd22cd39241bf430e66b4117999554a2316ab47557a28290
      Image:          apache/nifi:latest
      Image ID:       docker.io/apache/nifi@sha256:bf7576ab7ad0bfe38c86be5baa47229d1644287984034dc9d5ff4801c5827115
      Port:           8080/TCP
      Host Port:      0/TCP
      State:          Running
        Started:      Wed, 09 Dec 2020 20:47:03 -0800
      Ready:          True
      Restart Count:  0
      Environment:
        NIFI_BASE_DIR:                    /opt/nifi
        NIFI_CLUSTER_IS_NODE:             true
        NIFI_CLUSTER_NODE_PROTOCOL_PORT:  8082
        NIFI_ELECTION_MAX_WAIT:           1 min
        NIFI_HOME:                        /opt/nifi/nifi-current
        NIFI_LOG_DIR:                     /opt/nifi/nifi-current/logs
        NIFI_WEB_HTTP_HOST:               nifi
        NIFI_WEB_HTTP_PORT:               8080
        NIFI_ZK_CONNECT_STRING:           zookeeper:2181
      Mounts:
        /var/run/secrets/kubernetes.io/serviceaccount from default-token-x95qx (ro)
  Conditions:
    Type              Status
    Initialized       True
    Ready             True
    ContainersReady   True
    PodScheduled      True
  Volumes:
    default-token-x95qx:
      Type:        Secret (a volume populated by a Secret)
      SecretName:  default-token-x95qx
      Optional:    false
  QoS Class:       BestEffort
  Node-Selectors:  &lt;none&gt;
  Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                   node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
  Events:
    Type    Reason     Age   From               Message
    ----    ------     ----  ----               -------
    Normal  Scheduled  13m   default-scheduler  Successfully assigned default/nifi-6c9856f676-tjzfk to k3d-k3s-default-server-0
    Normal  Pulling    13m   kubelet            Pulling image &quot;apache/nifi:latest&quot;
    Normal  Pulled     10m   kubelet            Successfully pulled image &quot;apache/nifi:latest&quot; in 2m23.415948s
    Normal  Created    10m   kubelet            Created container nifi
    Normal  Started    10m   kubelet            Started container nifi
  $
  
  
  $ curl -XGET http://172.23.0.2:8080
  
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
      &lt;link rel=&quot;shortcut icon&quot; href=&quot;/nifi/images/nifi16.ico&quot;/&gt;
      &lt;title&gt;NiFi&lt;/title&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;/nifi/assets/reset.css/reset.css&quot; type=&quot;text/css&quot;/&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;/nifi/css/common-ui.css&quot; type=&quot;text/css&quot;/&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;/nifi/fonts/flowfont/flowfont.css&quot; type=&quot;text/css&quot;/&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;/nifi/assets/font-awesome/css/font-awesome.min.css&quot; type=&quot;text/css&quot;/&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;/nifi/css/message-pane.css&quot; type=&quot;text/css&quot;/&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;/nifi/css/message-page.css&quot; type=&quot;text/css&quot;/&gt;
      &lt;meta http-equiv=&quot;Refresh&quot; content=&quot;5; url=/nifi/&quot;&gt;
  &lt;/head&gt;
  
  &lt;body class=&quot;message-pane&quot;&gt;
  &lt;div class=&quot;message-pane-message-box&quot;&gt;
      &lt;p class=&quot;message-pane-title&quot;&gt;
          Did you mean: &lt;a href=&quot;/nifi/&quot;&gt;/nifi&lt;/a&gt;
      &lt;/p&gt;
      &lt;p class=&quot;message-pane-content&quot;&gt;You may have mistyped... but we'll try to redirect you in 5 seconds.&lt;/p&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p><strong>ifconfig: WSL</strong></p>
  <pre><code>eth0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
          inet 172.22.187.174  netmask 255.255.240.0  broadcast 172.22.191.255
          inet6 fe80::215:5dff:fe24:b429  prefixlen 64  scopeid 0x20&lt;link&gt;
          ether 00:15:5d:24:b4:29  txqueuelen 1000  (Ethernet)
          RX packets 1316772  bytes 1987244606 (1.9 GB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 245617  bytes 15676892 (15.6 MB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
      
      From powershell ipconfig output for WSL
  
     Connection-specific DNS Suffix  . :
     Link-local IPv6 Address . . . . . : fe80::f51e:6d1c:578:2be4%48
     IPv4 Address. . . . . . . . . . . : 172.22.176.1
     Subnet Mask . . . . . . . . . . . : 255.255.240.0
     Default Gateway . . . . . . . . . :
  
  PS C:\WINDOWS\system32&gt; ping 172.24.0.2  &lt;-- How to reach this IP from Windows???
  
  Pinging 172.24.0.2 with 32 bytes of data:
  Request timed out.
  
  Ping statistics for 172.24.0.2:
      Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
  </code></pre>
  <p>I am not good at networking. Wondering if there is any way I can open Kubernetes external IP's (LoadBalancer) to be available in windows? So that these IP's (Example: 172.24.0.2 in this case ) will be reachable from windows and I can access this service as-is? forwarding the port will not work as the service ports (8080 in this case) are not with WSL IP. My end goal is to access nifi ( or any other service ) like this from windows browser <a href="http://172.24.0.2:8080/nifi" rel="nofollow noreferrer">http://172.24.0.2:8080/nifi</a>.</p>
  <p>The below solution also not worked for me as here the service (8080) is running with Cluster load balancer-
  <a href="https://github.com/microsoft/WSL/issues/4150" rel="nofollow noreferrer">https://github.com/microsoft/WSL/issues/4150</a></p>
  <p>Stuck here for a few days. Any help/direction will be great. New in Kubernetes. May be missing fundamental things.</p>
  <p>Trying to do kubectl port forward which supposed to work without any issue as per documentation but getting the below error -</p>
  <pre><code>$ kubectl get all --all-namespaces
  NAMESPACE     NAME                                         READY   STATUS      RESTARTS   AGE
  kube-system   pod/helm-install-traefik-fb2kh               0/1     Completed   0          24h
  kube-system   pod/traefik-5dd496474-2hfmq                  1/1     Running     0          24h
  kube-system   pod/svclb-traefik-bjf9p                      2/2     Running     0          24h
  default       pod/nifi-6c9856f676-tjzfk                    1/1     Running     0          24h
  default       pod/svclb-nifi-48sm9                         1/1     Running     0          24h
  kube-system   pod/coredns-66c464876b-v2qsj                 1/1     Running     0          24h
  kube-system   pod/metrics-server-7b4f8b595-gjm85           1/1     Running     0          24h
  kube-system   pod/local-path-provisioner-7ff9579c6-fflqt   1/1     Running     1          24h
  
  NAMESPACE     NAME                         TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
  default       service/kubernetes           ClusterIP      10.43.0.1       &lt;none&gt;        443/TCP                      24h
  kube-system   service/kube-dns             ClusterIP      10.43.0.10      &lt;none&gt;        53/UDP,53/TCP,9153/TCP       24h
  kube-system   service/metrics-server       ClusterIP      10.43.34.204    &lt;none&gt;        443/TCP                      24h
  kube-system   service/traefik-prometheus   ClusterIP      10.43.62.31     &lt;none&gt;        9100/TCP                     24h
  kube-system   service/traefik              LoadBalancer   10.43.185.22    172.24.0.2    80:31486/TCP,443:31651/TCP   24h
  default       service/nifi                 LoadBalancer   10.43.240.177   172.24.0.2    8080:31123/TCP               24h
  
  NAMESPACE     NAME                           DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
  kube-system   daemonset.apps/svclb-traefik   1         1         1       1            1           &lt;none&gt;          24h
  default       daemonset.apps/svclb-nifi      1         1         1       1            1           &lt;none&gt;          24h
  
  NAMESPACE     NAME                                     READY   UP-TO-DATE   AVAILABLE   AGE
  kube-system   deployment.apps/traefik                  1/1     1            1           24h
  default       deployment.apps/nifi                     1/1     1            1           24h
  kube-system   deployment.apps/coredns                  1/1     1            1           24h
  kube-system   deployment.apps/metrics-server           1/1     1            1           24h
  kube-system   deployment.apps/local-path-provisioner   1/1     1            1           24h
  
  NAMESPACE     NAME                                               DESIRED   CURRENT   READY   AGE
  kube-system   replicaset.apps/traefik-5dd496474                  1         1         1       24h
  default       replicaset.apps/nifi-6c9856f676                    1         1         1       24h
  kube-system   replicaset.apps/coredns-66c464876b                 1         1         1       24h
  kube-system   replicaset.apps/metrics-server-7b4f8b595           1         1         1       24h
  kube-system   replicaset.apps/local-path-provisioner-7ff9579c6   1         1         1       24h
  
  NAMESPACE     NAME                             COMPLETIONS   DURATION   AGE
  
  
  $&gt; kubectl -n default port-forward --address 0.0.0.0 service/nifi 5000:8080
  Forwarding from 0.0.0.0:5000 -&gt; 8080
  </code></pre>
  <p>When trying localhost:5000 from windows browser getting this -</p>
  <pre><code>E1210 21:02:13.049280   32370 portforward.go:400] an error occurred forwarding 5000 -&gt; 8080: error forwarding port 8080 to pod b438a055ef4a16ade7ff42e6c26e80122ad5f1b3e2400b4f4991c7c79f89600e, uid : failed to execute portforward in network namespace &quot;/var/run/netns/cni-74542715-faae-d069-139c-cf2ed3a87534&quot;: failed to dial 8080: dial tcp4 127.0.0.1:8080: connect: connection refused
      
  </code></pre>