我已经使用WSL(Ubuntu 20.x(和Docker Desktop使用下面的博客设置了一个kubernetes集群
https://kubernetes.io/blog/2020/05/21/wsl-docker-kubernetes-on-the-windows-desktop/
我使用kinD实用程序创建了一个3节点集群
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
我还创建了一个nginx部署和一个带有Node端口的服务。如何从Windows浏览器访问该端口?我无法使用访问它http://127.0.0.1:nodeport
$kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
my-cluster-control-plane Ready master 46m v1.17.0 172.17.0.4 <none> Ubuntu 19.10 4.19.128-microsoft-standard containerd://1.3.2
my-cluster-worker Ready <none> 45m v1.17.0 172.17.0.2 <none> Ubuntu 19.10 4.19.128-microsoft-standard containerd://1.3.2
my-cluster-worker2 Ready <none> 45m v1.17.0 172.17.0.3 <none> Ubuntu 19.10 4.19.128-microsoft-standard containerd://1.3.2
我无法从windows浏览器访问节点IP 172.17.0.x,如何访问nginx服务暴露的节点端口?
PS:kubectl端口转发当我直接在Pod上公开端口时工作。我可以使用直接访问nginx服务器http://127.0.0.1:forwardport从windows浏览器。但是,我想使用服务和节点端口,而不需要端口转发
我知道可能已经晚了,但我只是想分享一下,因为我自己一直在努力在WSL上直接安装microK8,没有Docker,没有KinD。为了解决这个问题,我在github上写了一个小的实用程序脚本,作为helm chart,它以WSL=>在localhost上可用。
当然,部署的服务必须是要公开的负载平衡器或节点端口类型。否则,如果未通过Ingress或kubectl端口forward公开,则它仅在集群内部。
你可以在这里阅读更多信息:
- https://devopsifyme.com/how-to-access-k8ss-node-ports-using-wsl/
- https://devopsifyme.com/how-to-run-microk8s-on-your-wsl-with-ubuntu-22-04/