安装前准备
1.修改主机名
hostname k8s-master 192.168.126.128
hostname k8s-node 192.168.126.129
设置hosts解析
cat >>/etc/hosts<<EOF
192.168.126.128 k8s-master
192.168.126.129 k8s-node
EOF
2. 关闭swap交换区
打开 /etc/fstab 注释掉 swap行,重启系统 ==> 临时关闭是:swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
3. 禁用SELinux
打开 /etc/sysconfig/selinux,将SELINUX=enforcing修改为SELINUX=disabled,重启系统
sed -ri 's#(SELINUX=).*#\1disabled#' /etc/selinux/config
setenforce 0
systemctl disable firewalld && systemctl stop firewalld
4. 设置iptables
iptables -P FORWARD ACCEPT
5. 修改内核参数
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forw