Kubernetes flannel pod getting the wrong network Flannel running in a pod is getting the wrong subnet and networking is just not happy, the symptom is flannel is being assigned /24's from the 10.105.0.0/16. it should be assigning /26's from 10.105.5.128/21. Thanks for any help.  

here are the details:

/usr/bin/kubeadm init \
--kubernetes-version v1.7.5 \
--pod-network-cidr 10.105.5.128/21 \
--service-cidr 10.105.5.136/21 \
--token XXXXXXXXXXX


kube-flannel-rbac.yml is loaded after kube-flannel.yml
only modified bit(SubenetLen and Network) from kube-flannel.yml:

{
  "Network": "10.105.5.128/21",
  "SubnetLen": 26,
  "Backend": {
    "Type": "vxlan"
  }
}


DNS is set in the systemd file to:

--cluster-dns=10.105.5.136.10


Using Ubuntu 16.04 LTS and stock kernel

here is the docker daemon.json file:

{
"hosts":[
    "fd://",
    "0.0.0.0"
],
"ip-masq":false,
    "experimental": true,
"registry-mirrors": [
    "http://hub.xyz.com"
],
"insecure-registries": [
    "http://hub.xyz.com"
],
"tls": true,
"tlsverify": true,
"tlscacert":"/etc/docker/ca.pem",
"tlscert":"/etc/docker/cert.pem",
"tlskey":"/etc/docker/key.pem"
}


all kuberentes components are 1.7.5 installed from ubuntu k8s repos

here is the log of the kube-flannel container: 

I0926 03:29:10.214198      89 main.go:446] Determining IP address of default interface
I0926 03:29:10.216166      89 main.go:459] Using interface with name eth0 and address 10.105.5.12
I0926 03:29:10.216261      89 main.go:476] Defaulting external address to interface address (10.105.5.12)
I0926 03:29:10.242216      89 kube.go:283] Starting kube subnet manager
I0926 03:29:10.242055      89 kube.go:130] Waiting 10m0s for node controller to sync
I0926 03:29:11.242864      89 kube.go:137] Node controller sync successful
I0926 03:29:11.242957      89 main.go:226] Created subnet manager: Kubernetes Subnet Manager - kube-m2.XXXXX.com
I0926 03:29:11.242969      89 main.go:229] Installing signal handlers
I0926 03:29:11.243984      89 main.go:330] Found network config - Backend type: vxlan
I0926 03:29:11.288902      89 ipmasq.go:51] Adding iptables rule: -s 10.105.0.0/21 -d 10.105.0.0/21 -j RETURN
I0926 03:29:11.306692      89 ipmasq.go:51] Adding iptables rule: -s 10.105.0.0/21 ! -d 224.0.0.0/4 -j MASQUERADE
I0926 03:29:11.314413      89 ipmasq.go:51] Adding iptables rule: ! -s 10.105.0.0/21 -d 10.105.0.0/24 -j RETURN
I0926 03:29:11.323229      89 ipmasq.go:51] Adding iptables rule: ! -s 10.105.0.0/21 -d 10.105.0.0/21 -j MASQUERADE
I0926 03:29:11.329676      89 main.go:279] Wrote subnet file to /run/flannel/subnet.env
I0926 03:29:11.329746      89 main.go:284] Finished starting backend.
I0926 03:29:11.329829      89 vxlan_network.go:56] Watching for L3 misses
I0926 03:29:11.329903      89 vxlan_network.go:64] Watching for new subnet leases
You have either a bad understanding or misconception about how a cidr works.

10.105.5.128/21 is just one address in the range 10.105.0.0 - 10.105.7.255.
So either your cidr bits are not the one you're expecting, 10.105.5.128/26 would be a valid network definition but that's a /26 subnet within the 10.105.0.0/21, or you're not using the proper network definition.

You can check those division on this very helping site (the link already use your networks above.