From 6fad7d3520710f29483e9d04194ac3ec2bb50364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9na=C3=AFc=20Huard?= Date: Tue, 22 Sep 2015 18:30:39 +0200 Subject: [PATCH 1/2] Revert "Add local etcd discovery support for libvirt-coreos" This reverts commit 74601eabbee9beb5654d38877935c4eef3ac9795. --- cluster/libvirt-coreos/util.sh | 37 +------------------ docs/getting-started-guides/libvirt-coreos.md | 6 --- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/cluster/libvirt-coreos/util.sh b/cluster/libvirt-coreos/util.sh index 35eb5994550..808f87b8a7d 100644 --- a/cluster/libvirt-coreos/util.sh +++ b/cluster/libvirt-coreos/util.sh @@ -25,9 +25,6 @@ export LIBVIRT_DEFAULT_URI=qemu:///system readonly POOL=kubernetes readonly POOL_PATH="$(cd $ROOT && pwd)/libvirt_storage_pool" -readonly UUID=$(uuidgen) -readonly LOCAL_ETCD_IP="192.168.10.200" -DISCOVERY=${DISCOVERY:-""} # join # Concatenates the list elements with the delimiter passed as first parameter @@ -159,32 +156,6 @@ function initialize-network { virsh net-create "$ROOT/network_kubernetes_pods.xml" } -function destroy-discovery { - if [ -d $ROOT/discovery.etcd ]; then - set +e - kill `ps ax | grep -v grep | grep http://$LOCAL_ETCD_IP:4001 | awk '{print $1}'` - rm -fr $ROOT/discovery.etcd - brctl delif virbr_kub_gl veth_etcd_br - ip link del veth_etcd - set -e - fi -} - -function initialize-discovery { - if [[ "$DISCOVERY" == "local-etcd" ]]; then - unset http_proxy - unset https_proxy - ip link add veth_etcd type veth peer name veth_etcd_br - brctl addif virbr_kub_gl veth_etcd_br - ifconfig veth_etcd_br up - ifconfig veth_etcd $LOCAL_ETCD_IP/24 up - $POOL_PATH/etcd/bin/etcd --initial-cluster discovery=http://$LOCAL_ETCD_IP:7001 --initial-advertise-peer-urls http://$LOCAL_ETCD_IP:7001 --listen-peer-urls http://$LOCAL_ETCD_IP:7001 --listen-client-urls http://$LOCAL_ETCD_IP:4001 --advertise-client-urls http://$LOCAL_ETCD_IP:4001 --name discovery --data-dir $ROOT/discovery.etcd & - sleep 4 - curl -X PUT http://$LOCAL_ETCD_IP:4001/v2/keys/_etcd/registry/$UUID/_config/size -d value=$(($NUM_MINIONS+1)) - $POOL_PATH/etcd/bin/etcdctl -C http://$LOCAL_ETCD_IP:4001 ls /_etcd/registry/ - fi -} - function render-template { eval "echo \"$(cat $1)\"" } @@ -215,15 +186,10 @@ function kube-up { gen-kube-bearertoken initialize-pool keep_base_image initialize-network - initialize-discovery readonly ssh_keys="$(cat ~/.ssh/id_*.pub | sed 's/^/ - /')" readonly kubernetes_dir="$POOL_PATH/kubernetes" - if [[ "$DISCOVERY" == "local-etcd" ]]; then - readonly discovery="http://$LOCAL_ETCD_IP:4001/v2/keys/_etcd/registry/$UUID" - else - readonly discovery=$(curl -s https://discovery.etcd.io/new?size=$(($NUM_MINIONS+1))) - fi + readonly discovery=$(curl -s https://discovery.etcd.io/new?size=$(($NUM_MINIONS+1))) readonly machines=$(join , "${KUBE_MINION_IP_ADDRESSES[@]}") @@ -273,7 +239,6 @@ function kube-down { while read dom; do virsh destroy $dom done - destroy-discovery destroy-pool keep_base_image destroy-network } diff --git a/docs/getting-started-guides/libvirt-coreos.md b/docs/getting-started-guides/libvirt-coreos.md index 26e21e8bb9b..e3f56910799 100644 --- a/docs/getting-started-guides/libvirt-coreos.md +++ b/docs/getting-started-guides/libvirt-coreos.md @@ -227,12 +227,6 @@ Bring up a libvirt-CoreOS cluster of 5 nodes NUM_MINIONS=5 cluster/kube-up.sh ``` -Bring up a libvirt-CoreOS cluster with a local etcd discovery - -```sh -DISCOVERY=local-etcd cluster/kube-up.sh -``` - Destroy the libvirt-CoreOS cluster ```sh From 8b99dd6fb19156f8db119a1066ba035ecc1a7377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9na=C3=AFc=20Huard?= Date: Wed, 23 Sep 2015 11:34:55 +0200 Subject: [PATCH 2/2] Get rid of the etcd discovery mechanism in favor of static configuration In order to make the etcd instances of the VMs join into a single cluster, we used to use the discovery mechanism. This made the cluster bootstrap dependent on an external etcd cluster instance. 74601ea replaced the dependency on discovery.etcd.io by a local etcd cluster. This change completely gets rid of the dynamic discovery mechanism in favor of the static configuration method. This should be both safe and light since it completely removes the need of having an external etcd cluster running somewhere (either discovery.etcd.io, or locally). --- cluster/libvirt-coreos/user_data.yml | 8 +++++++- cluster/libvirt-coreos/util.sh | 13 ++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cluster/libvirt-coreos/user_data.yml b/cluster/libvirt-coreos/user_data.yml index 4616c24d44c..24c1dc41f14 100644 --- a/cluster/libvirt-coreos/user_data.yml +++ b/cluster/libvirt-coreos/user_data.yml @@ -15,11 +15,12 @@ write_files: coreos: etcd2: - discovery: ${discovery} advertise-client-urls: http://${public_ip}:2379 initial-advertise-peer-urls: http://${public_ip}:2380 listen-client-urls: http://0.0.0.0:2379 listen-peer-urls: http://${public_ip}:2380 + initial-cluster-state: new + initial-cluster: ${etcd2_initial_cluster} units: - name: static.network command: start @@ -70,6 +71,11 @@ coreos: Type=oneshot - name: etcd2.service command: start + drop-ins: + - name: 10-override-name.conf + content: | + [Service] + Environment=ETCD_NAME=%H - name: docker.service command: start drop-ins: diff --git a/cluster/libvirt-coreos/util.sh b/cluster/libvirt-coreos/util.sh index 808f87b8a7d..fc567584e57 100644 --- a/cluster/libvirt-coreos/util.sh +++ b/cluster/libvirt-coreos/util.sh @@ -189,11 +189,18 @@ function kube-up { readonly ssh_keys="$(cat ~/.ssh/id_*.pub | sed 's/^/ - /')" readonly kubernetes_dir="$POOL_PATH/kubernetes" - readonly discovery=$(curl -s https://discovery.etcd.io/new?size=$(($NUM_MINIONS+1))) - - readonly machines=$(join , "${KUBE_MINION_IP_ADDRESSES[@]}") local i + for (( i = 0 ; i <= $NUM_MINIONS ; i++ )); do + if [[ $i -eq $NUM_MINIONS ]]; then + etcd2_initial_cluster[$i]="${MASTER_NAME}=http://${MASTER_IP}:2380" + else + etcd2_initial_cluster[$i]="${MINION_NAMES[$i]}=http://${MINION_IPS[$i]}:2380" + fi + done + etcd2_initial_cluster=$(join , "${etcd2_initial_cluster[@]}") + readonly machines=$(join , "${KUBE_MINION_IP_ADDRESSES[@]}") + for (( i = 0 ; i <= $NUM_MINIONS ; i++ )); do if [[ $i -eq $NUM_MINIONS ]]; then type=master