k8s安装网络插件镜像下载不了问题

下面是本人在帮好友安装k8s过程中在安装网络插件这里碰到的问题

使用kubectl apply -f kube-flannel.yml安装flannel网络插件

安装完之后是要等个一阵子的,但是等了十分钟后发现节点状态还是为Noready

通过journalctl -f -u kubelet 查看kubelet日志发现报错

systemctl status kubelet 查看报错如下

# systemctl status kubelet
* kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/usr/lib/systemd/system/kubelet.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/kubelet.service.d
           `-10-kubeadm.conf
   Active: active (running) since  2022-11-04 19:53:22 CST; 7s ago
     Docs: https://kubernetes.io/docs/
 Main PID: 22607 (kubelet)
    Tasks: 14
   Memory: 32.7M
   CGroup: /system.slice/kubelet.service
           `-22607 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --network-plugin=cni...

22607 kubelet.go:1742] "Failed creating a mirror pod for" err="pods \"kube-apiserver-master\" already exists" pod="kube-...server-master"
22607 kubelet.go:1742] "Failed creating a mirror pod for" err="pods \"kube-controller-manager-master\" already exists" p...anager-master"
22607 request.go:665] Waited for 1.041822653s due to client-side throttling, not priority and fairness, request: POST:ht...be-system/pods
22607 kubelet.go:1742] "Failed creating a mirror pod for" err="pods \"kube-scheduler-master\" already exists" pod="kube-...eduler-master"
22607 configmap.go:200] Couldn't get configMap kube-system/kube-proxy: failed to sync configmap cache: timed out waiting... the condition
22607 nestedpendingoperations.go:335] Operation for "{volumeName:kubernetes.io/configmap/6839e60e-9e18-4b9a-90e5-bdbc860...215 +0800 CST
22607 configmap.go:200] Couldn't get configMap kube-flannel/kube-flannel-cfg: failed to sync configmap cache: timed out ... the condition
22607 nestedpendingoperations.go:335] Operation for "{volumeName:kubernetes.io/configmap/a075c2d0-52d0-4f92-a2db-8b79b5e...7888 +0800 CST
22607 cni.go:240] "Unable to update cni config" err="no networks found in /etc/cni/net.d"
22607 kubelet.go:2391] "Container runtime network not ready" networkReady="NetworkReady=false reason:NetworkPluginNotRea...uninitialized"
Hint: Some lines were ellipsized, use -l to show in full.

还是说报没有安装网络插件的问题。只能说明网络插件安装失败了

查看kube-flannel pod节点状态 Terminating

[root@master k8s]# kubectl get pod -n kube-flannel
NAME                    READY   STATUS        RESTARTS   AGE
kube-flannel-ds-v8xw5   0/1     Terminating   0          33m

查看 kube-flannel 启动过程 看Events事件

[root@master k8s]# kubectl describe pod -n kube-flannel

Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  42s   default-scheduler  Successfully assigned kube-flannel/kube-flannel-ds-z45kj to master
  Normal  Pulled     42s   kubelet            Container image "docker.io/rancher/mirrored-flannelcni-flannel-cni-plugin:v1.1.0" already present on machine
  Normal  Created    42s   kubelet            Created container install-cni-plugin
  Normal  Started    42s   kubelet            Started container install-cni-plugin
  Normal  Pulling    41s   kubelet            Pulling image "docker.io/rancher/mirrored-flannelcni-flannel:v0.20.0"

发现在 pulling image “docker.io/rancher/mirrored-flannelcni-flannel:v0.20.0” 这个地方一直卡着。

原因是这是一个国外的镜像访问不了,有点慢。想办法替换其它可以下载的镜像

搜索一下

[root@master k8s]# docker search flannel
NAME                                  DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
jmgao1983/flannel                     from quay.io/coreos/flannel                     10                   [OK]
lizhenliang/flannel                                                                   4
easzlab/flannel                       from quay.io/coreos/flannel                     4
sigwindowstools/flannel                                                               3
flannelcni/flannel                    primary images from https://github.com/flann…   2
winjay/flannel                                                                        1
flannelcni/flannel-cni-plugin         Flannel CNI plugin images as built from: htt…   1
jasonbrooks/flannel                   flannel system container                        1                    [OK]                                                          

选择拉取一个 jmgao1983/flannel 与 lizhenliang/flannel 都行

docker pull jmgao1983/flannel

在线编辑 kube-flannel.yml

kubectl edit -f kube-flannel.yml

	initContainers:
      - name: install-cni-plugin
       #image: flannelcni/flannel-cni-plugin:v1.1.0 for ppc64le and mips64le (dockerhub limitations may apply)
        image: docker.io/rancher/mirrored-flannelcni-flannel-cni-plugin:v1.1.0
        command:
        - cp
        args:
        - -f
        - /flannel
        - /opt/cni/bin/flannel
        volumeMounts:
        - name: cni-plugin
          mountPath: /opt/cni/bin
      - name: install-cni
       #image: flannelcni/flannel:v0.20.0 for ppc64le and mips64le (dockerhub limitations may apply)
        image: jmgao1983/flannel
        command:
        - cp
        args:
        - -f
        - /etc/kube-flannel/cni-conf.json
        - /etc/cni/net.d/10-flannel.conflist
        volumeMounts:
        - name: cni
          mountPath: /etc/cni/net.d
        - name: flannel-cfg
          mountPath: /etc/kube-flannel/
      containers:
      - name: kube-flannel
       #image: flannelcni/flannel:v0.20.0 for ppc64le and mips64le (dockerhub limitations may apply)
        image: jmgao1983/flannel

将 docker.io/rancher/mirrored-flannelcni-flannel:v0.20.0 换成 jmgao1983/flannel

再次查看

kubectl describe pod -n kube-flannel

看到 Started container kube-flannel 表示启动成功

Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  42s   default-scheduler  Successfully assigned kube-flannel/kube-flannel-ds-lg6th to master
  Normal  Pulled     42s   kubelet            Container image "docker.io/rancher/mirrored-flannelcni-flannel-cni-plugin:v1.1.0" already present on machine
  Normal  Created    42s   kubelet            Created container install-cni-plugin
  Normal  Started    42s   kubelet            Started container install-cni-plugin
  Normal  Pulling    41s   kubelet            Pulling image "jmgao1983/flannel"
  Normal  Pulled     24s   kubelet            Successfully pulled image "jmgao1983/flannel" in 17.43224951s
  Normal  Created    24s   kubelet            Created container install-cni
  Normal  Started    24s   kubelet            Started container install-cni
  Normal  Pulling    23s   kubelet            Pulling image "jmgao1983/flannel"
  Normal  Pulled     2s    kubelet            Successfully pulled image "jmgao1983/flannel" in 20.788409144s
  Normal  Created    2s    kubelet            Created container kube-flannel
  Normal  Started    2s    kubelet            Started container kube-flannel

再次查看nodes状态

[root@master k8s]# kubectl get pod -n kube-flannel
NAME                    READY   STATUS    RESTARTS   AGE
kube-flannel-ds-lg6th   1/1     Running   0          11m
[root@master k8s]# kubectl get nodes
NAME     STATUS   ROLES                  AGE   VERSION
master   Ready    control-plane,master   88m   v1.23.9

你可能感兴趣的:(k8s,kubernetes,网络,docker)