CrashLoopBackoff中的法兰绒吊舱kubernetes错误

时间:2018-03-27 10:42:16

标签: kubernetes flannel

在kubernetes中使用法兰绒作为CNI我正在尝试实现一个网络,用于在不同的流浪者vms上传播的pod到pod通信。我正在使用这个https://raw.githubusercontent.com/coreos/flannel/v0.9.0/Documentation/kube-flannel.yml来制作法兰绒吊舱。但是kube-flannel豆荚会出现CrashLoopBackOff错误并且无法启动。

[root@flnode-04 ~]# kubectl get pods -o wide --all-namespaces
NAMESPACE         NAME                      READY     STATUS             RESTARTS   AGE       IP              NODE
diamanti-system   collectd-v0.5-flnode-04   1/1       Running            0          3h        192.168.30.14   flnode-04
diamanti-system   collectd-v0.5-flnode-05   1/1       Running            0          3h        192.168.30.15   flnode-05
diamanti-system   collectd-v0.5-flnode-06   1/1       Running            0          3h        192.168.30.16   flnode-06
diamanti-system   provisioner-d4kvf         1/1       Running            0          3h        192.168.30.16   flnode-06
kube-system       kube-flannel-ds-2kqpv     0/1       CrashLoopBackOff   1          18m       192.168.30.14   flnode-04
kube-system       kube-flannel-ds-xgqdm     0/1       CrashLoopBackOff   1          18m       192.168.30.16   flnode-06
kube-system       kube-flannel-ds-z59jz     0/1       CrashLoopBackOff   1          18m       192.168.30.15   flnode-05

这是一个pod的日志

[root@flnode-04 ~]# kubectl logs kube-flannel-ds-2kqpv --namespace=kube-system 
I0327 10:28:44.103425       1 main.go:483] Using interface with name mgmt0 and address 192.168.30.14
I0327 10:28:44.105609       1 main.go:500] Defaulting external address to interface address (192.168.30.14)
I0327 10:28:44.138132       1 kube.go:130] Waiting 10m0s for node controller to sync
I0327 10:28:44.138213       1 kube.go:283] Starting kube subnet manager
I0327 10:28:45.138509       1 kube.go:137] Node controller sync successful
I0327 10:28:45.138588       1 main.go:235] Created subnet manager: Kubernetes Subnet Manager - flnode-04
I0327 10:28:45.138596       1 main.go:238] Installing signal handlers
I0327 10:28:45.138690       1 main.go:348] Found network config - Backend type: vxlan
I0327 10:28:45.138767       1 vxlan.go:119] VXLAN config: VNI=1 Port=0 GBP=false DirectRouting=false
panic: assignment to entry in nil map
goroutine 1 [running]:
github.com/coreos/flannel/subnet/kube.(*kubeSubnetManager).AcquireLease(0xc420010cd0, 0x7f5314399bd0, 0xc420347880, 0xc4202213e0, 0x6, 0xf54, 0xc4202213e0)
    /go/src/github.com/coreos/flannel/subnet/kube/kube.go:239 +0x1f7
github.com/coreos/flannel/backend/vxlan.(*VXLANBackend).RegisterNetwork(0xc4200b3480, 0x7f5314399bd0, 0xc420347880, 0xc420010c30, 0xc4200b3480, 0x0, 0x0, 0x4d0181)
    /go/src/github.com/coreos/flannel/backend/vxlan/vxlan.go:141 +0x44e
main.main()
    /go/src/github.com/coreos/flannel/main.go:278 +0x8ae

法兰绒吊舱进入CrashLoopBackoff的原因究竟是什么?解决方案是什么?

2 个答案:

答案 0 :(得分:0)

我能够通过运行命令

来解决问题
kubectl annotate node appserv9 flannel.alpha.coreos.com/public-ip=10.10.10.10 --overwrite=true

错误原因:代码中的nil映射(无密钥可用)

您提供的ip无关紧要,但必须在所有节点上单独运行此命令,以便上述错误不必分配给 nil 映射。

答案 1 :(得分:0)

如果使用kubeadm init --pod-network-cidr network/mask部署群集,则此network/mask应该与kube-flannel.yaml中的ConfigMap匹配

我的ConfigMap看起来像:

kind: ConfigMap
apiVersion: v1
metadata:
  name: kube-flannel-cfg
  namespace: kube-system
  data:
  ...
    net-conf.json: |
      {
        "Network": "10.244.0.0/16",
        "Backend": {
          "Type": "vxlan"
        }
      }

所以network/mask应该等于10.244.0.0/16