Skip to content

Instantly share code, notes, and snippets.

@dbathgate
Last active April 20, 2021 18:39
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 dbathgate/737e8d800decde9adbf8a0130870bcc4 to your computer and use it in GitHub Desktop.
Save dbathgate/737e8d800decde9adbf8a0130870bcc4 to your computer and use it in GitHub Desktop.
Basic flannel and etcd setup
#!/bin/bash
###### Install and run Etcd #############
curl --location https://github.com/coreos/etcd/releases/download/v3.1.5/etcd-v3.1.5-linux-amd64.tar.gz | tar -xz
cp etcd-v3.1.5-linux-amd64/etcd /usr/local/bin/
cp etcd-v3.1.5-linux-amd64/etcdctl /usr/local/bin/
mkdir /var/lib/etcd
nohup etcd --data-dir=/var/lib/etcd/ --listen-client-urls=http://192.168.33.11:2379 --advertise-client-urls=http://192.168.33.11:2379 </dev/null >/dev/null 2>&1 &
########################################
#### Configure network #################
etcdctl --endpoint http://192.168.33.11:2379 set /coreos.com/network/config '{ "Network": "10.2.0.0/16", "Backend": { "Type": "vxlan" } }'
########################################
#### Install and run Flannel ############
curl --location https://github.com/coreos/flannel/releases/download/v0.7.0/flanneld-amd64 -o /usr/local/bin/flanneld
chmod +x /usr/local/bin/flanneld
nohup flanneld --ip-masq=true --etcd-endpoints=http://192.168.33.11:2379 --public-ip=192.168.33.11 </dev/null >/dev/null 2>&1 &
########################################
#### Configure Docker ##################
cat >> /etc/sysconfig/docker <<EOF
# Flannel config
. /run/flannel/subnet.env
OPTIONS="\$OPTIONS --bip=\$FLANNEL_SUBNET --mtu=\$FLANNEL_MTU"
EOF
/etc/init.d/docker stop
/etc/init.d/docker start
########################################
@josep112
Copy link

Hello, very good, I have 2 doubts, the first is that I use debian and do not have the / etc / sysconfig / docker folder, should I put it in / etc / default / docker?
Another question is that when I restart the machine the network is lost what do I have to do?

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