5、docker+k8s+kubesphere:node安装

5、docker+k8s+kubesphere:node安装

将master节点上的$HOME/.kube/config 文件拷贝到node节点对应的文件中

[root@node151 ~]# cat .kube/config 
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOTENJL3gxeEkxR3BhV0EKVUJZSlpqaGlhVDFjY3lyVlpXa2lpWld5Mi9KT2pTSFBVMXppTFJhUUlBeE5wUEROSVU0eXhXOVp3dnVXdWdNUQpNU2k4K1FJT0JscEcwWWJiUFR4Z3dPMnd3dHh3QVBQQkpNTTF4QTMyRTgxUnZxc3VLTWUvZVpQamFGOVI2RlQwCjFNNVNmOHlNcEcvazk5d2QvakJwbXo3dE5jOXdpRHVRWHcxRFh4eXo4bEJTY2dwc2g0aENOTTVXaGhGcHRjWkoKSCtZMDUyNGFwSFoyMXlQVXVKSG1qNGdQUHAxb3oyOFVaWXZkLzJVNHJobldyVHB0Nzg5dGhLR3Y2c0hlT2pieAp5dWdxMGc0VGk3cjRScHZhd0szdVpzR3Y0ZjBNdDNCdXpjam55UDFjZndVYXNUQlA4eDlucjZ1R1ZYST0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
    server: https://192.168.5.151:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
...................................等等
在node152  node153  的根目录下创建
mkdir -p .kube
再从master上远程拷贝
[root@node151 .kube]# cd ..
[root@node151 ~]# cd .kube/
[root@node151 .kube]# ll
总用量 12
drwxr-x--- 3 root root   23 7月  24 14:53 cache
-rw------- 1 root root 5449 7月  24 14:53 config
drwxr-x--- 3 root root 4096 7月  24 15:23 http-cache
[root@node151 .kube]#  scp config [email protected]:$PWD
[root@node151 .kube]#  scp config [email protected]:$PWD

node节点执行,修改config权限

在node152  node153上执行
chown $(id -u):$(id -g) $HOME/.kube/config

node加入集群

在node152  node153上执行
将maser节点执行的永久不过期的token拷贝到node152、node153节点执行

kubeadm join 192.168.5.151:6443 --token uwt7uq.w932sasaow3jd8sg     --discovery-token-ca-cert-hash sha256:9cd6057cfb7372fbe19a056d372d439c0a2688487d0b140a184b91cf2aa3ccdf 

执行完的结果如下

[root@node152 ~]# kubeadm join 192.168.5.151:6443 --token uwt7uq.w932sasaow3jd8sg     --discovery-token-ca-cert-hash sha256:9cd6057cfb7372fbe19a056d372d439c0a2688487d0b140a184b91cf2aa3ccdf 
W0724 15:03:01.661481    1910 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set.
[preflight] Running pre-flight checks
	[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.17" 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@node153 ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@node153 ~]# systemctl enable docker.service
[root@node153 ~]# kubeadm join 192.168.5.151:6443 --token uwt7uq.w932sasaow3jd8sg     --discovery-token-ca-cert-hash sha256:9cd6057cfb7372fbe19a056d372d439c0a2688487d0b140a184b91cf2aa3ccdf 
W0724 15:03:07.279102    1875 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set.
[preflight] Running pre-flight checks
	[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.17" 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.


在master上执行
[root@node151 ~]#  kubectl get node
NAME      STATUS     ROLES    AGE   VERSION
node151   NotReady   master   28m   v1.17.5
node152   NotReady   <none>   59s   v1.17.5
node153   NotReady   <none>   51s   v1.17.5

这里所有节点都处于NotReady 状态,这里是正常的,因为还没有网络,需要安装网络

节点重新加入集群

节点出现问题解决方式

先删除之前的一些信息
rm -rf /etc/kubernetes/*
systemctl restart kubelet
systemctl status kubelet

再执行
kubeadm join 192.168.5.151:6443 --token uwt7uq.w932sasaow3jd8sg     --discovery-token-ca-cert-hash sha256:9cd6057cfb7372fbe19a056d372d439c0a2688487d0b140a184b91cf2aa3ccdf 

猜你喜欢

转载自blog.csdn.net/iteye_14723/article/details/107561449
今日推荐