Skip to content

Instantly share code, notes, and snippets.

@krotkiewicz
Created February 3, 2018 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krotkiewicz/682068325ef05d16df68d27cb66e9cb3 to your computer and use it in GitHub Desktop.
Save krotkiewicz/682068325ef05d16df68d27cb66e9cb3 to your computer and use it in GitHub Desktop.
4.sh
root@node $ export MASTER_IP=10.135.53.41
root@node $ export NODE_IP=10.135.53.41
root@node $ wget -q --show-progress https://github.com/coreos/flannel/releases/download/v0.6.2/flannel-v0.6.2-linux-amd64.tar.gz
flannel-v0.6.2-linux-amd64.tar.gz.1 100%[==================================================================================================================================>] 4.51M 1.15MB/s in 3.9s
root@node $ tar xzf flannel-v0.6.2-linux-amd64.tar.gz
root@node $ mv flanneld mk-docker-opts.sh /usr/local/bin/
root@node $ etcdctl -C http://$MASTER_IP:2379 set /coreos.com/network/config '{"Network": "10.0.0.0/8", "SubnetLen": 20, "SubnetMin": "10.10.0.0","SubnetMax": "10.99.0.0","Backend": {"Type": "vxlan","VNI": 100,"Port": 8472}}'
root@node $ flanneld -iface=$NODE_IP -etcd-endpoints http://$MASTER_IP:2379 &> /tmp/flanneld.log &
root@node $ mk-docker-opts.sh -d /etc/default/docker
root@node $ service docker restart
root@node2 $ export MASTER_IP=10.135.53.41
root@node2 $ export NODE_IP=10.135.40.58
root@node2 $ wget -q --show-progress https://github.com/coreos/flannel/releases/download/v0.6.2/flannel-v0.6.2-linux-amd64.tar.gz
flannel-v0.6.2-linux-amd64.tar.gz 100%[==================================================================================================================================>] 4.51M 1.04MB/s in 4.5s
root@node2 $ tar xzf flannel-v0.6.2-linux-amd64.tar.gz
root@node2 $ mv flanneld mk-docker-opts.sh /usr/local/bin/
root@node2 $ flanneld -iface=$NODE_IP -etcd-endpoints http://$MASTER_IP:2379 &> /tmp/flanneld.log &
root@node2 $ mk-docker-opts.sh -d /etc/default/docker
root@node2 $ service docker restart
@TodayyadoT
Copy link

Hi, I followed your post Kubernetes From Scratch and came here, I met an issue that my pods still got the primary duplicated IPs after executing all the command above:

[root@worker1 tmp]# kubectl get po -o wide
NAME                     READY     STATUS    RESTARTS   AGE       IP           NODE
nginx                    1/1       Running   5          18h       172.17.0.3   worker1
nginx-1423793266-14wnd   1/1       Running   3          1h        172.17.0.3   worker2
nginx-1423793266-6gj7z   1/1       Running   5          18h       172.17.0.6   worker1
nginx-1423793266-9wgpx   1/1       Running   5          18h       172.17.0.5   worker1
nginx-1423793266-dp4n4   1/1       Running   5          18h       172.17.0.4   worker1
nginx-1423793266-kz7wg   1/1       Running   3          1h        172.17.0.4   worker2
nginx-1423793266-zt70f   1/1       Running   3          1h        172.17.0.2   worker2
nginx2                   1/1       Running   5          18h       172.17.0.2   worker1

And here is the log of flannel:

[root@worker1 tmp]# cat /tmp/flanneld.log
I0517 03:09:46.433560 16933 main.go:126] Installing signal handlers
I0517 03:09:46.434028 16933 manager.go:163] Using 192.168.205.31 as external interface
I0517 03:09:46.434049 16933 manager.go:164] Using 192.168.205.31 as external endpoint
I0517 03:09:46.437675 16933 local_manager.go:134] Found lease (10.15.208.0/20) for current IP (192.168.205.31), reusing
I0517 03:09:46.441891 16933 manager.go:246] Lease acquired: 10.15.208.0/20
I0517 03:09:46.442554 16933 network.go:58] Watching for L3 misses
I0517 03:09:46.442574 16933 network.go:66] Watching for new subnet leases
I0517 03:09:46.445926 16933 network.go:153] Handling initial subnet events
I0517 03:09:46.445942 16933 device.go:163] calling GetL2List() dev.link.Index: 53
I0517 03:09:46.446016 16933 network.go:160] fdb already populated with: 192.168.205.32 3e:1f:bc:35:19:69
I0517 03:09:46.446030 16933 network.go:160] fdb already populated with: 10.0.2.15 be:1f:3b:aa:b7:a1
I0517 03:09:46.440129 10275 network.go:112] Subnet added: 10.15.208.0/20
I0517 03:09:46.440156 10275 device.go:168] caI0517 03:09:46.440616 09837 network.go:112] Subnet added: 10.15.208.0/20
I0517 03:09:46.440639 09837 device.go:168] calling NeighAdd: 192.168.205.31, ca:0d:c7:8b:38:b3

I used centos7 so I changed mk-docker-opts.sh -d /etc/default/docker to my default path /ets/sysconfig/docker.
In fact I didn't understand this two command: etcdctl -C ... and flanneld ...
What's the probable cause this issue?

@TodayyadoT
Copy link

Haha, I have found the reason, it's caused by docker, I used the latest docker 1.13.1.
It specifies config in /etc/docker/daemon.json like this:
{
"bip": "10.15.208.0/20",
"mtu": 1500
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment