本文主要是介绍k8s 高可用集群 -加入第二个master,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
k8s 高可用集群 -加入第二个master
问题:
[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 -oyaml'
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 addressPlease ensure that:
* The cluster has a stable controlPlaneEndpoint address.
* The certificates that must be shared among control plane instances are provided.
第一次尝试加入的时候报了上面的错误
开始填坑:
step 1
查看一下 kubeadm-config.yaml
kubectl -n kube-system get cm kubeadm-config -oyaml
发现controlPlaneEndpoint的值是空的.
走,去改他.
kubectl -n kube-system edit cm kubeadm-config
编辑yaml文件
controlPlaneEndpoint值为192.168.1.194:6443(当前master ip),然后确认信息修改完成
step 2
从master1 拷贝证书到master2
# cat scp.sh
USER=root
port=62200
CONTROL_PLANE_IPS="192.168.1.122"
for host in ${CONTROL_PLANE_IPS}; doscp -P ${port} /etc/kubernetes/pki/ca.crt "${USER}"@$host:scp -P ${port} /etc/kubernetes/pki/ca.key "${USER}"@$host:scp -P ${port} /etc/kubernetes/pki/sa.key "${USER}"@$host:scp -P ${port} /etc/kubernetes/pki/sa.pub "${USER}"@$host:scp -P ${port} /etc/kubernetes/pki/front-proxy-ca.crt "${USER}"@$host:scp -P ${port} /etc/kubernetes/pki/front-proxy-ca.key "${USER}"@$host:scp -P ${port} /etc/kubernetes/pki/etcd/ca.crt "${USER}"@$host:etcd-ca.crtscp -P ${port} /etc/kubernetes/pki/etcd/ca.key "${USER}"@$host:etcd-ca.keyscp -P ${port} /etc/kubernetes/admin.conf "${USER}"@$host:ssh -p${port} ${USER}@${host} 'mkdir -p /etc/kubernetes/pki/etcd'ssh -p${port} ${USER}@${host} 'mv /${USER}/ca.crt /etc/kubernetes/pki/'ssh -p${port} ${USER}@${host} 'mv /${USER}/ca.key /etc/kubernetes/pki/'ssh -p${port} ${USER}@${host} 'mv /${USER}/sa.pub /etc/kubernetes/pki/'ssh -p${port} ${USER}@${host} 'mv /${USER}/sa.key /etc/kubernetes/pki/'ssh -p${port} ${USER}@${host} 'mv /${USER}/front-proxy-ca.crt /etc/kubernetes/pki/'ssh -p${port} ${USER}@${host} 'mv /${USER}/front-proxy-ca.key /etc/kubernetes/pki/'ssh -p${port} ${USER}@${host} 'mv /${USER}/etcd-ca.crt /etc/kubernetes/pki/etcd/ca.crt'ssh -p${port} ${USER}@${host} 'mv /${USER}/etcd-ca.key /etc/kubernetes/pki/etcd/ca.key'ssh -p${port} ${USER}@${host} 'mv /${USER}/admin.conf /etc/kubernetes/admin.conf'
done
step 3
再次尝试加入
kubeadm join 192.168.1.194:6443 --token 424mp7.nkxx07p940mkl2nd --discovery-token-ca-cert-hash sha256:f64bf3bb57ed8ae6ff25e24b68f9b5ff79d32e7b2b53ab54c7c02c0b4edb72bc --experimental-control-plane
与加入 node相比,以master的身份加入多了: --experimental-control-plane
这回可以了吧,老铁。
step 4
配置一下kubectl,以便管理集群
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl get nodes
Done
参考&感谢:
- Kubernetes安装(kubeadm方法安装)
- 使用kubeadm部署k8s多master集群(一)集群部署
这篇关于k8s 高可用集群 -加入第二个master的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!