From 11556dc927247b96d1a18e45e48876e75ce3edab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9na=C3=AFc=20Huard?= Date: Mon, 13 Apr 2015 12:14:42 +0200 Subject: [PATCH] libvirt-coreos cluster: Fix etcd versions incompatibility issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Whereas CoreOS is still shipped with etcd 0.4.9, kubernetes has moved to etcd 2.0.4. This version mismatch makes kubernetes unable to use etcd. Kubernetes’ logs are full of “502: (unhandled http status [Temporary Redirect] with body []) [0]” This change makes libvirt-coreos cluster explicitly use etcd v2.0.9 instead of the one shipped within CoreOS. This change aims at being reverted once CoreOS will migrate to etcd 2. This migration is tracked at: https://github.com/coreos/bugs/issues/317 --- cluster/libvirt-coreos/.gitignore | 1 + cluster/libvirt-coreos/coreos.xml | 5 +++++ cluster/libvirt-coreos/user_data.yml | 24 +++++++++++++++++++++++- cluster/libvirt-coreos/util.sh | 18 ++++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/cluster/libvirt-coreos/.gitignore b/cluster/libvirt-coreos/.gitignore index f26d8e4020a..3eb6823b0f2 100644 --- a/cluster/libvirt-coreos/.gitignore +++ b/cluster/libvirt-coreos/.gitignore @@ -1,2 +1,3 @@ /libvirt_storage_pool/ /coreos_production_qemu_image.img.bz2 +/etcd-v2.0.9-linux-amd64.tar.gz diff --git a/cluster/libvirt-coreos/coreos.xml b/cluster/libvirt-coreos/coreos.xml index 041f3a01510..a0490e2eadd 100644 --- a/cluster/libvirt-coreos/coreos.xml +++ b/cluster/libvirt-coreos/coreos.xml @@ -35,6 +35,11 @@ + + + + + diff --git a/cluster/libvirt-coreos/user_data.yml b/cluster/libvirt-coreos/user_data.yml index ae7a430e972..338df478961 100644 --- a/cluster/libvirt-coreos/user_data.yml +++ b/cluster/libvirt-coreos/user_data.yml @@ -17,11 +17,22 @@ coreos: etcd: name: ${name} addr: ${public_ip}:4001 - bind-addr: 0.0.0.0 + # bind-addr: 0.0.0.0 peer-addr: ${public_ip}:7001 # peers: {etcd_peers} discovery: ${discovery} units: + - name: etcd.service + drop-ins: + - name: opt-etcd2.conf + content: | + [Unit] + After=opt-etcd.mount + Requires=opt-etcd.mount + + [Service] + ExecStart= + ExecStart=/opt/etcd/bin/etcd - name: static.network command: start content: | @@ -103,6 +114,17 @@ coreos: Where=/opt/kubernetes Options=ro,trans=virtio,version=9p2000.L Type=9p + - name: opt-etcd.mount + command: start + content: | + [Unit] + ConditionVirtualization=|vm + + [Mount] + What=etcd + Where=/opt/etcd + Options=ro,trans=virtio,version=9p2000.L + Type=9p update: group: ${COREOS_CHANNEL:-alpha} reboot-strategy: off diff --git a/cluster/libvirt-coreos/util.sh b/cluster/libvirt-coreos/util.sh index e93798594a8..b05a6089165 100644 --- a/cluster/libvirt-coreos/util.sh +++ b/cluster/libvirt-coreos/util.sh @@ -25,6 +25,8 @@ export LIBVIRT_DEFAULT_URI=qemu:///system readonly POOL=kubernetes readonly POOL_PATH="$(cd $ROOT && pwd)/libvirt_storage_pool" +ETCD_VERSION=${ETCD_VERSION:-v2.0.9} + # join # Concatenates the list elements with the delimiter passed as first parameter # @@ -93,6 +95,9 @@ function destroy-pool { virsh vol-delete $vol --pool $POOL done + rm -rf "$POOL_PATH"/etcd/* + virsh vol-delete etcd --pool $POOL || true + [[ "$1" == 'keep_base_image' ]] && return set +e @@ -140,6 +145,18 @@ function initialize-pool { render-template "$ROOT/skydns-rc.yaml" > "$POOL_PATH/kubernetes/addons/skydns-rc.yaml" fi + mkdir -p "$POOL_PATH/etcd" + if [[ ! -f "$ROOT/etcd-${ETCD_VERSION}-linux-amd64.tar.gz" ]]; then + wget -P "$ROOT" https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz + fi + if [[ "$ROOT/etcd-${ETCD_VERSION}-linux-amd64.tar.gz" -nt "$POOL_PATH/etcd/etcd" ]]; then + tar -x -C "$POOL_PATH/etcd" -f "$ROOT/etcd-${ETCD_VERSION}-linux-amd64.tar.gz" etcd-${ETCD_VERSION}-linux-amd64 + rm -rf "$POOL_PATH/etcd/bin/*" + mkdir -p "$POOL_PATH/etcd/bin" + mv "$POOL_PATH"/etcd/etcd-${ETCD_VERSION}-linux-amd64/{etcd,etcdctl} "$POOL_PATH/etcd/bin" + rm -rf "$POOL_PATH/etcd/etcd-${ETCD_VERSION}-linux-amd64" + fi + virsh pool-refresh $POOL } @@ -187,6 +204,7 @@ function kube-up { readonly ssh_keys="$(cat ~/.ssh/id_*.pub | sed 's/^/ - /')" readonly kubernetes_dir="$POOL_PATH/kubernetes" + readonly etcd_dir="$POOL_PATH/etcd" readonly discovery=$(curl -s https://discovery.etcd.io/new) readonly machines=$(join , "${KUBE_MINION_IP_ADDRESSES[@]}")