k8s-后期添加node節點


1. k8s-后期添加node接口

由於kubeadm前期安裝完成后join使用 token 過期時間為(24小時過期),所以需要重新生成token

  • 重新生成新的token

    [root@k8s-master ~]# kubeadm token create
    W0522 12:29:55.879191   12368 configset.go:348] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
    rkv6b7.zee4rywuo0ywg04s
    
  • 查看是否存在有效的 token 值

    [root@k8s-master ~]# kubeadm token list
    TOKEN                     TTL         EXPIRES                     USAGES                   DESCRIPTION                                                EXTRA GROUPS
    rkv6b7.zee4rywuo0ywg04s   23h         2021-05-23T12:29:55+08:00   authentication,signing   <none>                                                     system:bootstrappers:kubeadm:default-node-token
    
  • 獲取CA證書 sha256 編碼 hash 值

    [root@k8s-master ~]# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
    ae10cf364184d37cd3289c996659ee434f3a54c2bc8b80aadc5a68888ff7486a
    
  • 執行node節點加入

    [root@k8s-node02 ~]# kubeadm join 172.17.0.13:6443 --token rkv6b7.zee4rywuo0ywg04s     --discovery-token-ca-cert-hash sha256:ae10cf364184d37cd3289c996659ee434f3a54c2bc8b80aadc5a68888ff7486a
    [preflight] Running pre-flight checks
    	[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/
    	[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.6. Latest validated version: 19.03
    [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'
    [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...
    
    This node has joined the cluster:
    * Certificate signing request was sent to apiserver and a response was received.
    * The Kubelet was informed of the new secure connection details.
    
    Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
    
  • k8s master端驗證是否正常

    [root@k8s-master ~]# kubectl get nodes
    NAME         STATUS   ROLES    AGE     VERSION
    k8s-master   Ready    master   4d22h   v1.19.0
    k8s-node01   Ready    <none>   4d22h   v1.19.0
    k8s-node02   Ready    <none>   2m48s   v1.19.0
    

    發現成功添加到新集群里


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM