1.create VM
centos 7.9 2CPU4GB
k8s-master
公共 IP 地址
20.212.185.31
专用 IP 地址
10.5.0.4
k8s-node1
公共 IP 地址
20.205.154.71
专用 IP 地址
10.5.0.5
k8s-node2
公共 IP 地址
20.212.197.234
专用 IP 地址
10.5.0.6
k8s-win
公共 IP 地址
20.212.156.45
专用 IP 地址
10.5.0.7
2.初始化配置
更新系统
yum update -y
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
关闭selinux
sed -i 's/enforcing/disabled/' /etc/selinux/config # 永久
setenforce 0 # 临时
关闭swap
swapoff -a # 临时
sed -ri 's/.swap./#&/' /etc/fstab # 永久
根据规划设置主机名
hostnamectl set-hostname
在master添加hosts
cat >> /etc/hosts << EOF
10.5.0.4 k8s-master
10.5.0.5 k8s-node1
10.5.0.6 k8s-node2
EOF
将桥接的IPv4流量传递到iptables的链
cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system # 生效
时间同步
yum install ntpdate -y
ntpdate time.windows.com
kubeadm init
--apiserver-advertise-address=10.5.0.4
--kubernetes-version v1.21.0
--service-cidr=10.96.0.0/12
--pod-network-cidr=10.244.0.0/16
--ignore-preflight-errors=all
kubeadm join 10.5.0.4:6443 --token rjm6xz.p9gaeqq9p4c2p48f
--discovery-token-ca-cert-hash sha256:c335b6cb6682bbb775e281d396f574f16bd1c90814de778d069d426b11c2dabc
kubeadm join 10.5.0.4:6443 --token rjm6xz.p9gaeqq9p4c2p48f
--discovery-token-ca-cert-hash
sha256:c335b6cb6682bbb775e281d396f574f16bd1c90814de778d069d426b11c2dabc
eyJhbGciOiJSUzI1NiIsImtpZCI6Im9mb1lueGJPNDBlOE5CbE1kSWdCeHN3WmhVSnlObXljemVPQ1EwamxlWW8ifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtYWRtaW4tdG9rZW4tN2hzcTUiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGFzaGJvYXJkLWFkbWluIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiZDNlNTU2OGYtZDFmMS00MzlhLWIxYWItOTU2YTVjMzcxNWIzIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmRhc2hib2FyZ
C1hZG1pbiJ9.WfZOATQ8HLCr5Ftz3ejYkTARoRTJc5QOsNlowY1PXyGwPGXtlpU37gRFllhCvOaV-s2wNaWV3G1QSaVisplBpNIbtrT8lkxnTdGS38vizvevjdAsemPKdy6qRJSGKajeItCSrtyYTkHdDLVxjJ93m8NLQU8NaFeAQ6nbutwBjjU07EU76h9z11lStsfm02xfndOIT_zLo7NR61gvMc5PqPBN_LtnusBT3mwkaphmGQUOvxElSnMlbwRi-vZQkOHTzk_VGHvp2Msw0-5hzhDgIoDyZ_tRunmlp38BjCYAJrzybJrbrayE7wjT-DjGrpayaTa3d_CGOpk6JDTE3qcRBA