在 CentOS7 環境,K8S 的 Master 透過 kubeadm join 啟動後,先查看 pods 處於 Pending 狀態

> kubectl get pods --all-namespaces
//or 
> kubectl get pods -n kube-system

//輸出
NAMESPACE     NAME                                          READY   STATUS    RESTARTS   AGE
kube-system   coredns-66bff467f8-c79f7                      0/1     Pending   0          24h
kube-system   coredns-66bff467f8-ncpd6                      0/1     Pending   0          24h
kube-system   etcd-k8s-master                               1/1     Running   0          24h
kube-system   kube-apiserver-k8s-master                     1/1     Running   0          24h
kube-system   kube-controller-manager-k8s-master            1/1     Running   0          24h
kube-system   kube-proxy-mnsjm                              1/1     Running   0          24h
kube-system   kube-scheduler-k8s-master                     1/1     Running   0          24h

以及查看 nodes,k8s-master 呈現 NotReady

> kubectl get nodes

//輸出
NAME                  STATUS     ROLES    AGE   VERSION
k8s-master            NotReady   master   44h   v1.18.6

解決這問題,只要安裝 flannel Pod 網路插件即可

(Flannel is an overlay network provider that can be used with Kubernetes.)

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

稍等一會,再查看 pods 輸出, coredns就會正常運行

> kubectl get pods -n kube-system

NAME                                          READY   STATUS    RESTARTS   AGE
coredns-66bff467f8-c79f7                      1/1     Running   0          45h
coredns-66bff467f8-ncpd6                      1/1     Running   0          45h
etcd-ssdnodes-adamouyang                      1/1     Running   1          45h
kube-apiserver-ssdnodes-adamouyang            1/1     Running   1          45h
kube-controller-manager-ssdnodes-adamouyang   1/1     Running   1          45h
kube-flannel-ds-amd64-4jnsx                   1/1     Running   0          4m45s
kube-flannel-ds-amd64-s8m9x                   1/1     Running   0          4m45s
kube-proxy-mnsjm                              1/1     Running   1          45h
kube-proxy-tzwqs                              1/1     Running   1          68m
kube-scheduler-ssdnodes-adamouyang            1/1     Running   1          45h

以及查看 node

> kubectl get node

NAME                  STATUS   ROLES    AGE   VERSION
k8s-master            Ready    master   45h   v1.18.6

若執行過程有發生問題,可查看日誌

journalctl -f -u kubelet.servic