环境准备
kubernetes环境是通过kubeadm初始化的,以自托管(self-hosted)模式搭建的(docker镜像)
1.关闭防火墙,关闭selinux
(生产环境按需关闭或打开)
systemctl disable firewalld.service
systemctl stop firewalld.service
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
检查:
systemctl is-enabled firewalld.service
systemctl status firewalld.service
getenforce
2.同步服务器时间
选择公网ntpd服务器或者自建ntpd服务器
3.关闭swap分区
echo "vm.swappiness=1">>/etc/sysctl.conf
sysctl -p
检查:
sysctl -a | grep “vm.swappiness”
4.集群所有节点主机可以相互解析
5.master对node节点ssh互信
ssh-keygen -t rsa
ssh-copy-id -i /root/.ssh/id_rsa.pub 172.16.xx.xx
6.配置系统内核参数使流过网桥的流量也进入iptables/netfilter框架
modprobe br_netfilter
echo -e 'net.bridge.bridge-nf-call-iptables = 1 \nnet.bridge.bridge-nf-call-ip6tables = 1' >> /etc/sysctl.conf && sysctl -p
或者
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl