# How to access microk8s cluster in WSL 2 from remote?

**URL:** <https://discuss.kubernetes.io/t/how-to-access-microk8s-cluster-in-wsl-2-from-remote/21493>\
**Category:** microk8s\
**Created:** [October 1, 2022, 2:05am UTC](https://discuss.kubernetes.io/t/how-to-access-microk8s-cluster-in-wsl-2-from-remote/21493 "2022-10-01T02:05:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidshen84](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/davidshen84/32/8072_2.png) [@davidshen84](https://discuss.kubernetes.io/u/davidshen84)\
**Post date:** [October 1, 2022, 2:05am UTC](https://discuss.kubernetes.io/t/how-to-access-microk8s-cluster-in-wsl-2-from-remote/21493/1 "2022-10-01T02:05:59Z")

</div>

Hi,

If I install microk8s on a _normal_ Linux machine, the k8s API server is bound to the host network, which is accessible from a remote machine.

But on WSL 2, the microk8s cluster lives in a virtual machine-like environment. So, machines that can reach my Windows box still cannot reach my microk8s cluster.

I find a way to port forwarding on my Windows box so remote requests can finally hit my microk8s cluster. But I got the following error when I tried to use `kubectl`.

```auto
Unable to connect to the server: x509: certificate is valid for 127.0.0.1, 10.152.183.1, 172.26.203.192, not 192.168.86.109
error getting namespace list
error: could not list namespaces (is the cluster accessible?)

```

The IP `192.168.86.109` is my Windows LAN IP.

Next, I just need to find a way to update the certificate, so it accepts my host IP. `minikube` has a `--apiserver-ips` option which allows you to add extra IPs to the certificate. But I could not find how to do this with microk8s.

So my question is it possible to add extra IPs to the apiserver certificate in microk8s?

Thanks

## Update

Solution at [ssl - How can I add an additional IP / hostname to my Kubernetes certificate? - DevOps Stack Exchange](https://devops.stackexchange.com/a/10834/37134)

---

<div class="post-metadata">

**Author:** ![balchua1](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/balchua1/32/5372_2.png) [@balchua1](https://discuss.kubernetes.io/u/balchua1)\
**Post date:** [October 1, 2022, 3:11am UTC](https://discuss.kubernetes.io/t/how-to-access-microk8s-cluster-in-wsl-2-from-remote/21493/2 "2022-10-01T03:11:55Z")

</div>

In the wsl instance go to the directory `/var/snap/microk8s/current/certs` and modify the file `csr.conf.template`

By adding the external IP into the list

Example:

```auto
[alt_names]
DNS.1 = kubernetes
DNS.2 = kubernetes.default
DNS.3 = kubernetes.default.svc
DNS.4 = kubernetes.default.svc.cluster
DNS.5 = kubernetes.default.svc.cluster.local
IP.1 = 127.0.0.1
IP.2 = 10.152.183.1
#MOREIPS
IP.99 = 192.168.86.109

```

It should automatically update the certificates.

Then you might want to get the new config `microk8s config > $KUBECONFIG`,  
Where `KUBECONFIG` is the location of your kubernetes config file.

---

<div class="post-metadata">

**Author:** ![Siganberg](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/siganberg/32/11257_2.png) [@Siganberg](https://discuss.kubernetes.io/u/Siganberg)\
**Post date:** [November 24, 2022, 7:36pm UTC](https://discuss.kubernetes.io/t/how-to-access-microk8s-cluster-in-wsl-2-from-remote/21493/3 "2022-11-24T19:36:46Z")

</div>

Can you share how you are able to forward remote request to WSL (microk8s)?
