单master节点k8s集群加入新的master节点报错error execution phase preflight: One or more conditions for hosting...
单master节点k8s集群加入新的master节点报错error execution phase preflight:One or more conditions for hosting…一、查看节点:k8s-master01服务器:查看token和证书:[root@k8s-master01 iamges-pull]# kubectl get nodesNAMESTATUSROLESAGEVER
·
单master节点k8s集群加入新的master节点报错error execution phase preflight: One or more conditions for hosting…
一、查看节点:
k8s-master01服务器:
查看token和证书:
[root@k8s-master01 iamges-pull]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master01 Ready control-plane,master 102m v1.22.1
二、生成master节点加入命令
[root@k8s-master01 iamges-pull]# kubeadm token create --ttl 0 --print-join-command
kubeadm join 10.0.0.210:6443 --token b9dfm3.39mwjt0v1oab0xrq --discovery-token-ca-cert-hash sha256:b9a246c680238127e0fdab36d45fff2d2a5a54c48f8fa4c54a235eb9a0012383
[root@k8s-master01 flannel]# kubeadm init phase upload-certs --upload-certs
I0507 19:50:57.979860 92344 version.go:255] remote version is much newer: v1.24.0; falling back to: stable-1.22
[upload-certs] Storing the certificates in Secret "kubeadm-certs" in the "kube-system" Namespace
[upload-certs] Using certificate key:
6e3e8b8e279385f6f6e89b459686900127eee9a22d061ca3680581a30cd7e703
拼接master节点加入的命令:
kubeadm join 10.0.0.210:6443 --token b9dfm3.39mwjt0v1oab0xrq \
--discovery-token-ca-cert-hash sha256:b9a246c680238127e0fdab36d45fff2d2a5a54c48f8fa4c54a235eb9a0012383 \
--control-plane --certificate-key 9fec8959bb3bb3a14d817f1efb6badc39b81084287ece45294671e4f8ba44445
三、节点加入
k8s-master02服务器:
[root@k8s-master02 iamges-pull]# kubeadm join 10.0.0.210:6443 --token b9dfm3.39mwjt0v1oab0xrq --discovery-token-ca-cert-hash sha256:b9a246c680238127e0fdab36d45fff2d2a5a54c48f8fa4c54a235eb9a0012383 --control-plane --certificate-key 9fec8959bb3bb3a14d817f1efb6badc39b81084287ece45294671e4f8ba44445
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
error execution phase preflight:
One or more conditions for hosting a new control plane instance is not satisfied.
unable to add a new control plane instance a cluster that doesn't have a stable controlPlaneEndpoint address
Please ensure that:
* The cluster has a stable controlPlaneEndpoint address.
* The certificates that must be shared among control plane instances are provided.
To see the stack trace of this error execute with --v=5 or higher
总是报错,不能加入成功?????????
四、问题解决
k8s-master01服务器:
kubectl -n kube-system edit cm kubeadm-config
## 添加此行信息
controlPlaneEndpoint: "10.0.0.210:6443"
###保存
如下:
[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" ## 添加此行信息
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
k8s-master02服务器:
再次尝试加入:
[root@k8s-master02 iamges-pull]# kubeadm join 10.0.0.210:6443 --token b9dfm3.39mwjt0v1oab0xrq --discovery-token-ca-cert-hash sha256:b9a246c680238127e0fdab36d45fff2d2a5a54c48f8fa4c54a235eb9a0012383 --control-plane --certificate-key 9fec8959bb3bb3a14d817f1efb6badc39b81084287ece45294671e4f8ba44445
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
error execution phase preflight:
One or more conditions for hosting a new control plane instance is not satisfied.
unable to add a new control plane instance a cluster that doesn't have a stable controlPlaneEndpoint address
Please ensure that:
* The cluster has a stable controlPlaneEndpoint address.
* The certificates that must be shared among control plane instances are provided.
To see the stack trace of this error execute with --v=5 or higher
[root@k8s-master02 iamges-pull]# kubeadm join 10.0.0.210:6443 --token b9dfm3.39mwjt0v1oab0xrq --discovery-token-ca-cert-hash sha256:b9a246c680238127e0fdab36d45fff2d2a5a54c48f8fa4c54a235eb9a0012383 --control-plane --certificate-key 9fec8959bb3bb3a14d817f1efb6badc39b81084287ece45294671e4f8ba44445
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
error execution phase preflight:
One or more conditions for hosting a new control plane instance is not satisfied.
unable to add a new control plane instance a cluster that doesn't have a stable controlPlaneEndpoint address
Please ensure that:
* The cluster has a stable controlPlaneEndpoint address.
* The certificates that must be shared among control plane instances are provided.
To see the stack trace of this error execute with --v=5 or higher
[root@k8s-master02 iamges-pull]# kubeadm join 10.0.0.210:6443 --token b9dfm3.39mwjt0v1oab0xrq --discovery-token-ca-cert-hash sha256:b9a246c680238127e0fdab36d45fff2d2a5a54c48f8fa4c54a235eb9a0012383 --control-plane --certificate-key 9fec8959bb3bb3a14d817f1efb6badc39b81084287ece45294671e4f8ba44445
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[preflight] Running pre-flight checks before initializing the new control plane instance
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[download-certs] Downloading the certificates in Secret "kubeadm-certs" in the "kube-system" Namespace
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [k8s-master02 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.0.0.211 10.0.0.210]
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [k8s-master02 localhost] and IPs [10.0.0.211 127.0.0.1 ::1]
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [k8s-master02 localhost] and IPs [10.0.0.211 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Valid certificates and keys now exist in "/etc/kubernetes/pki"
[certs] Using the existing "sa" key
[kubeconfig] Generating kubeconfig files
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[check-etcd] Checking that the etcd cluster is healthy
[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-start] Waiting for the kubelet to perform the TLS Bootstrap...
[etcd] Announced new etcd member joining to the existing etcd cluster
[etcd] Creating static Pod manifest for "etcd"
[etcd] Waiting for the new etcd member to join the cluster. This can take up to 40s
The 'update-status' phase is deprecated and will be removed in a future release. Currently it performs no operation
[mark-control-plane] Marking the node k8s-master02 as control-plane by adding the labels: [node-role.kubernetes.io/master(deprecated) node-role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers]
[mark-control-plane] Marking the node k8s-master02 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule]
This node has joined the cluster and a new control plane instance was created:
* Certificate signing request was sent to apiserver and approval was received.
* The Kubelet was informed of the new secure connection details.
* Control plane (master) label and taint were applied to the new node.
* The Kubernetes control plane instances scaled up.
* A new etcd member was added to the local/stacked etcd cluster.
To start administering your cluster from this node, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Run 'kubectl get nodes' to see this node join the cluster.
[root@k8s-master02 iamges-pull]# mkdir -p $HOME/.kube
[root@k8s-master02 iamges-pull]# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
[root@k8s-master02 iamges-pull]# sudo chown $(id -u):$(id -g) $HOME/.kube/config
查看节点:
[root@k8s-master02 iamges-pull]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master01 Ready control-plane,master 121m v1.22.1
k8s-master02 Ready control-plane,master 11m v1.22.1
成功!!!!!!!!!!!
更多推荐
已为社区贡献14条内容
所有评论(0)