<p>I hope someone can enlighten me on Kubernetes network setup. I want to use flannel as the Kubernetes network layer.</p>

<p>I'm on Kubernetes: 1.5.5 btw.</p>

<p>The problem is, there are so many places you can(should?) define a cidr, I'm not seeing the woods for the trees anymore.</p>

<p>To give you some info about my setup:</p>

<ul>
<li>my hosts are deployed in the 10.9.0.0/24 range.</li>
<li>I want to use 10.254.0.0/16 as the flannel range</li>
<li>at the moment, docker on the worker nodes uses the 172.17.0.0/16 range</li>
</ul>

<p>kube-apiserver has the following options for cidr's:</p>

<pre><code>--service-cluster-ip-range
</code></pre>

<p>kube-controller-manager has the following options for cidr's:</p>

<pre><code>--cluster-cidr
--service-cluster-ip-range
</code></pre>

<p>what's the difference between those two?</p>

<p>kube-proxy has this one:</p>

<pre><code>--cluster-cidr={{ kubernetes_cluster_cidr }}
</code></pre>

<p>what ip range goes where exactly?</p>

<p>Actually, you have 2 different network layers there:</p>

<ul>
<li>Cluster-cidr: the pods layer (where you want to use 10.254.0.0/16):
Once you have your flannel network up and running, you will have to configure Docker to use it (via systemd drop-in or with something like:
<code>echo "DOCKER_OPTS="--bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}"" &gt;&gt; /etc/default/docker</code>). This way all the "docker0" interfaces in your cluster will be connected within the flannel network.</li>
<li>Service-cluster-ip-range: the <a href="https://kubernetes.io/docs/user-guide/services/" rel="nofollow noreferrer">service</a> layer. Services are used to abstract a logical set of pods. As long as you don't know where a pod is going to be located, or the IP that is going to be assigned to it... You need some kind of abstraction to reach a pod/set of pods, wherever they are.</li>
</ul>

<blockquote>
  <p>A Kubernetes Service is an abstraction which defines a logical set of Pods and a policy by which to access them - sometimes called a micro-service. The set of Pods targeted by a Service is (usually) determined by a Label Selector (see below for why you might want a Service without a selector).
  As an example, consider an image-processing backend which is running with 3 replicas. Those replicas are fungible - frontends do not care which backend they use. While the actual Pods that compose the backend set may change, the frontend clients should not need to be aware of that or keep track of the list of backends themselves. The Service abstraction enables this decoupling.</p>
</blockquote>

<p>NOTE: The service layer must not overlap with your cluster pods network (flannel) or any other existing network infrastructure.</p>
