首页 > 其他分享 >k8s-新增master节点

k8s-新增master节点

时间:2023-01-11 18:33:06浏览次数:48  
标签:v1.18 join -- master kubeadm k8s 节点

在当前唯一的master节点上运行如下命令 第一步:

kubeadm init phase upload-certs --upload-certs
执行结果如下:
1 # kubeadm init phase upload-certs --upload-certs
2 I1109 14:34:00.836965    5988 version.go:255] remote version is much newer: v1.25.3; falling back to: stable-1.22
3 [upload-certs] Storing the certificates in Secret "kubeadm-certs" in the "kube-system" Namespace
4 [upload-certs] Using certificate key:
5 ecf2abbfdf3a7bc45ddb2de75152ec12889971098d69939b98e4451b53aa3033

第二步:

kubeadm token create --print-join-command
执行结果如下
[root@k8s-master ~]# kubeadm token create --print-join-command
kubeadm join 172.16.0.1:6443 --token xxxxxx --discovery-token-ca-cert-hash sha256:xxxxxxx
第三步: 将得到的token和key进行拼接,得到如下命令:
kubeadm join 172.16.0.1:6443 --token q466v0.hbk3qjreznjsf8ew --discovery-token-ca-cert-hash xxxxxxx --control-plane --certificate-key xxxxxxx
注意事项:
  1. 不要使用 --experimental-control-plane,会报错
  2. 要加上--control-plane --certificate-key ,不然就会添加为node节点而不是master
  3. join的时候节点上不要部署,如果部署了kubeadm reset后再join
  第四步: join之后在原先唯一的master节点上成功后,显示如下消息:
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.

这样,我们在任何一个master节点上使用命令

kubectl get nodes
都能看到现在是全部的节点:
# kubectl get nodes
NAME          STATUS   ROLES    AGE   VERSION
k8s-master    Ready    master   57m   v1.18.0
k8s-master1   Ready    master   21m   v1.18.0
k8s-master2   Ready    master   21m   v1.18.0
k8s-node1     Ready    <none>   56m   v1.18.0
k8s-node2     Ready    <none>   56m   v1.18.0
k8s-node3     Ready    <none>   56m   v1.18.0
k8s-node4     Ready    <none>   56m   v1.18.0
k8s-node5     Ready    <none>   56m   v1.18.0
报错: 1. 第一次加入集群的时候会有以下报错:
 1 [preflight] Running pre-flight checks
 2 [preflight] Reading configuration from the cluster...
 3 [preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
 4 error execution phase preflight:
 5 One or more conditions for hosting a new control plane instance is not satisfied.
 6 
 7 unable to add a new control plane instance a cluster that doesn't have a stable controlPlaneEndpoint address
 8 
 9 Please ensure that:
10 * The cluster has a stable controlPlaneEndpoint address.
11 * The certificates that must be shared among control plane instances are provided.
12 
13 
14 To see the stack trace of this error execute with --v=5 or higher
解决办法如下:
查看kubeadm-config.yaml
kubectl -n kube-system get cm kubeadm-config -oyaml
发现没有controlPlaneEndpoint
添加controlPlaneEndpoint
kubectl -n kube-system edit cm kubeadm-config
大概在这么个位置:
kind: ClusterConfiguration
kubernetesVersion: v1.18.0
controlPlaneEndpoint: 172.16.0.56:6443
然后再在准备添加为master的节点上执行kubeadm join的命令

  

标签:v1.18,join,--,master,kubeadm,k8s,节点
From: https://www.cnblogs.com/qianyuliang/p/17044626.html

相关文章

  • K8s常用命令
    #部署应用kubectlapply-fapp.yaml#查看deploymentkubectlgetdeployment#查看podkubectlgetpod-owide#查看pod详情kubectldescribepodpod-name#......
  • K8s创建pod yaml文件详解
    apiVersion:v1#指定api版本,此值必须在kubectlapiversion中kind:Pod#指定创建资源的角色/类型metadata:#资源的元数据/属性name:web04-pod#资源的名字,......
  • 搭建k8s集群初始化master节点 kubeadm init 遇到问题解决
    搭建k8s集群时遇到的问题一记,自己找了很久解决方案,也看到有些人提出类似问题后不了了之,于是发出来给网络做一次贡献kubeadminit报错”unknownserviceruntime.v1al......
  • zigbee提升最大节点数的一点点研究
    zigbee网络中有一种地址叫做网络短地址,共有16位,最大值是0xFFFF,也就是65536,这个值就规定了理论上一个zigbee网络中最多能有设备65536个。当然,实际上很难做到有这么......
  • Centos7.6部署k8s v1.16.4高可用集群(主备模式)
    原文:https://zhuanlan.zhihu.com/p/465647563一、部署环境主机列表:共有7台服务器,3台controlplane,3台work,1台client。k8s版本:二、高可用架构本文采用kub......
  • 在 K8S Volume 中使用 subPath
    使用subPath有时,在单个Pod中共享卷以供多方使用是很有用的。volumeMounts.subPath属性可用于指定所引用的卷内的子路径,而不是其根路径。下面是一个使用同一共享卷的......
  • 在 K8S Volume 中使用 subPath
    使用subPath有时,在单个Pod中共享卷以供多方使用是很有用的。volumeMounts.subPath属性可用于指定所引用的卷内的子路径,而不是其根路径。下面是一个使用同一共享卷的......
  • 【多用户】k8s多用户配置 kubeconfig
    K8S集群中的认证、授权与kubeconfig一、kubeconfig介绍-[appuser@k8s-master-1~]$cat/etc/kubernetes/kubeconfigapiVersion:v1kind:Configclusters:-name:shj......
  • 增加ceph mon节点
    增加cephmon节点随便找一台正在运行的mon节点上修改ceph.conf,增加相应的moninitialmembers与monhost,不再赘述。然后同步到所有节点。可使用如下命令进行远程同步(前提......
  • android11 keymaster4 和 keymaster3 接口差异点
    最近在尝试升级optee的keymaster3实现到keymaster4。记录下升级过程中的方法和一些坑,便于回溯。keymaster源码:https://github.com/linaro-swg/kmgk基于这份源码,basedan......