按手册安装选用的网络,并等待dns安装OK,然后增加node。
NAME STATUS ROLES AGE VERSION k8a204 Ready master 6m6s v1.13.0 [root@localhost .kube]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8a203 NotReady <none> 4s v1.13.0 k8a204 Ready master 6m19s v1.13.0注意,配置较慢,耐心等待
kubectl get pods --all-namespaces ===============以下是结果=============== NAMESPACE NAME READY STATUS RESTARTS AGE kube-system coredns-86c58d9df4-2vdvx 1/1 Running 0 7m32s kube-system coredns-86c58d9df4-88fjk 1/1 Running 0 7m32s kube-system etcd-k8a204 1/1 Running 0 6m39s kube-system kube-apiserver-k8a204 1/1 Running 0 6m30s kube-system kube-controller-manager-k8a204 1/1 Running 0 6m30s kube-system kube-proxy-tl7g5 1/1 Running 0 7m32s kube-system kube-proxy-w2jgl 0/1 ContainerCreating 0 95s kube-system kube-scheduler-k8a204 1/1 Running 0 6m49s 节点加入后NotReady接上一问题:
ContainerCreating 状态时,请耐心等待,但是如果超过10分钟仍然无响应,则必定是出错了,囧!
最主要的问题:节点的镜像拉不下来。
采用下列方式:
1)在master主机内保存镜像为文件:
docker save -o /opt/kube-pause.tar k8s.gcr.io/pause:3.1 docker save -o /opt/kube-proxy.tar k8s.gcr.io/kube-proxy:v1.13.0 docker save -o /opt/kube-flannel1.tar quay.io/coreos/flannel:v0.9.1 docker save -o /opt/kube-flannel2.tar quay.io/coreos/flannel:v0.10.0-amd64 docker save -o /opt/kube-calico1.tar quay.io/calico/cni:v3.3.2 docker save -o /opt/kube-calico2.tar quay.io/calico/node:v3.3.22)拷贝文件到node计算机
scp /opt/*.tar root@192.168.232.203:/opt/3) 在node节点执行docker导入
docker load -i /opt/kube-flannel1.tar docker load -i /opt/kube-flannel2.tar docker load -i /opt/kube-proxy.tar docker load -i /opt/kube-pause.tar docker load -i /opt/kube-calico1.tar docker load -i /opt/kube-calico2.tar4) 检查node节点镜像文件
docker images ==============================================以下是结果====================================== REPOSITORY TAG IMAGE ID CREATED SIZE k8s.gcr.io/kube-proxy v1.13.0 8fa56d18961f 9 days ago 80.2 MB quay.io/calico/node v3.3.2 4e9be81e3a59 9 days ago 75.3 MB quay.io/calico/cni v3.3.2 490d921fa49c 9 days ago 75.4 MB quay.io/coreos/flannel v0.10.0-amd64 f0fad859c909 10 months ago 44.6 MB k8s.gcr.io/pause 3.1 da86e6ba6ca1 11 months ago 742 kB quay.io/coreos/flannel v0.9.1 2b736d06ca4c 13 months ago 51.3 MB搞定了,所有服务均running
[root@localhost .kube]# kubectl get pods --all-namespaces ====================================以下是结果======================================== NAMESPACE NAME READY STATUS RESTARTS AGE kube-system calico-node-4dsg5 1/2 Running 0 42m kube-system calico-node-5dtk2 1/2 Running 0 41m kube-system calico-node-78qvp 1/2 Running 0 41m kube-system coredns-86c58d9df4-26vr7 1/1 Running 0 43m kube-system coredns-86c58d9df4-s5ljf 1/1 Running 0 43m kube-system etcd-k8a204 1/1 Running 0 42m kube-system kube-apiserver-k8a204 1/1 Running 0 42m kube-system kube-controller-manager-k8a204 1/1 Running 0 42m kube-system kube-proxy-8c7hs 1/1 Running 0 41m kube-system kube-proxy-dls8l 1/1 Running 0 41m kube-system kube-proxy-t65tc 1/1 Running 0 43m kube-system kube-scheduler-k8a204 1/1 Running 0 42m 重启恢复master swapoff -a # 启动所有容器 # 更简洁的命令: docker start $(docker ps -aq) docker start $(docker ps -a | awk '{ print $1}' | tail -n +2) systemctl start kubelet # 查看启动错误 journalctl -xefu kubelet # docker 开机自启 docker run --restart=alwaysDNS解析 kubernetes.default失败
安装busybox进行dns检测,一直出现如下错误:
kubectl exec -ti busybox -- nslookup kubernetes.default =============================以下是结果============================ Server: 10.96.0.10 Address: 10.96.0.10:53 ** server can't find kubernetes.default: NXDOMAIN *** Can't find kubernetes.default: No answer经查,新版busybox的dns解析有变化或bug,采用旧版本busybox images <= 1.28.4 后测试OK
token过期后重新生成
# 生成新的token kubeadm token create # 生成新的token hash码 openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //' # 利用新的token和hash码加入节点 # master地址,token,hash请自行更换 kubeadm join 192.168.232.204:6443 --token m87q91.gbcqhfx9ansvaf3o --discovery-token-ca-cert-hash sha256:fdd34ef6c801e382f3fb5b87bc9912a120bf82029893db121b9c8eae29e91c62