Initial commit for ccp multi-deploy solution

It's authored by Marek, I'm just reposting it here to make
publically available.
This is a sample shell script + config files to assist in deployment
of multiple OpenStack environments within a single K8s cluster.

Change-Id: Ic372d56b72b2430cabdb8afb84d2d7776a349465
This commit is contained in:
Sergey Lukjanov 2016-09-30 07:46:11 -07:00 committed by Marek Zawadzki
parent 10336ec4e1
commit 8e30af7d39
11 changed files with 256 additions and 0 deletions

View File

@ -0,0 +1,119 @@
#!/bin/bash
#
# This script semit-automates deployment of multiple OpenStack environemtns
# within single K8s cluster using mcp/ccp tool.
# This is PoC.
# Usage: tox -e multi-deploy -- --help
#
# (c) mzawadzki@mirantis.com
set -e
# Config (defaults):
NUMBER_OF_ENVS=1 # Requires 3 K8s nodes per env
BUILD_IMAGES=true # Set to true if run for the first time
NAMESPACE_PREFIX="ccp"
: ${CONFIG_DIR:="tools/ccp-multi-deploy/config"}
# Functions:
function usage {
cat <<EOF
Usage: $0 [OPTION]
Deploy multiple OpenStack environments with fuel-ccp.
Options:
-h, --help
print usage and exit
-n, --number-of-envs=NUMBER
deploy NUMBER of parallel environments (default: 1)
-s, --skip-building-images
do not build Docker images for OpenStack services
(rely on existing local registry, default: false)
EOF
exit
}
function ccp_wait_for_deployment_to_finish {
until kubectl --namespace $1 get jobs | awk '$3 ~ 0 {print}' | wc -l | grep "^0$"; do
echo "Waiting for jobs to finish..."
sleep 1m
done
echo "...................................."
echo "Jobs and pods in namespace: $1"
kubectl --namespace $1 get jobs
kubectl --namespace $1 get pods
echo "openrc file: openrc-$1"
cat openrc-$1
echo "...................................."
}
function display_horizon_access_info {
HORIZON_NODEPORT=`kubectl --namespace $1 get service horizon -o yaml | awk '/nodePort: / {print $NF}'`
echo "Hint - to access horizon from your workstation please run:"
echo "ssh USER@LAB_HOST_IP -L 18080:127.0.0.1:18080 ssh -L8080:NODE1_IP:${HORIZON_NODEPORT} vagrant@NODE1_IP"
}
function run_openstack_tests {
source $1
./tools/deploy-test-vms.sh -a create
# FIXME(mzawadzki): workaround for some minor error during networking destroy (minor b/c it works manually)
./tools/deploy-test-vms.sh -a destroy || true
}
# Parse command line arguments:
OPTS=`getopt -o 'hsn:' --long help,skip-building-images,number-of-envs: -n 'parse-options' -- ${@}`
if [ ${?} != 0 ] ; then
echo "Failed parsing options."
exit 1
fi
eval set -- ${OPTS}
while true; do
case ${1} in
-h|--help ) usage; shift ;;
-n|--number-of-envs ) NUMBER_OF_ENVS=${2}; shift; shift ;;
-s|--skip-building-images ) BUILD_IMAGES=false; shift ;;
-- ) shift; break ;;
* ) break ;;
esac
done
# Check some basic requirements and exit explicitly if they are not met:
if [ ! -f "${CONFIG_DIR}/ccp-cli-config-1.yaml" ]; then
echo "Config file not found, did you set CONFIG_DIR correctly?"
exit 1
fi
which kubectl || exit 1
groups | grep docker || exit 1
if [ `kubectl get nodes | grep node | wc -l` -lt $(($NUMBER_OF_ENVS * 3)) ]; then
echo "Your K8s cluster is too small, you need NUMBER_OF_ENVS * 3 nodes."
exit 1
fi
# Fetch CCP repos
CCP="ccp --debug --config-file ${CONFIG_DIR}/ccp-cli-config-1.yaml"
${CCP} fetch
# Create internal Docker registry for CCP,
# build and push CCP images:
if [ "${BUILD_IMAGES}" = "true" ]; then
kubectl delete pod registry || true
kubectl delete service registry || true
./tools/registry/deploy-registry.sh -n default
${CCP} build
fi
# Deploy envs:
for n in $(seq 1 ${NUMBER_OF_ENVS}); do
CCP="ccp --debug --config-file ${CONFIG_DIR}/ccp-cli-config-${n}.yaml"
${CCP} deploy
ccp_wait_for_deployment_to_finish ${NAMESPACE_PREFIX}-${n}
display_horizon_access_info ${NAMESPACE_PREFIX}-${n}
run_openstack_tests openrc-${NAMESPACE_PREFIX}-${n}
echo "CCP cleanup command: ccp --debug --config-file ${CONFIG_DIR}/ccp-cli-config-${n} cleanup"
done

View File

@ -0,0 +1,7 @@
!include
- ccp-configs-common.yaml
- ccp-roles.yaml
- ccp-topology-1.yaml
---
kubernetes:
namespace: "ccp-1"

View File

@ -0,0 +1,7 @@
!include
- ccp-configs-common.yaml
- ccp-roles.yaml
- ccp-topology-2.yaml
---
kubernetes:
namespace: "ccp-2"

View File

@ -0,0 +1,7 @@
!include
- ccp-configs-common.yaml
- ccp-roles.yaml
- ccp-topology-3.yaml
---
kubernetes:
namespace: "ccp-3"

View File

@ -0,0 +1,12 @@
---
builder:
push: True
registry:
address: "127.0.0.1:31500"
repositories:
path: /tmp/ccp-repos
skip_empty: True
configs:
private_interface: eth0
public_interface: eth1
neutron_external_interface: eth2

View File

@ -0,0 +1,30 @@
---
roles:
controller-net-host:
- neutron-dhcp-agent
- neutron-l3-agent
- neutron-metadata-agent
controller-net-bridge:
- etcd
- glance-api
- glance-registry
- heat-api
- heat-engine
- horizon
- keystone
- mariadb
- memcached
- neutron-server
- nova-api
- nova-conductor
- nova-consoleauth
- nova-novncproxy
- nova-scheduler
- rabbitmq
compute:
- nova-compute
- nova-libvirt
openvswitch:
- neutron-openvswitch-agent
- openvswitch-db
- openvswitch-vswitchd

View File

@ -0,0 +1,13 @@
---
nodes:
node[1,2-3,4,5-6,7,8-9]:
roles:
- controller-net-bridge
node1:
roles:
- openvswitch
- controller-net-host
node[2-3]:
roles:
- openvswitch
- compute

View File

@ -0,0 +1,13 @@
---
nodes:
node[1,2-3,4,5-6,7,8-9]:
roles:
- controller-net-bridge
node4:
roles:
- openvswitch
- controller-net-host
node[5-6]:
roles:
- openvswitch
- compute

View File

@ -0,0 +1,13 @@
---
nodes:
node[1,2-3,4,5-6,7,8-9]:
roles:
- controller-net-bridge
node7:
roles:
- openvswitch
- controller-net-host
node[8-9]:
roles:
- openvswitch
- compute

View File

@ -0,0 +1,31 @@
# Multiple OpenStack deployments "roles topology" file.
# This file describes how ccp roles will be distributed among
# nodes in K8s cluster.
# Deployments are marked by numbers in [].
# Note: this file is NOT used by any tool.
node1:
- openvswitch[1]
- controller-net-host[1]
- controller-net-bridge[.*]
node[2-3]
- openvswitch[1]
- compute[1]
- controller-net-bridge[.*]
node4:
- openvswitch[2]
- controller-net-host[2]
- controller-net-bridge[.*]
node[5-6]
- openvswitch[2]
- compute[2]
- controller-net-bridge[.*]
node7:
- openvswitch[3]
- controller-net-host[3]
- controller-net-bridge[.*]
node[8-9]:
- openvswitch[3]
- compute[3]
- controller-net-bridge[.*]

View File

@ -40,6 +40,10 @@ commands = python setup.py build_sphinx
[testenv:debug]
commands = oslo_debug_helper {posargs}
[testenv:multi-deploy]
commands =
bash -ex "{toxinidir}/tools/ccp-multi-deploy/ccp-multi-deploy.sh" {posargs}
[flake8]
# H102 skipped as it's a non-free project