
正文
Kubernetes集群开启Firewall
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
关于端口的官方说明:https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
k8s master需要开启以下端口
firewall-cmd --permanent --add-port=6443/tcp
firewall-cmd --permanent --add-port=2379-2380/tcp
firewall-cmd --permanent --add-port=10250/tcp
firewall-cmd --permanent --add-port=10251/tcp
firewall-cmd --permanent --add-port=10252/tcp
firewall-cmd --permanent --add-port=10255/tcp
firewall-cmd --permanent --add-port=8472/udp
firewall-cmd --permanent --add-port=443/udp
firewall-cmd --permanent --add-port=53/udp
firewall-cmd --permanent --add-port=53/tcp
firewall-cmd --permanent --add-port=9153/tcp
firewall-cmd --add-masquerade --permanent
# only if you want NodePorts exposed on control plane IP as well
firewall-cmd --permanent --add-port=30000-32767/tcp
systemctl restart firewalld
k8s node需要开启以下端口
firewall-cmd --permanent --add-port=10250/tcp
firewall-cmd --permanent --add-port=10255/tcp
firewall-cmd --permanent --add-port=8472/udp
firewall-cmd --permanent --add-port=443/udp
firewall-cmd --permanent --add-port=30000-32767/tcp
firewall-cmd --permanent --add-port=53/udp
firewall-cmd --permanent --add-port=53/tcp
firewall-cmd --permanent --add-port=9153/tcp
firewall-cmd --add-masquerade --permanent
systemctl restart firewalld
以下几点需要特别注意:
8472/udp为flannel的通信端口
443/tcp 为Kubernetes server端口
注意一点:一定要执行以下命令打开NAT,默认是关闭状态,这里踩过坑!!
firewall-cmd --add-masquerade --permanent
# 检查是否允许NAT转发
firewall-cmd --query-masquerade
# 关闭NAT转发
firewall-cmd --remove-masquerade
如果你使用了istio还有把istio-pilot的端口加到防火墙里:
firewall-cmd --permanent --add-port=15010-15014/tcp
否则会出现以下报错:
Envoy proxy is NOT ready

![【电子书】[职业技术] 《Kubernetes实战(套装共2册)》[吴龙辉][epub+mobi+azw3] 【电子书】[职业技术] 《Kubernetes实战(套装共2册)》[吴龙辉][epub+mobi+azw3]](https://www.04ip.com/template/qe/style/noimg/10.jpg)




