What are implications of choosing network /16 vs /12 when setting up Flannel and service IPs for Kubernetes?

5/7/2017

I'm in the process of setting up a Kubernetes cluster from scratch. I am looking to install Flannel as part of the installation process. When I look at online guides/examples I can see that it is necessary to configure the Flannel subnetwork.

I can see that some guides (deploying-kubernetes-using-ansible.html) set up the flannel network like this:

{
  "Network": "172.16.0.0/12",
  "SubnetLen": 24,
  "Backend": {
    "Type": "vxlan"
  }
}

whereas another guide here (Kubernetes – simple install on CentOS 7) sets up the network like this:

{"Network":"172.17.0.0/16"}

I am still learning about CIDR notation, so I can see that there are more IP addresses available with the first approach than the second. The second URL states that:

All your kubernetes nodes will be in 3 different subnets at the same time:

External interface subnet: 10.0.1.0/24
Flannel subnet: 172.17.0.0/16 #Do not use existing subnet
Service cluster subnet: 10.10.10.0/24 # Do not use existing subnet

I can see from Wikipedia (Private IPv4 address spaces) that the 172 range is a private address space of up to /12.

The implications of the quote as I see them are:

  • External interface: /24 (set by the network admin) == up to 255 hosts on the external network. This is the max number of nodes in the cluster.
  • Flannel subnet: 172.17.0.0/16 (set by Flannel config) == up to 65535 IPs in the Flannel network. What does this mean?
  • Service cluster: 10.10.10.0/24 (set by KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.10.10.0/24") == up to 255 services in the cluster? (docs here)

What are the practical implications of changing the Flannel config to /12 (or any other number from 12..31)?

Same question for service-cluster-ip-range and how do you deconflict the service IPs from the IPs of pods?

-- John
cidr
flannel
kubernetes

1 Answer

5/10/2017

Actually flannel config Network(/12) must be smaller than SubnetLen (/24).External interface subnet is the subnet of your host. service-cluster-ip-range is the scope of clusterIP which is virtual (default implement by iptables in kubernetes). Iptables and routes conflicts will appear when they have the same ip range. so we should specific different ip range for them.

-- luke
Source: StackOverflow