问题:
我刚安装完k8s, 1个master 两个node
192.168.0.3 k8s-master
192.168.0.6 k8s-node0
192.168.0.44 k8s-node1
然后用下面两句命令安装了1个nginx
kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --port=80 --type=NodePort
nginx 这个pod 安装在了k8s-node1 中
但是我只能在k8s 上用k8s-node1 来访问这个nginx 服务, 例如
root@k8s-master:~/k8s-install# curl http://192.168.0.44:30763
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
但是用k8s-master 和 k8s-node0的ip都是不能访问的
curl http://192.168.0.3:30763 --timeout
curl http://192.168.0.6:30763 --timeout
原因:
K8S 的 NodePort需要UDP 流量
而我的nodes其实都是GCP上的VM, 在防火墙里只开放了tcp的端口
解决方法:
在对应的vpc network里开放udp 端口
问题解决