环境3master,现已初始成功master01,需要将master02 加入master 01 中。一些报错和解决办法

报错1:error execution phase preflight:

问题

  1. [root@k8s-master02 ~]# kubeadm join 192.168.77.17:6443 --token uhny33.wj7v4ahq3gmjeubg --discovery-token-ca-cert-hash sha256:2eea886037094d698b1549454e4a9c1932ee31e258890153322cfbb6fe125926 --control-plane --certificate-key 8c8976904d1de3657c4c4d7b945645ac9dfb97f2099665973d7ed2045a019c74
  2. [preflight] Running pre-flight checks
  3. [preflight] Reading configuration from the cluster...
  4. [preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
  5. error execution phase preflight:
  6. One or more conditions for hosting a new control plane instance is not satisfied.
  7. unable to add a new control plane instance a cluster that doesn't have a stable controlPlaneEndpoint address
  8. Please ensure that:
  9. * The cluster has a stable controlPlaneEndpoint address.
  10. * The certificates that must be shared among control plane instances are provided.

解决办法

参考资料:https://blog.csdn.net/weixin_40668374/article/details/124638969
在master01 中执行

kubectl -n kube-system edit cm kubeadm-config
[root@k8s-master01 iamges-pull]# kubectl -n kube-system edit cm kubeadm-config
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
data:
  ClusterConfiguration: |
    apiServer:
      extraArgs:
        authorization-mode: Node,RBAC
      timeoutForControlPlane: 4m0s
    apiVersion: kubeadm.k8s.io/v1beta3
    certificatesDir: /etc/kubernetes/pki
    clusterName: kubernetes
    controllerManager: {}
    dns: {}
    etcd:
      local:
        dataDir: /var/lib/etcd
    imageRepository: 10.0.0.214:80/google_containers
    kind: ClusterConfiguration
    kubernetesVersion: v1.22.1
    controlPlaneEndpoint: "10.0.0.210:6443" ## 添加此行信息,这里10.0.0.210 是你master01 的IP,比如192.168.77.17
    networking:
      dnsDomain: cluster.local
      podSubnet: 10.244.0.0/16
      serviceSubnet: 10.96.0.0/12
    scheduler: {}
kind: ConfigMap
metadata:
  creationTimestamp: "2022-05-07T10:34:06Z"
  name: kubeadm-config
  namespace: kube-system
  resourceVersion: "8483"
  uid: ae61d9bb-f401-4b79-a47f-f704ced7bc39

报错2:忘记Join命令

在master01 上

# 此处要记录下 join语句,如果join token忘记,则需要执行下边命令重新生成
kubeadm token create --print-join-command


生成新的密钥
kubeadm init phase upload-certs --upload-certs

然后拼接两个语句,在master02 上执行

kubeadm join 192.168.77.17:6443 --token uhny33.wj7v4ahq3gmjeubg     --discovery-token-ca-cert-hash sha256:2eea886037094d698b1549454e4a9c1932ee31e258890153322cfbb6fe125926 --control-plane --certificate-key  8c8976904d1de3657c4c4d7b945645ac9dfb97f2099665973d7ed2045a019c74

报错3:新的服务器安装docker错误

https://www.cnblogs.com/zyh-smile/p/12350371.html