flannel-io / flannel

flannel is a network fabric for containers, designed for Kubernetes
Apache License 2.0
8.61k stars 2.87k forks source link

Docker integration create network got error invalid network config #1949

Open aleccai8 opened 2 months ago

aleccai8 commented 2 months ago

Expected Behavior

network should create sucessfully

Current Behavior

root@docker:~/daemonset# docker network create --attachable=true --subnet=${FLANNEL_SUBNET} -o "com.docker.network.driver.mtu"=${FLANNEL_MTU} flannel
Error response from daemon: invalid network config:
invalid subnet 10.0.35.1/24: it should be 10.0.35.0/24

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context

flannel logs: I0418 21:49:50.510214 90815 main.go:210] CLI flags config: {etcdEndpoints:http://127.0.0.1:4001,http://127.0.0.1:2379 etcdPrefix:/coreos.com/network etcdKeyfile: etcdCertfile: etcdCAFile: etcdUsername: etcdPassword: version:false kubeSubnetMgr:false kubeApiUrl: kubeAnnotationPrefix:flannel.alpha.coreos.com kubeConfigFile: iface:[] ifaceRegex:[] ipMasq:false ifaceCanReach: subnetFile:/run/flannel/subnet.env publicIP: publicIPv6: subnetLeaseRenewMargin:60 healthzIP:0.0.0.0 healthzPort:0 iptablesResyncSeconds:5 iptablesForwardRules:true netConfPath:/etc/kube-flannel/net-conf.json setNodeNetworkUnavailable:true} W0418 21:49:50.510914 90815 main.go:530] no subnet found for key: FLANNEL_IPV6_SUBNET in file: /run/flannel/subnet.env W0418 21:49:50.511178 90815 registry.go:84] no certificate provided: connecting to etcd with http. This is insecure I0418 21:49:50.513636 90815 main.go:230] Created subnet manager: Etcd Local Manager with Previous Subnet: 10.0.35.0/24 I0418 21:49:50.513667 90815 main.go:233] Installing signal handlers I0418 21:49:50.517323 90815 main.go:442] Found network config - Backend type: vxlan I0418 21:49:50.517368 90815 match.go:210] Determining IP address of default interface I0418 21:49:50.518324 90815 match.go:263] Using interface with name eth0 and address 192.168.2.6 I0418 21:49:50.518363 90815 match.go:285] Defaulting external address to interface address (192.168.2.6) I0418 21:49:50.518441 90815 vxlan.go:141] VXLAN config: VNI=1 Port=0 GBP=false Learning=false DirectRouting=false I0418 21:49:50.521383 90815 local_manager.go:154] Found lease (ip: 10.0.35.0/24 ipv6: ::/0) for current IP (192.168.2.6), reusing I0418 21:49:50.524366 90815 main.go:567] Starting flannel in iptables mode I0418 21:49:50.524412 90815 iptables.go:224] Changing default FORWARD chain policy to ACCEPT I0418 21:49:50.533041 90815 main.go:386] Wrote subnet file to /run/flannel/subnet.env I0418 21:49:50.533075 90815 main.go:390] Running backend. I0418 21:49:50.533153 90815 vxlan_network.go:65] watching for new subnet leases I0418 21:49:50.535157 90815 registry.go:291] registry: watching subnets starting from rev 10 I0418 21:49:50.535195 90815 local_manager.go:318] manager.WatchLease: sending reset results... I0418 21:49:50.535273 90815 local_manager.go:395] Waiting for 22h59m58.999911093s to renew lease I0418 21:49:50.569849 90815 iptables.go:370] bootstrap done

Your Environment

rbrtbnfgl commented 2 months ago

It seems that Docker doesn't like the subnet specified with the first address. You could try to edit /run/flannel/subnet.env and change 10.0.35.1/24 with 10.0.35.0/24