官方文档
可以参考下 kubernetes.io/zh-cn/docs/…
前置工作
参考初始化控制平面的文章,在工作节点服务器上进行初始化控制平面之前的所有前置工作
juejin.cn/post/756680…
参考安装网络插件的文章,需要配置 br_netfilter 内核模块加载
juejin.cn/post/756684…
安装
去控制平面节点打印工作节点加入命令
root@server-01:~# kubeadm token create --print-join-command
kubeadm join 192.168.174.128:6443 --token sv4d8i.nf6pbxbfef9ko35n --discovery-token-ca-cert-hash sha256:35fd160abe3f7e36db31657d1bc1916b6bf322fb133b1749c7bad4394cdc133b
去工作节点执行 join 命令
root@server-02:~# kubeadm join 192.168.174.128:6443 --token sv4d8i.nf6pbxbfef9ko35n --discovery-token-ca-cert-hash sha256:35fd160abe3f7e36db31657d1bc1916b6bf322fb133b1749c7bad4394cdc133b
[preflight] Running pre-flight checks
[WARNING HTTPProxy]: Connection to "https://192.168.174.128" uses proxy "http://192.168.43.196:1023". If that is not intended, adjust your proxy settings
[preflight] Reading configuration from the "kubeadm-config" ConfigMap in namespace "kube-system"...
[preflight] Use 'kubeadm init phase upload-config kubeadm --config your-config-file' to re-upload it.
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/instance-config.yaml"
[patches] Applied patch of type "application/strategic-merge-patch+json" to target "kubeletconfiguration"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-check] Waiting for a healthy kubelet at http://127.0.0.1:10248/healthz. This can take up to 4m0s
[kubelet-check] The kubelet is healthy after 502.11582ms
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap
This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.
Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
等待工作节点 flannel 部署完毕后(可能镜像拉取会比较慢,耐心等待 pod 状态 从 Init 变成 Running),在控制平面节点查看节点信息,工作节点状态为 Ready
root@server-01:~# kubectl get nodes -A
NAME STATUS ROLES AGE VERSION
server-01 Ready control-plane 17h v1.34.1
server-02 Ready <none> 15m v1.34.1