kubernetes集群管理系列讲座(十)使用kubeadm管理

2020-07-02  本文已影响0人  炼狱腾蛇Eric

课程目标

1. 使用kubeadm增加master/node节点

1.1. 查看token

下面那个23h的是我们的,发现还没过期。

$ kubeadm token list
TOKEN                     TTL         EXPIRES                USAGES                   DESCRIPTION                                                EXTRA GROUPS
424h2b.bmvx996zclz8uu5k   1h          2020-06-30T08:24:55Z   <none>                   Proxy for managing TTL for the kubeadm-certs secret        <none>
nzjpz8.vkfaw9phnwh32jol   23h         2020-07-01T06:24:55Z   authentication,signing   <none>                                                     system:bootstrappers:kubeadm:default-node-token
[ec2-user@ip-10-0-12-135 ~]$

1.2. 合成加入集群的命令

openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
89022963a3104da98a595443b6be361c7920700bd3f43fd29491eb0d4c18e0eb
$ kubeadm init phase upload-certs --upload-certs
W0630 07:14:53.905530   28330 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
[upload-certs] Storing the certificates in Secret "kubeadm-certs" in the "kube-system" Namespace
[upload-certs] Using certificate key:
6e8d24cb72dc0e9096394d602f95b027907bcf3d16750e72cccde33c00177f74
# master节点加入
  kubeadm join 10.0.1.94:6443 --token nzjpz8.vkfaw9phnwh32jol \
    --discovery-token-ca-cert-hash sha256:89022963a3104da98a595443b6be361c7920700bd3f43fd29491eb0d4c18e0eb \
    --control-plane --certificate-key 6e8d24cb72dc0e9096394d602f95b027907bcf3d16750e72cccde33c00177f74

# node节点加入

kubeadm join 10.0.1.94:6443 --token nzjpz8.vkfaw9phnwh32jol \
    --discovery-token-ca-cert-hash sha256:89022963a3104da98a595443b6be361c7920700bd3f43fd29491eb0d4c18e0eb
$ kubeadm token create --print-join-command
W0630 07:13:25.055002   26926 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
kubeadm join 10.0.1.94:6443 --token 2pvbmf.24m09oruy70t6bzj     --discovery-token-ca-cert-hash sha256:89022963a3104da98a595443b6be361c7920700bd3f43fd29491eb0d4c18e0eb

2. 使用kubeadm删除master/node节点

kubectl drain k8s-node2 --delete-local-data --force --ignore-daemonsets
kubectl delete node k8s-node2
kubeadm reset

为了方便大家学习,请大家加我的微信,我会把大家加到微信群(微信群的二维码会经常变)和qq群821119334,问题答案云原生技术课堂,有问题可以一起讨论

2020 CKA考试视频 真题讲解 https://www.bilibili.com/video/BV167411K7hp

2020 CKA考试指南 https://www.bilibili.com/video/BV1sa4y1479B/

2020年 5月CKA考试真题 https://mp.weixin.qq.com/s/W9V4cpYeBhodol6AYtbxIA

上一篇下一篇

猜你喜欢

热点阅读