Public Repository

Last pushed: 2 years ago
Short Description
Run container
Full Description

Single etcd server:

-

docker run -d --name <container name> -p 4001:4001 -v <logs and snapshots directory>:/data vandersex/etcd

Etcd cluster:

  • Run etcd nodes:
  • docker run -d --name etcd-node1 -h etcd-node1 -p 4001:4001 -p 7001:7001 vandersex/etcd \
    ./etcd \
    -listen-client-urls http://0.0.0.0:4001 \
    -advertise-client-urls http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):4001 \
    -name etcd-node1 \
    -initial-advertise-peer-urls http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7001 \
    -listen-peer-urls http://0.0.0.0:7001 \
    -initial-cluster-token pathfinder-etcd-cluster \
    -initial-cluster etcd-node1=http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7001,etcd-node2=http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7002,etcd-node3=http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7003 \
    -initial-cluster-state new
    
    docker run -d --name etcd-node2 -h etcd-node2 -p 4002:4002 -p 7002:7002 vandersex/etcd \
    ./etcd \
    -listen-client-urls http://0.0.0.0:4002 \
    -advertise-client-urls http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):4002 \
    -name etcd-node2 \
    -initial-advertise-peer-urls http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7002 \
    -listen-peer-urls http://0.0.0.0:7002 \
    -initial-cluster-token pathfinder-etcd-cluster \
    -initial-cluster etcd-node1=http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7001,etcd-node2=http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7002,etcd-node3=http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7003 \
    -initial-cluster-state new
    
    docker run -d --name etcd-node3 -h etcd-node3 -p 4003:4003 -p 7003:7003 vandersex/etcd \
    ./etcd \
    -listen-client-urls http://0.0.0.0:4003 \
    -advertise-client-urls http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):4003 \
    -name etcd-node3 \
    -initial-advertise-peer-urls http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7003 \
    -listen-peer-urls http://0.0.0.0:7003 \
    -initial-cluster-token pathfinder-etcd-cluster \
    -initial-cluster etcd-node1=http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7001,etcd-node2=http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7002,etcd-node3=http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7003 \
    -initial-cluster-state new
    
  • Run etcd proxy:

  • docker run -d --name etcd-proxy -h etcd-proxy -p 8080:8080 vandersex/etcd \
    ./etcd \
    -proxy on \
    -bind-addr 0.0.0.0:8080 \
    -initial-cluster etcd-node1=http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7001,etcd-node2=http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7002,etcd-node3=http://$(ifconfig eth0 | perl -nle'/dr:(\S+)/ && print $1'):7003
    

Now you can write a key to the cluster and retrieve the value from proxy or any member .

Docker Pull Command
Owner
vandersex