按照搭建Kubernetes时官网给的命令
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
部署完成时查看
[root@k8s-master01 flannel]# kubectl get pod -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-5c98db65d4-cr9lq 0/1 Pending 0 74m
coredns-5c98db65d4-h4h8f 0/1 Pending 0 74m
etcd-k8s-master01 1/1 Running 0 73m
kube-apiserver-k8s-master01 1/1 Running 0 73m
kube-controller-manager-k8s-master01 1/1 Running 0 73m
kube-flannel-ds-amd64-cpzh6 0/1 Init:ImagePullBackOff 0 51m
kube-proxy-sb68t 1/1 Running 0 74m
kube-scheduler-k8s-master01 1/1 Running 0 74m
flannel状态为Init:ImagePullBackOff
原因
查看kube-flannel.yml
文件时发现quay.io/coreos/flannel:v0.12.0-amd64
quay.io
网站目前国内无法访问
下载flannel:v0.12.0-amd64
导入到docker中
可以去https://github.com/coreos/flannel/releases
官方仓库下载镜像
[root@k8s-master01 tmp]# docker load < flanneld-v0.12.0-amd64.docker
256a7af3acb1: Loading layer [==================================================>] 5.844MB/5.844MB
d572e5d9d39b: Loading layer [==================================================>] 10.37MB/10.37MB
57c10be5852f: Loading layer [==================================================>] 2.249MB/2.249MB
7412f8eefb77: Loading layer [==================================================>] 35.26MB/35.26MB
05116c9ff7bf: Loading layer [==================================================>] 5.12kB/5.12kB
Loaded image: quay.io/coreos/flannel:v0.12.0-amd64
[root@k8s-master01 tmp]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
quay.io/coreos/flannel v0.12.0-amd64 4e9f801d2217 4 months ago 52.8MB
k8s.gcr.io/kube-proxy v1.15.1 89a062da739d 12 months ago 82.4MB
k8s.gcr.io/kube-scheduler v1.15.1 b0b3c4c404da 12 months ago 81.1MB
k8s.gcr.io/kube-apiserver v1.15.1 68c3eb07bfc3 12 months ago 207MB
k8s.gcr.io/kube-controller-manager v1.15.1 d75082f1d121 12 months ago 159MB
k8s.gcr.io/coredns 1.3.1 eb516548c180 18 months ago 40.3MB
k8s.gcr.io/etcd 3.3.10 2c4adeb21b4f 20 months ago 258MB
k8s.gcr.io/pause 3.1 da86e6ba6ca1 2 years ago 742kB
[root@k8s-master01 tmp]#
[root@k8s-master01 tmp]# kubectl get pod -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-5c98db65d4-cr9lq 1/1 Running 0 104m
coredns-5c98db65d4-h4h8f 1/1 Running 0 104m
etcd-k8s-master01 1/1 Running 0 103m
kube-apiserver-k8s-master01 1/1 Running 0 103m
kube-controller-manager-k8s-master01 1/1 Running 0 102m
kube-flannel-ds-amd64-cpzh6 1/1 Running 0 80m
kube-proxy-sb68t 1/1 Running 0 104m
kube-scheduler-k8s-master01 1/1 Running 0 103m
[root@k8s-master01 tmp]#