0

在 kubernetes 中使用 flannel 作为 CNI 我正在尝试实现一个网络,以便在不同的 vagrant vm 上传播 pod 到 pod 的通信。我正在使用这个https://raw.githubusercontent.com/coreos/flannel/v0.9.0/Documentation/kube-flannel.yml来创建法兰绒豆荚。但是 kube-flannel pod 出现 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 的确切原因是什么,解决方案是什么?

4

2 回答 2

0

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

我的 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

于 2019-02-23T14:42:22.120 回答
0

我能够通过运行命令来解决问题

kubectl annotate node appserv9 flannel.alpha.coreos.com/public-ip=10.10.10.10 --overwrite=true

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

你给什么 ip 并不重要,但是这个命令必须在所有节点上单独运行,这样上述错误就不必分配给nil映射。

于 2018-03-28T09:22:14.963 回答