文章目录
1. 查看节点
kubectl get nodes
2. 增加节点
若maser初始化成功后 kubeadm join xxx , 如果忘记,则在master节点上执行 #kubeadm token list
若默认token 24小时过期,后续机器要加入集群需要重新使用下面命令重新生成token
#kubeadm token create
获取ca证书sha256编码hash值
#openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
添加worker节点
#kubeadm join --token <重新生成的token值> 192.168.1.105:6443 --discovery-token-ca-cert-hash sha256:<sha256编码值>
或者指定配置文件
#kubadm join --config kubeadm-config.yaml
#cat kubeadm-config.yaml
apiVersion: kubeadm.k8s.io/v1beta2
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
token: abcdef.0123456789abcdef
ttl: 24h0m0s
usages:
- signing
- authentication
kind: InitConfiguration
localAPIEndpoint:
advertiseAddress: 192.168.86.137
bindPort: 6443
nodeRegistration:
criSocket: /var/run/dockershim.sock
name: 192.168.86.137
taints:
- effect: NoSchedule
key: node-role.kubernetes.io/master
---
apiServer:
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns:
type: CoreDNS
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: registry.aliyuncs.com/google_containers
kind: ClusterConfiguration
kubernetesVersion: v1.17.17
networking:
dnsDomain: cluster.local
serviceSubnet: 10.96.0.0/12
podSubnet: 10.244.0.0/16
scheduler: {}
重新添加已经添加过的节点,请先初始化
#kubeadm reset
3. 删除节点
-
驱逐节点(drain 翻译排出,此时卸载节点,但是没有删除)
#kubectl drain --delete-local-data --force --ignore-daemonsets -
删除节点
kubectl delete node -
清空init配置,需要删除的节点上执行
kubeadm reset