集群主节点安装方法如下:
1.参看下面连接信息:
https://www.yuque.com/nickname-uo8wh/rycohh/oza3bw
安装完毕之后,从节点只需要安装到第10步,此时从节点不需要init
拷贝主节点安装从节点信息,在从节点位置执行下面方式:
[root@localhost docker]# kubeadm join 192.168.0.127:6443 --token fvdmel.61fjcb4ej591sujj \
--discovery-token-ca-cert-hash sha256:f36a0ec6acd67259e8f86a6a882bdf445685341a4c2b52cebc7e9651d3de7ec6
如果长时间没有加入集群中,可能存在token失效的情况,此时在主节点上,做如下操作,重新获取token:
[root@master01 k8s]# kubeadm token create
W0517 01:41:44.766379 948637 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
263ih8.r7ha83r2l115x35f
集群安装完成之后登录控制台,使用token匿名登录之后会存在看不到控制面板的情况,需要执行以下命令,让控制台能够看到集群的工作情况
[root@master01 k8s]# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
2dccc854ba53678dc594a7b2c9fda859370c616ab9599e84b3014f4d2134d8a1
- 出现以下信息代表加入集群成功:
[root@localhost docker]# kubeadm join 192.168.0.112:6443 --token i7pd7i.jipszw0hku7gzekj --discovery-token-ca-cert-hash sha256:2dccc854ba53678dc594a7b2c9fda859370c616ab9599e84b3014f4d2134d8a1
W0517 01:59:22.532878 11190 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set.
[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
[WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
[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] Downloading configuration for the kubelet from the "kubelet-config-1.18" ConfigMap in the kube-system namespace
[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.
- 在主节点运行:
[root@master01 k8s]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master01.paas.com Ready master 3d7h v1.18.0
master03.paas.com Ready <none> 8m50s v1.18.0
node01 Ready worker 3d6h v1.18.0
集群加入成功