From aaeb818c3d9cad226b64c956e0e6d36187ee4a0c Mon Sep 17 00:00:00 2001 From: Anthony Yeh Date: Fri, 10 Jul 2015 16:29:13 -0700 Subject: [PATCH] Update Docker/Kubernetes configs to etcd v2.0.13. --- docker/etcd-lite/Dockerfile | 8 +------ docker/etcd-lite/build.sh | 4 ++-- docker/etcd/Dockerfile | 6 +++--- .../kubernetes/etcd-controller-template.yaml | 21 ++++++++++++++----- examples/kubernetes/etcd-up.sh | 14 +++++++++---- 5 files changed, 32 insertions(+), 21 deletions(-) diff --git a/docker/etcd-lite/Dockerfile b/docker/etcd-lite/Dockerfile index f1605f8e5d..b1ce0a99c9 100644 --- a/docker/etcd-lite/Dockerfile +++ b/docker/etcd-lite/Dockerfile @@ -1,11 +1,5 @@ # This image is only meant to be built from within the build.sh script. FROM debian:wheezy -# Install dependencies -RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - curl \ - && rm -rf /var/lib/apt/lists/* - # Copy binaries (placed by build.sh) -COPY base/etcd /usr/bin/ +COPY base/etcd base/etcdctl /usr/bin/ diff --git a/docker/etcd-lite/build.sh b/docker/etcd-lite/build.sh index 4ef8c0ca1f..7e8537e9bf 100755 --- a/docker/etcd-lite/build.sh +++ b/docker/etcd-lite/build.sh @@ -5,10 +5,10 @@ # Extract files from vitess/etcd image mkdir base -sudo docker run -ti --rm -v $PWD/base:/base -u root vitess/etcd:v0.4.6 bash -c 'cp -R /go/bin/etcd /base/' +sudo docker run -ti --rm -v $PWD/base:/base -u root vitess/etcd:v2.0.13 bash -c 'cp -R /go/bin/etcd /go/bin/etcdctl /base/' # Build vitess/etcd-lite image -sudo docker build -t vitess/etcd:v0.4.6-lite . +sudo docker build -t vitess/etcd:v2.0.13-lite . # Clean up temporary files sudo rm -rf base diff --git a/docker/etcd/Dockerfile b/docker/etcd/Dockerfile index 22edebac9e..f8061fefef 100644 --- a/docker/etcd/Dockerfile +++ b/docker/etcd/Dockerfile @@ -8,7 +8,7 @@ FROM golang:1.4-wheezy RUN mkdir -p src/github.com/coreos && \ cd src/github.com/coreos && \ - curl -sL https://github.com/coreos/etcd/archive/v0.4.6.tar.gz | tar -xz && \ - mv etcd-0.4.6 etcd && \ - go install github.com/coreos/etcd + curl -sL https://github.com/coreos/etcd/archive/v2.0.13.tar.gz | tar -xz && \ + mv etcd-2.0.13 etcd && \ + go install github.com/coreos/etcd github.com/coreos/etcd/etcdctl CMD ["etcd"] diff --git a/examples/kubernetes/etcd-controller-template.yaml b/examples/kubernetes/etcd-controller-template.yaml index ab8fd74c90..10c049e407 100644 --- a/examples/kubernetes/etcd-controller-template.yaml +++ b/examples/kubernetes/etcd-controller-template.yaml @@ -6,7 +6,7 @@ metadata: name: etcd cell: {{cell}} spec: - replicas: 3 + replicas: {{replicas}} selector: name: etcd cell: {{cell}} @@ -16,9 +16,16 @@ spec: name: etcd cell: {{cell}} spec: + volumes: + - name: certs + hostPath: {path: /etc/ssl/certs} containers: - name: etcd - image: vitess/etcd:v0.4.6-lite + image: vitess/etcd:v2.0.13-lite + volumeMounts: + - name: certs + readOnly: true + mountPath: /etc/ssl/certs command: - bash - "-c" @@ -33,12 +40,16 @@ spec: local_etcd=${!local_etcd_host_var}:${!local_etcd_port_var} if [ "{{cell}}" != "global" ]; then - until curl -L http://$global_etcd/v2/keys/vt/cells/{{cell}} - -XPUT -d value=http://$local_etcd; do + until etcdctl -C "http://$global_etcd" + set "/vt/cells/{{cell}}" "http://$local_etcd"; do echo "[$(date)] waiting for global etcd to register cell '{{cell}}'"; sleep 1; done; fi - etcd -name $HOSTNAME -peer-addr $ipaddr:7001 -addr $ipaddr:4001 -discovery {{discovery}} + etcd -name $HOSTNAME -discovery {{discovery}} + -advertise-client-urls http://$ipaddr:4001 + -initial-advertise-peer-urls http://$ipaddr:7001 + -listen-client-urls http://$ipaddr:4001 + -listen-peer-urls http://$ipaddr:7001 diff --git a/examples/kubernetes/etcd-up.sh b/examples/kubernetes/etcd-up.sh index cc60658bbb..1750ea0d32 100755 --- a/examples/kubernetes/etcd-up.sh +++ b/examples/kubernetes/etcd-up.sh @@ -13,10 +13,12 @@ set -e script_root=`dirname "${BASH_SOURCE}"` source $script_root/env.sh +replicas=${ETCD_REPLICAS:-3} + for cell in 'global' 'test'; do # Generate a discovery token. echo "Generating discovery token for $cell cell..." - discovery=$(curl -sL https://discovery.etcd.io/new) + discovery=$(curl -sL https://discovery.etcd.io/new?size=$replicas) # Create the client service, which will load-balance across all replicas. echo "Creating etcd service for $cell cell..." @@ -24,10 +26,14 @@ for cell in 'global' 'test'; do sed -e "s/{{cell}}/$cell/g" | \ $KUBECTL create -f - + # Expand template variables + sed_script="" + for var in cell discovery replicas; do + sed_script+="s,{{$var}},${!var},g;" + done + # Create the replication controller. echo "Creating etcd replicationcontroller for $cell cell..." - cat etcd-controller-template.yaml | \ - sed -e "s/{{cell}}/$cell/g" -e "s,{{discovery}},$discovery,g" | \ - $KUBECTL create -f - + cat etcd-controller-template.yaml | sed -e "$sed_script" | $KUBECTL create -f - done