kubeadm docker flannel integration

6/4/2017

Before kubeadm I use these steps to take flannel ip & mtu value to docker.

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

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

Step 4: start Docker and check its status.

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

Thanks SR

-- sfgroups
docker
flannel
kubeadm
kubernetes

1 Answer

8/9/2017

Here are the steps I took to set up flannel in Kubernetes v1.7.3.

Install flannel

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

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

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

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

Setup these environment variables for docker

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

sudo cat << EOF > /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" 

Note: do set ip-masq as false for docker, otherwise kube-dns would not work well.

Reload the service configuration, then the changes will take effect.

sudo systemctl daemon-reload`

Voila, everything works after that.

-- ichbinblau
Source: StackOverflow