使用kubeadm工具箱创建Kubernetes集群(4)

节点是工作负载(containers and pods)运行的地方。要将新节点添加到群集,请为每台机器执行以下操作:
# 节点需要安装 yum install -y kubelet kubeadm kubectl

[root@aniu-saas-4 ~]# kubeadm join --token dc2313.9e3daddc83109625 192.168.10.10:6443 --discovery-token-ca-cert-hash sha256:8fe62dea8e88ff957dcd712f3c5948cc43f940abb3f34e8823576434d216ed5a
[preflight] Running pre-flight checks.
        [WARNING FileExisting-crictl]: crictl not found in system path
[preflight] Starting the kubelet service
[discovery] Trying to connect to API Server "192.168.10.10:6443"
[discovery] Created cluster-info discovery client, requesting info from "https://192.168.10.10:6443"
[discovery] Requesting info from "https://192.168.10.10:6443" again to validate TLS against the pinned public key
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server "192.168.10.10:6443"
[discovery] Successfully established connection with API Server "192.168.10.10:6443"

This node has joined the cluster:
* Certificate signing request was sent to master and a response
  was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the master to see this node join the cluster.

查看节点信息
[root@aniu-k8s ~]# kubectl get nodes
NAME          STATUS    ROLES    AGE      VERSION
aniu-k8s      Ready      master    1h        v1.9.2
aniu-saas-4  NotReady  <none>    17s      v1.9.2

从其他机器或者笔记本终端操作集群
scp root@<master ip>:/etc/kubernetes/admin.conf .
kubectl --kubeconfig ./admin.conf get nodes

将API服务器代理到本地主机
scp root@<master ip>:/etc/kubernetes/admin.conf .
kubectl --kubeconfig ./admin.conf proxy

删除Kubernetes集群节点
kubectl drain <node name> --delete-local-data --force --ignore-daemonsets
kubectl delete node <node name>

注意事项
如果kubeadm出错,修改完成之后需要 kubeadm reset在重启初始化
官网文档只有修改docker配置哪一步,笔者没有操作,其他步骤和官网一致

错误
查看系统日志仍存在相关错误:
#
Error adding network: open /run/flannel/subnet.env: no such file or directory
#
oci-systemd-hook[12470]: systemdhook <debug>: Skipping as container command is /pause, not init or systemd
# 后面继续学习排查故障

部署Dashboard插件
下载Dashboard配置文件
mkdir ~/k8s
cd ~/k8s
wget https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/04baa94af211f0afbc53451212d4d520.html