服务器准备
1.1 服务器Labs-K8s-Master-1:系统初始化
systemctl disable --now firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
hostnamectl set-hostname Labs-K8s-Master-1
reboot
cat >> /etc/hosts << EOF
10.10.2.151 Labs-K8s-Master-1
10.10.2.152 Labs-K8s-Master-2
10.10.2.153 Labs-K8s-Master-3
10.10.2.154 Labs-K8s-Woker-1
EOF
cat >> /etc/modules-load.d/k8s.conf << EOF
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
cat >> /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
sysctl -p /etc/sysctl.d/k8s.conf
echo 'pool tiger.sina.com.cn iburst' >> /etc/chrony.conf
echo 'pool ntp1.aliyun.com iburst' >> /etc/chrony.conf
systemctl enable chronyd
systemctl start chronyd
yum install -y ipset ipvsadm
cat >> /etc/sysconfig/modules/ipvs.modules << EOF
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack
EOF
chmod 755 /etc/sysconfig/modules/ipvs.modules
bash /etc/sysconfig/modules/ipvs.modules
lsmod | grep -e ip_vs -e nf_conntrack
1.2 服务器Labs-K8s-Master-2:系统初始化
systemctl disable --now firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
hostnamectl set-hostname Labs-K8s-Master-2
reboot
cat >> /etc/hosts << EOF
10.10.2.151 Labs-K8s-Master-1
10.10.2.152 Labs-K8s-Master-2
10.10.2.153 Labs-K8s-Master-3
10.10.2.154 Labs-K8s-Woker-1
EOF
cat >> /etc/modules-load.d/k8s.conf << EOF
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
cat >> /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
sysctl -p /etc/sysctl.d/k8s.conf
echo 'pool tiger.sina.com.cn iburst' >> /etc/chrony.conf
echo 'pool ntp1.aliyun.com iburst' >> /etc/chrony.conf
systemctl enable chronyd
systemctl start chronyd
yum install -y ipset ipvsadm
cat >> /etc/sysconfig/modules/ipvs.modules << EOF
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack
EOF
chmod 755 /etc/sysconfig/modules/ipvs.modules
bash /etc/sysconfig/modules/ipvs.modules
lsmod | grep -e ip_vs -e nf_conntrack
1.3 服务器Labs-K8s-Master-3:系统初始化
systemctl disable --now firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
hostnamectl set-hostname Labs-K8s-Master-3
reboot
cat >> /etc/hosts << EOF
10.10.2.151 Labs-K8s-Master-1
10.10.2.152 Labs-K8s-Master-2
10.10.2.153 Labs-K8s-Master-3
10.10.2.154 Labs-K8s-Woker-1
EOF
cat >> /etc/modules-load.d/k8s.conf << EOF
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
cat >> /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
sysctl -p /etc/sysctl.d/k8s.conf
echo 'pool tiger.sina.com.cn iburst' >> /etc/chrony.conf
echo 'pool ntp1.aliyun.com iburst' >> /etc/chrony.conf
systemctl enable chronyd
systemctl start chronyd
yum install -y ipset ipvsadm
cat >> /etc/sysconfig/modules/ipvs.modules << EOF
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack
EOF
chmod 755 /etc/sysconfig/modules/ipvs.modules
bash /etc/sysconfig/modules/ipvs.modules
lsmod | grep -e ip_vs -e nf_conntrack
1.4 服务器Labs-K8s-Woker-1:系统初始化
systemctl disable --now firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
hostnamectl set-hostname Labs-K8s-Woker-1
reboot
cat >> /etc/hosts << EOF
10.10.2.151 Labs-K8s-Master-1
10.10.2.152 Labs-K8s-Master-2
10.10.2.153 Labs-K8s-Master-3
10.10.2.154 Labs-K8s-Woker-1
EOF
cat >> /etc/modules-load.d/k8s.conf << EOF
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
cat >> /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
sysctl -p /etc/sysctl.d/k8s.conf
echo 'pool tiger.sina.com.cn iburst' >> /etc/chrony.conf
echo 'pool ntp1.aliyun.com iburst' >> /etc/chrony.conf
systemctl enable chronyd
systemctl start chronyd
yum install -y ipset ipvsadm
cat >> /etc/sysconfig/modules/ipvs.modules << EOF
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack
EOF
chmod 755 /etc/sysconfig/modules/ipvs.modules
bash /etc/sysconfig/modules/ipvs.modules
lsmod | grep -e ip_vs -e nf_conntrack