devstack: Use devstack's etcd3 service

This patch deprecates the containerized etcd that we've been using up
until now for devstack. It moves the default to be the devstack provided
etcd3 service so we do not conflict with other etcd3 consumers and
benefit from the upstream devstack improvements.

Change-Id: Icf7d48b72d0ff6ae34d4752040100997d7892c5e
Fixes-Bug: 1638892
Signed-off-by: Antoni Segura Puimedon <antonisp@celebdor.com>
This commit is contained in:
Antoni Segura Puimedon 2017-06-14 16:01:08 +02:00 committed by Kirill Zaitsev
parent 6e2183f0b6
commit 9500a81a57
7 changed files with 117 additions and 84 deletions

View File

@ -22,7 +22,7 @@ VARIANT=${1:-default}
export DEVSTACK_LOCAL_CONFIG="enable_plugin neutron-lbaas git://git.openstack.org/openstack/neutron-lbaas"
export DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_plugin kuryr-kubernetes https://git.openstack.org/openstack/kuryr-kubernetes"
export DEVSTACK_LOCAL_CONFIG+=$'\n'"NEUTRON_LBAAS_SERVICE_PROVIDERV2=LOADBALANCERV2:Haproxy:neutron_lbaas.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default"
export OVERRIDE_ENABLED_SERVICES=neutron,q-svc,key,mysql,rabbit,docker,etcd,kubernetes-api,kubernetes-controller-manager,kubernetes-scheduler,kubelet,kuryr-kubernetes,q-lbaasv2
export OVERRIDE_ENABLED_SERVICES=neutron,q-svc,key,mysql,rabbit,docker,legacy_etcd,kubernetes-api,kubernetes-controller-manager,kubernetes-scheduler,kubelet,kuryr-kubernetes,q-lbaasv2
if [[ $VARIANT == 'default' ]]; then
export OVERRIDE_ENABLED_SERVICES+=,q-agt,q-dhcp,q-l3

View File

@ -57,3 +57,90 @@ function ovs_bind_for_kubelet() {
sudo ip addr add "${port_ips[$i]}/${prefix}" dev "$ifname"
done
}
# get_container
# Description: Pulls a container from Dockerhub
# Params:
# image_name - the name of the image in docker hub
# version - The version of the image to pull. Defaults to 'latest'
function get_container {
local image
local image_name
local version
image_name="$1"
version="${2:-latest}"
if [ "$image_name" == "" ]; then
return 0
fi
image="${image_name}:${version}"
if [ -z "$(docker images -q "$image")" ]; then
docker pull "$image"
fi
}
# run_container
# Description: Runs a container and attaches devstack's logging to it
# Params:
# name - Name of the container to run
# args - arguments to run the container with
function run_container {
# Runs a detached container and uses devstack's run process to monitor
# its logs
local name
local docker_bin
docker_bin=$(which docker)
name="$1"
shift
"$docker_bin" run --name "$name" --detach "$@"
run_process "$name" \
"$docker_bin logs -f $name"
}
# stop_container
# Description: stops a container and its devstack logging
# Params:
# name - Name of the container to stop
function stop_container {
local name
name="$1"
docker kill "$name"
docker rm "$name"
stop_process "$name"
}
# prepare_etcd_legacy
# Description: Creates datadir for etcd and fetches its container image
function prepare_etcd_legacy {
# Make Etcd data directory
sudo install -d -o "$STACK_USER" "$KURYR_ETCD_DATA_DIR"
# Get Etcd container
get_container "$KURYR_ETCD_IMAGE" "$KURYR_ETCD_VERSION"
}
# run_etcd_legacy
# Description: Deprecated way of running etcd for Kubernetes (based on
# coreos upstream image.
function run_etcd_legacy {
run_container etcd \
--net host \
--volume="${KURYR_ETCD_DATA_DIR}:/var/etcd:rw" \
"${KURYR_ETCD_IMAGE}:${KURYR_ETCD_VERSION}" \
/usr/local/bin/etcd \
--name devstack \
--data-dir /var/etcd/data \
--initial-advertise-peer-urls "$KURYR_ETCD_ADVERTISE_PEER_URL" \
--listen-peer-urls "$KURYR_ETCD_LISTEN_PEER_URL" \
--listen-client-urls "$KURYR_ETCD_LISTEN_CLIENT_URL" \
--advertise-client-urls "$KURYR_ETCD_ADVERTISE_CLIENT_URL" \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster "devstack=$KURYR_ETCD_ADVERTISE_PEER_URL" \
--initial-cluster-state new
}

View File

@ -76,8 +76,15 @@ enable_service docker
# Etcd
# ====
# The default is for devstack to run etcd for you. You can select the image and
# version of it by uncommenting and modifying the following defaults.
# The default is for devstack to run etcd for you.
enable_service etcd3
# You can also run the deprecated etcd containerized and select the image and
# version of it by commenting the etcd3 service enablement and uncommenting
#
# enable legacy_etcd
#
# You can also modify the following defaults.
# KURYR_ETCD_IMAGE="quay.io/coreos/etcd"
# KURYR_ETCD_VERSION="v3.0.8"
#
@ -88,8 +95,8 @@ enable_service docker
# KURYR_ETCD_LISTEN_CLIENT_URL=http://0.0.0.0:2379}
# KURYR_ETCD_LISTEN_PEER_URL=http://0.0.0.0:2380}
#
# If you already have etcd configured and running, you can just comment out
enable_service etcd
# If you already have an etcd cluster configured and running, you can just
# comment out the lines enabling legacy_etcd and etcd3
# then uncomment and set the following line:
# KURYR_ETCD_CLIENT_URL="http://etcd_ip:etcd_client_port"

View File

@ -26,7 +26,7 @@ KURYR_CONFIGURE_NEUTRON_DEFAULTS=False
KURYR_CONFIGURE_BAREMETAL_KUBELET_IFACE=False
enable_service docker
enable_service etcd
enable_service etcd3
enable_service kubernetes-api
enable_service kubernetes-controller-manager
enable_service kubernetes-scheduler

View File

@ -58,8 +58,15 @@ enable_service docker
# Etcd
# ====
# The default is for devstack to run etcd for you. You can select the image and
# version of it by uncommenting and modifying the following defaults.
# The default is for devstack to run etcd for you.
enable_service etcd3
# You can also run the deprecated etcd containerized and select the image and
# version of it by commenting the etcd3 service enablement and uncommenting
#
# enable legacy_etcd
#
# You can also modify the following defaults.
# KURYR_ETCD_IMAGE="quay.io/coreos/etcd"
# KURYR_ETCD_VERSION="v3.0.8"
#
@ -70,8 +77,8 @@ enable_service docker
# KURYR_ETCD_LISTEN_CLIENT_URL=http://0.0.0.0:2379}
# KURYR_ETCD_LISTEN_PEER_URL=http://0.0.0.0:2380}
#
# If you already have etcd configured and running, you can just comment out
enable_service etcd
# If you already have an etcd cluster configured and running, you can just
# comment out the lines enabling legacy_etcd and etcd3
# then uncomment and set the following line:
# KURYR_ETCD_CLIENT_URL="http://etcd_ip:etcd_client_port"

View File

@ -11,31 +11,6 @@
# License for the specific language governing permissions and limitations
# under the License.
function run_container {
# Runs a detached container and uses devstack's run process to monitor
# its logs
local name
local docker_bin=$(which docker)
name="$1"
shift
"$docker_bin" run --name "$name" --detach "$@"
run_process "$name" \
"$docker_bin logs -f $name"
}
function stop_container {
local name
name="$1"
docker kill "$name"
docker rm "$name"
stop_process "$name"
}
function create_kuryr_account {
if is_service_enabled kuryr-kubernetes; then
create_service_user "kuryr" "admin"
@ -278,49 +253,6 @@ function check_docker {
fi
}
function get_container {
local image
local image_name
local version
image_name="$1"
version="${2:-latest}"
if [ "$image_name" == "" ]; then
return 0
fi
image="${image_name}:${version}"
if [ -z "$(docker images -q "$image")" ]; then
docker pull "$image"
fi
}
function prepare_etcd {
# Make Etcd data directory
sudo install -d -o "$STACK_USER" "$KURYR_ETCD_DATA_DIR"
# Get Etcd container
get_container "$KURYR_ETCD_IMAGE" "$KURYR_ETCD_VERSION"
}
function run_etcd {
run_container etcd \
--net host \
--volume="${KURYR_ETCD_DATA_DIR}:/var/etcd:rw" \
"${KURYR_ETCD_IMAGE}:${KURYR_ETCD_VERSION}" \
/usr/local/bin/etcd \
--name devstack \
--data-dir /var/etcd/data \
--initial-advertise-peer-urls "$KURYR_ETCD_ADVERTISE_PEER_URL" \
--listen-peer-urls "$KURYR_ETCD_LISTEN_PEER_URL" \
--listen-client-urls "$KURYR_ETCD_LISTEN_CLIENT_URL" \
--advertise-client-urls "$KURYR_ETCD_ADVERTISE_CLIENT_URL" \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster "devstack=$KURYR_ETCD_ADVERTISE_PEER_URL" \
--initial-cluster-state new
}
function prepare_docker {
curl -L http://get.docker.com | sudo bash
}
@ -613,9 +545,9 @@ if is_service_enabled kuryr-kubernetes; then
run_docker
fi
if is_service_enabled etcd; then
prepare_etcd
run_etcd
if is_service_enabled legacy_etcd; then
prepare_etcd_legacy
run_etcd_legacy
fi
get_container "$KURYR_HYPERKUBE_IMAGE" "$KURYR_HYPERKUBE_VERSION"
@ -665,7 +597,7 @@ if is_service_enabled kuryr-kubernetes; then
if is_service_enabled kubernetes-api; then
stop_container kubernetes-api
fi
if is_service_enabled etcd; then
if is_service_enabled legacy_etcd; then
stop_container etcd
fi
@ -673,7 +605,7 @@ if is_service_enabled kuryr-kubernetes; then
fi
if [[ "$1" == "clean" ]]; then
if is_service_enabled etcd; then
if is_service_enabled legacy_etcd; then
# Cleanup Etcd for the next stacking
sudo rm -rf "$KURYR_ETCD_DATA_DIR"
fi

View File

@ -18,7 +18,7 @@ KURYR_NEUTRON_DEFAULT_SERVICE_SUBNET=k8s-service-subnet
KURYR_ETCD_IMAGE=${KURYR_ETCD_IMAGE:-quay.io/coreos/etcd}
KURYR_ETCD_VERSION=${KURYR_ETCD_VERSION:-v3.0.8}
KURYR_ETCD_DATA_DIR=${KURYR_ETCD_DATA_DIR:-${DATA_DIR}/etcd}
KURYR_ETCD_ADVERTISE_CLIENT_URL=${KURYR_ETCD_ADVERTISE_CLIENT_URL:-http://${HOST_IP}:2379}
KURYR_ETCD_ADVERTISE_CLIENT_URL=${KURYR_ETCD_ADVERTISE_CLIENT_URL:-http://${HOST_IP}:${ETCD_PORT}}
KURYR_ETCD_ADVERTISE_PEER_URL=${KURYR_ETCD_ADVERTISE_PEER_URL:-http://${HOST_IP}:2380}
KURYR_ETCD_LISTEN_CLIENT_URL=${KURYR_ETCD_LISTEN_CLIENT_URL:-http://0.0.0.0:2379}
KURYR_ETCD_LISTEN_PEER_URL=${KURYR_ETCD_LISTEN_PEER_URL:-http://0.0.0.0:2380}