<p>Before kubeadm I use these steps to take flannel ip  &amp; mtu value to docker.</p>

<p>Step 1: stop Docker and Flannel<br>
Step 2: start Flannel and check its status;<br>
step 3: update Docker startup script like this</p>

<pre><code>source /run/flannel/subnet.env
--bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU} 
</code></pre>

<p>Step 4: start Docker and check its status.</p>

<p>How this steps done with <code>kubeadm</code>? I see Docker deamon process start first then Flannel starts as container trying to understate the integration process. </p>

<p>Thanks
SR</p>

<p>Here are the steps I took to set up flannel in Kubernetes v1.7.3.</p>

<p>Install flannel</p>

<pre><code>kubectl create -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel-rbac.yml
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
</code></pre>

<p>You will see the flannel pod created but it falls into a "CrashLoopBackOff" state and restart forever.  </p>

<p>After flannel is installed by Kubeadm, the subnet info will be recorded in file <code>/run/flannel/subnet.env</code>.</p>

<pre><code>cat /run/flannel/subnet.env 
FLANNEL_NETWORK=10.244.0.0/16
FLANNEL_SUBNET=10.244.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true
</code></pre>

<p>Setup these environment variables for docker</p>

<pre><code>mkdir -p /usr/lib/systemd/system/docker.service.d
sudo cat &lt;&lt; EOF &gt; /usr/lib/systemd/system/docker.service.d/flannel.conf
[Service]
EnvironmentFile=-/run/flannel/docker
EOF

sudo cat &lt;&lt; EOF &gt; /run/flannel/docker
DOCKER_OPT_BIP="--bip=10.244.0.1/24"
DOCKER_OPT_IPMASQ="--ip-masq=false"
DOCKER_OPT_MTU="--mtu=1450"
DOCKER_NETWORK_OPTIONS=" --bip=10.244.0.1/24 --ip-masq=false --mtu=1450" 
</code></pre>

<p><strong><em>Note: do set ip-masq as false for docker, otherwise kube-dns would not work well.</em></strong> </p>

<p>Reload the service configuration, then the changes will take effect.</p>

<pre><code>sudo systemctl daemon-reload`
</code></pre>

<p>Voila, everything works after that.</p>
