Skip to content

Instantly share code, notes, and snippets.

@wdalmut
Created July 11, 2017 20:00
Show Gist options
  • Save wdalmut/85005f555b0d75fd2b7b78cd68edb489 to your computer and use it in GitHub Desktop.
Save wdalmut/85005f555b0d75fd2b7b78cd68edb489 to your computer and use it in GitHub Desktop.
CoreOS + Docker Swarm
sudo mkdir /etc/systemd/system/docker.service.d/
sudo vim /etc/systemd/system/docker.service.d/cluster.conf
[Service]
Environment="DOCKER_OPTS=--cluster-advertise=10.0.0.2:2375 --cluster-store=etcd://10.0.0.2:2379 --host=tcp://10.0.0.2:2375"
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl enable docker
docker run -d --restart always --name swarm swarm join --addr 10.0.0.5:2375 etcd://10.0.0.5:2379
docker run -d --restart always --name swarm-manager -p 3375:3375 swarm manage -H=tcp://0.0.0.0:3375 etcd://10.0.0.4:2379
#run as swarm manager docker host
docker network create --driver overlay --subnet 10.0.1.0/24 cluster-network
# on the first node, set the cloud data to be
#cloud-config
coreos:
etcd2:
advertise-client-urls: http://$private_ipv4:2379
initial-advertise-peer-urls: http://$private_ipv4:2380
listen-client-urls: http://0.0.0.0:2379
listen-peer-urls: http://$private_ipv4:2380
name: node-a
initial-cluster-state: new
initial-cluster: node-a=http://$private_ipv4:2380
units:
- name: etcd2.service
command: start
# on the second node set the cloud data to be
#cloud-config
coreos:
etcd2:
advertise-client-urls: http://$private_ipv4:2379
initial-advertise-peer-urls: http://$private_ipv4:2380
listen-client-urls: http://0.0.0.0:2379
listen-peer-urls: http://$private_ipv4:2380
name: node-b
initial-cluster-state: existing
initial-cluster: node-a=http://10.0.0.2:2380,node-b=http://$private_ipv4:2380
units:
- name: etcd2.service
command: start
# Once both nodes are running, run this on node-a
etcdctl member add node-b http://10.0.0.3:2380
# then restart etcd2 on node-b
sudo systemctl start etcd2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment