зеркало из https://github.com/github/vitess-gh.git
Update Docker/Kubernetes configs to etcd v2.0.13.
This commit is contained in:
Родитель
d48074d215
Коммит
aaeb818c3d
|
@ -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/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче