集群主节点安装方法如下:
    1.参看下面连接信息:
    https://www.yuque.com/nickname-uo8wh/rycohh/oza3bw
    安装完毕之后,从节点只需要安装到第10步,此时从节点不需要init
    拷贝主节点安装从节点信息,在从节点位置执行下面方式:

    1. [root@localhost docker]# kubeadm join 192.168.0.127:6443 --token fvdmel.61fjcb4ej591sujj \
    2. --discovery-token-ca-cert-hash sha256:f36a0ec6acd67259e8f86a6a882bdf445685341a4c2b52cebc7e9651d3de7ec6

    如果长时间没有加入集群中,可能存在token失效的情况,此时在主节点上,做如下操作,重新获取token:

    1. [root@master01 k8s]# kubeadm token create
    2. W0517 01:41:44.766379 948637 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
    3. 263ih8.r7ha83r2l115x35f

    集群安装完成之后登录控制台,使用token匿名登录之后会存在看不到控制面板的情况,需要执行以下命令,让控制台能够看到集群的工作情况

    1. [root@master01 k8s]# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
    2. 2dccc854ba53678dc594a7b2c9fda859370c616ab9599e84b3014f4d2134d8a1
    1. 出现以下信息代表加入集群成功:
    1. [root@localhost docker]# kubeadm join 192.168.0.112:6443 --token i7pd7i.jipszw0hku7gzekj --discovery-token-ca-cert-hash sha256:2dccc854ba53678dc594a7b2c9fda859370c616ab9599e84b3014f4d2134d8a1
    2. W0517 01:59:22.532878 11190 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set.
    3. [preflight] Running pre-flight checks
    4. [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
    5. [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.6. Latest validated version: 19.03
    6. [WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
    7. [preflight] Reading configuration from the cluster...
    8. [preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
    9. [kubelet-start] Downloading configuration for the kubelet from the "kubelet-config-1.18" ConfigMap in the kube-system namespace
    10. [kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
    11. [kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
    12. [kubelet-start] Starting the kubelet
    13. [kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...
    14. This node has joined the cluster:
    15. * Certificate signing request was sent to apiserver and a response was received.
    16. * The Kubelet was informed of the new secure connection details.
    17. Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
    1. 在主节点运行:
    1. [root@master01 k8s]# kubectl get nodes
    2. NAME STATUS ROLES AGE VERSION
    3. master01.paas.com Ready master 3d7h v1.18.0
    4. master03.paas.com Ready <none> 8m50s v1.18.0
    5. node01 Ready worker 3d6h v1.18.0

    集群加入成功