apt-get update && apt-get install -y apt-transport-https
# 添加key
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg > /etc/apt//etc/apt/trusted.gpg.d/aliyun-kubernetes.asc
# 添加软件源
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
# 执行更新并安装
apt-get update
apt-get install -y kubelet kubeadm kubectl
cat <<EOF >/etc/default/kubelet
KUBELET_EXTRA_ARGS="--pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.6"
EOF
# 关闭swap
sudo swapoff -a
# 初始化
sudo kubeadm init --kubernetes-version v1.27.4 --image-repository registry.aliyuncs.com/google_containers --apiserver-advertise-address 0.0.0.0 --service-cidr 10.1.0.0/16 --pod-network-cidr 10.2.0.0/16
这时,master应该就安装完成了
sudo kubeadm join 192.168.8.5:6443 --token XXXXXX.XXXXXXXXXXXXXXXX --discovery-token-ca-cert-hash sha256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
其中token和hash来自master初始化最后的输出,地址和端口是master的apiserver