【问题标题】:Kubernetes V1.6.2 unable to update cni config: No networks found in /etc/cni/net.dKubernetes V1.6.2 无法更新 cni 配置:在 /etc/cni/net.d 中找不到网络
【发布时间】:2017-09-28 12:55:04
【问题描述】:

基于这个 (https://kubernetes.io/docs/getting-started-guides/kubeadm/) 步骤,我在 Centos 7 中安装了 Kubernetes 并执行 kubeadm init 命令。

但节点未处于就绪状态。当我查看 /var/log/messages.收到以下消息。

Apr 30 22:19:38 master kubelet: W0430 22:19:38.226441    2372 cni.go:157] Unable to update cni config: No networks found in /etc/cni/net.d
Apr 30 22:19:38 master kubelet: E0430 22:19:38.226587    2372 kubelet.go:2067] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized

我的 kubelet 使用这些参数运行。

 /usr/bin/kubelet --kubeconfig=/etc/kubernetes/kubelet.conf --require-kubeconfig=true --pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true --network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin --cluster-dns=10.96.0.10 --cluster-domain=cluster.local --authorization-mode=Webhook --client-ca-file=/etc/kubernetes/pki/ca.crt --cgroup-driver=systemd

在我的服务器中,我没有看到 /etc/cni/net.d 目录。在 /opt/cin/bin 目录中,我看到了这些文件。

# ls  /opt/cni/bin
bridge  cnitool  dhcp  flannel  host-local  ipvlan  loopback  macvlan  noop  ptp  tuning

如何清除此错误消息?

【问题讨论】:

    标签: kubernetes


    【解决方案1】:

    看起来您已选择法兰绒作为 CNI 网络。 请检查您是否在 kubeadm 初始化时指定了 --pod-network-cidr 10.244.0.0/16。

    同时检查你是否为法兰绒创建了 ConfigMap,就像这里 @https://github.com/coreos/flannel/blob/master/Documentation/kube-flannel.yml

    【讨论】:

    【解决方案2】:

    如果您在 AWS ...我使用的是 Cloud Formation yaml,建议您将 Kubernetes 版本的 AMI 与 Region+ID 匹配:

    Kubernetes 版本 1.13.8 地区:美国东部(弗吉尼亚北部) (us-east-1) Amazon EKS 优化的 AMI:ami-0d3998d69ebe9b214

    然后应用您的映射:

    kubectl apply -f aws-auth-cm.yaml
    

    那就看魔术吧:

    kubectl get nodes --watch
    

    https://docs.aws.amazon.com/eks/latest/userguide/launch-workers.html

    【讨论】:

      【解决方案3】:

      我认为这个问题是由 kuberadm 首先 init coredns 而不是 init flannel 引起的,所以它抛出“network plugin is not ready: cni config uninitialized”。
      解决方案:
      1.通过kubectl -n kube-system apply -f https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml安装法兰绒
      2. 重置 coredns pod
      kubectl delete coredns-xx-xx
      3.然后运行kubectl get pods看看是否有效。

      如果您看到此错误“cni0”已经具有不同于 10.244.1.1/24 的 IP 地址。 按照这个:

      ifconfig  cni0 down
      brctl delbr cni0
      ip link delete flannel.1
      

      如果你看到这个错误“Back-off restarting failed container”,你可以通过

      root@master:/home/moonx/yaml# kubectl logs coredns-86c58d9df4-x6m9w -n=kube-system
      .:53
      2019-01-22T08:19:38.255Z [INFO] CoreDNS-1.2.6
      2019-01-22T08:19:38.255Z [INFO] linux/amd64, go1.11.2, 756749c
      CoreDNS-1.2.6
      linux/amd64, go1.11.2, 756749c
       [INFO] plugin/reload: Running configuration MD5 = f65c4821c8a9b7b5eb30fa4fbc167769
       [FATAL] plugin/loop: Forwarding loop detected in "." zone. Exiting. See https://coredns.io/plugins/loop#troubleshooting. Probe query: "HINFO 1599094102175870692.6819166615156126341.".
      

      然后你可以在失败的节点上看到文件“/etc/resolv.conf”,如果nameserver是localhost会有一个loopback。改成:

      #nameserver 127.0.1.1
      nameserver 8.8.8.8
      

      github issue

      【讨论】:

        【解决方案4】:

        以上解决方案均不适合我。 我发现我的服务器没有默认路由!

        # route -n
        169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlp9s0
        172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
        

        所以我通过以下命令添加了默认网关:

        # route add default gw 19.168.1.1
        # route -n 
        0.0.0.0         192.168.1.1     0.0.0.0         UG    600    0        0 wlp9s0
        169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlp9s0
        172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
        

        现在iptables 工作正常

        【讨论】:

          猜你喜欢
          • 2020-01-03
          • 1970-01-01
          • 2020-12-17
          • 1970-01-01
          • 2018-04-15
          • 2023-02-21
          • 2019-04-17
          • 2017-03-02
          • 2019-02-28
          相关资源
          最近更新 更多