Last active
March 1, 2022 06:06
-
-
Save thanhpp/0cb3302b763d1d71768b9bb99ebaface to your computer and use it in GitHub Desktop.
etcd-cluster-example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.9' | |
services: | |
etcd1: | |
container_name: etcd1 | |
build: | |
context: . | |
dockerfile: Dockerfile | |
environment: | |
- NAME=etcd-1 | |
- DATADIR=/etcd-data | |
- HOST=http://etcd1 | |
- CLUSTER=etcd-1=http://etcd1:2380,etcd-2=http://etcd2:2380 | |
- CLUSTERSTATE=new | |
- TOKEN=kvl | |
volumes: | |
- ./etcd-data-1:/etcd-data | |
networks: | |
etcd-network: | |
etcd2: | |
container_name: etcd2 | |
build: | |
context: . | |
dockerfile: Dockerfile | |
environment: | |
- NAME=etcd-2 | |
- DATADIR=/etcd-data | |
- HOST=http://etcd2 | |
- CLUSTER=etcd-1=http://etcd1:2380,etcd-2=http://etcd2:2380 | |
- CLUSTERSTATE=new | |
- TOKEN=kvl | |
volumes: | |
- ./etcd-data-2:/etcd-data | |
networks: | |
etcd-network: | |
networks: | |
etcd-network: | |
# entrypoint: /etcd/etcd-v3.5.2-linux-amd64/etcd | |
# command: | |
# - '--name=s1' | |
# - '--data-dir=/etcd-data' | |
# - '--listen-client-urls=http://0.0.0.0:2379' | |
# - '--advertise-client-urls=http://0.0.0.0:2379' | |
# - '--listen-peer-urls=http://0.0.0.0:2380' | |
# - '--initial-advertise-peer-urls=http://0.0.0.0:2380' | |
# - '--initial-cluster=s1=http://0.0.0.0:2380' | |
# - '--initial-cluster-token=tkn' | |
# - '--initial-cluster-state=new' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine | |
RUN apk update && apk add --no-cache tar | |
WORKDIR /etcd | |
RUN wget https://github.com/etcd-io/etcd/releases/download/v3.5.2/etcd-v3.5.2-linux-amd64.tar.gz | |
RUN tar -xvzf etcd-v3.5.2-linux-amd64.tar.gz | |
RUN rm -f etcd-v3.5.2-linux-amd64.tar.gz | |
WORKDIR /etcd/etcd-v3.5.2-linux-amd64 | |
CMD ./etcd --name ${NAME} \ | |
--data-dir=${DATADIR} \ | |
--initial-advertise-peer-urls ${HOST}:2380 --listen-peer-urls http://0.0.0.0:2380 \ | |
--advertise-client-urls ${HOST}:2379 --listen-client-urls http://0.0.0.0:2379 \ | |
--initial-cluster=${CLUSTER} \ | |
--initial-cluster-token=${TOKEN} \ | |
--initial-cluster-state=${CLUSTERSTATE} | |
# - '--name=s1' | |
# - '--data-dir=/etcd-data' | |
# - '--listen-client-urls=http://0.0.0.0:2379' | |
# - '--advertise-client-urls=http://0.0.0.0:2379' | |
# - '--listen-peer-urls=http://0.0.0.0:2380' | |
# - '--initial-advertise-peer-urls=http://0.0.0.0:2380' | |
# - '--initial-cluster=s1=http://0.0.0.0:2380' | |
# - '--initial-cluster-token=tkn' | |
# - '--initial-cluster-state=new' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment