From 9cac3c6b63b9b3f3241d9163c7bc849050e98307 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Fri, 21 Dec 2018 18:40:47 +0000 Subject: [PATCH] Run k8s-on-openstack to manage k8s control plane The k8s-on-openstack project produces an opinionated kubernetes that is correctly set up to be integrated with OpenStack. All of the patches we've submitted to update it for our environment have been landed upstream, so just consume it directly. It's possible we might want to take a more hands-on forky approach in the future, but for now it seems fairly stable. Change-Id: I4ff605b6a947ab9b9f3d0a73852dde74c705979f --- playbooks/run-k8s-on-openstack.yaml | 15 +++++++++++ run_all.sh | 5 ++++ run_k8s_ansible.sh | 42 +++++++++++++++++++++++++++++ tools/cloud-to-env.py | 30 +++++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 playbooks/run-k8s-on-openstack.yaml create mode 100755 run_k8s_ansible.sh create mode 100644 tools/cloud-to-env.py diff --git a/playbooks/run-k8s-on-openstack.yaml b/playbooks/run-k8s-on-openstack.yaml new file mode 100644 index 0000000000..3fb944edf8 --- /dev/null +++ b/playbooks/run-k8s-on-openstack.yaml @@ -0,0 +1,15 @@ +- hosts: "localhost:!disabled" + name: "System-config: Update the system-config repo on bridge" + connection: local + gather_facts: false + tasks: + - name: Make sure k8s-on-openstack repo is up to date + git: + repo: https://github.com/infraly/k8s-on-openstack + dest: /opt/k8s-on-openstack + force: yes + + - name: Run kubernetes deploy playbook + command: ./run_k8s_ansible.sh + args: + chdir: /opt/system-config diff --git a/run_all.sh b/run_all.sh index 2f4fc11598..e1ef6e48d4 100755 --- a/run_all.sh +++ b/run_all.sh @@ -82,6 +82,11 @@ start_timer timeout -k 2m 120m ansible-playbook -f 50 ${ANSIBLE_PLAYBOOKS}/base.yaml send_timer base +# Run k8s-on-openstack +start_timer +timeout -k 2m 120m ansible-playbook -f 50 ${ANSIBLE_PLAYBOOKS}/run-k8s-on-openstack.yaml +send_timer k8s + # Update the puppet version start_timer timeout -k 2m 120m ansible-playbook -f 50 ${ANSIBLE_PLAYBOOKS}/update_puppet_version.yaml diff --git a/run_k8s_ansible.sh b/run_k8s_ansible.sh new file mode 100755 index 0000000000..c842d948ff --- /dev/null +++ b/run_k8s_ansible.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Copyright (c) 2018 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is required to wrap the ansible playbook invocation because +# we need to set config options via environment variables. There are parts +# of this that could be cleaned up upstream, but doing so makes the actual +# os_ module invocations really chatty. + +eval $(python3 tools/cloud-to-env.py --cloud=openstackci-vexxhost --region=sjc1) + +export KEY="bridge-root-2014-09-15" +export NAME="opendev-k8s" +export IMAGE="Ubuntu 16.04 LTS (x86_64) [2018-08-24]" +export MASTER_FLAVOR="v2-highcpu-4" +export MASTER_BOOT_FROM_VOLUME="True" +export IGNORE_VOLUME_AZ="True" +export FLOATING_IP_NETWORK_UUID="0048fce6-c715-4106-a810-473620326cb0" +export NODE_FLAVOR="v2-highcpu-8" +export NODE_AUTO_IP="True" +export NODE_BOOT_FROM_VOLUME="True" +export NODE_VOLUME_SIZE="64" +export NODE_EXTRA_VOLUME="True" +export NODE_EXTRA_VOLUME_SIZE="80" +export USE_OCTAVIA="True" +export BLOCK_STORAGE_VERSION='v3' + +cd /opt/k8s-on-openstack +ansible-playbook -v site.yaml diff --git a/tools/cloud-to-env.py b/tools/cloud-to-env.py new file mode 100644 index 0000000000..069ed29f4e --- /dev/null +++ b/tools/cloud-to-env.py @@ -0,0 +1,30 @@ +import argparse +import sys + +import openstack + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + "--cloud", dest="cloud", required=True, + help="cloud name") + parser.add_argument( + "--region", dest="region", required=True, + help="cloud region") + + options = parser.parse_args() + + cloud_region = openstack.config.OpenStackConfig().get_one( + cloud=options.cloud, region_name=options.region) + + print("export OS_REGION_NAME='{region_name}'".format( + region_name=cloud_region.region_name)) + for k, v in cloud_region.auth.items(): + print("export OS_{key}='{value}'".format( + key=k.upper(), + value=v)) + return 0 + +if __name__ == '__main__': + sys.exit(main())