From 291127f0d1f74aa5510f1cb56c67e5d498de375d Mon Sep 17 00:00:00 2001 From: Pengfei Ni Date: Sat, 27 May 2017 19:14:05 +0800 Subject: [PATCH] Add devstack plugin for stackube The plugin install components including * OpenStack Keystone, Neutron and Cinder with Ceph backend * Kubernetes with frakti container runtime * Kubernetes auth via keystone Implements: blueprint kubernetes-deploy Change-Id: Ib2ad60b71bc51bdedaefd7014c83ed7ba56414e3 Signed-off-by: Pengfei Ni --- devstack/README.md | 50 ++++++++ devstack/kubeadm.yaml | 13 ++ devstack/local.conf.node.sample | 29 +++++ devstack/local.conf.sample | 33 +++++ devstack/plugin.sh | 215 ++++++++++++++++++++++++++++++++ devstack/settings | 15 +++ 6 files changed, 355 insertions(+) create mode 100644 devstack/README.md create mode 100644 devstack/kubeadm.yaml create mode 100644 devstack/local.conf.node.sample create mode 100644 devstack/local.conf.sample create mode 100644 devstack/plugin.sh create mode 100644 devstack/settings diff --git a/devstack/README.md b/devstack/README.md new file mode 100644 index 0000000..af4d1c5 --- /dev/null +++ b/devstack/README.md @@ -0,0 +1,50 @@ +# devstack plugin + +devstack plugin for stackube. + +## All-in-one + +```sh +# create stack user +sudo useradd -s /bin/bash -d /opt/stack -m stack +echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack +sudo su - stack + +git clone https://git.openstack.org/openstack-dev/devstack -b stable/ocata +cd devstack +``` + +Create `local.conf` from [local.conf.sample](local.conf.sample) and then run `./stack.sh` to install. + +```sh +./stack.sh +``` + +Wait a while for installation compelete, then setup kubernetes and OpenStack client: + +```sh +# Kubernetes +export KUBECONFIG=$HOME/admin.conf +kubectl cluster-info + +# OpenStack +source openrc admin admin +openstack service list +``` + +## Add a node + +```sh +# create stack user +sudo useradd -s /bin/bash -d /opt/stack -m stack +echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack +sudo su - stack + +git clone https://git.openstack.org/openstack-dev/devstack -b stable/ocata +cd devstack +``` + +Create `local.conf` from [local.conf.node.sample](local.conf.node.sample), set `HOST_IP` to local host's IP, set `SERVICE_HOST` to master's IP and set `KUBEADM_TOKEN` to kubeadm token (could be got by `kubeadm token list`). + +Then run `./stack.sh` to install. + diff --git a/devstack/kubeadm.yaml b/devstack/kubeadm.yaml new file mode 100644 index 0000000..1f58269 --- /dev/null +++ b/devstack/kubeadm.yaml @@ -0,0 +1,13 @@ +kind: MasterConfiguration +apiVersion: kubeadm.k8s.io/v1alpha1 +kubernetesVersion: "stable" +controllerManagerExtraArgs: + horizontal-pod-autoscaler-use-rest-clients: "true" + horizontal-pod-autoscaler-sync-period: "10s" + node-monitor-grace-period: "10s" + feature-gates: "AllAlpha=true" + enable-dynamic-provisioning: "true" +apiServerExtraArgs: + runtime-config: "api/all=true" + feature-gates: "AllAlpha=true" + experimental-keystone-url: "https://KEYSTONE_HOST:5000/v2.0" diff --git a/devstack/local.conf.node.sample b/devstack/local.conf.node.sample new file mode 100644 index 0000000..a8fc6d6 --- /dev/null +++ b/devstack/local.conf.node.sample @@ -0,0 +1,29 @@ +[[local|localrc]] +# Set to local host's IP +HOST_IP=10.0.0.3 +# Set to master node's IP +SERVICE_HOST="10.0.0.2" +MYSQL_HOST=${SERVICE_HOST} +RABBIT_HOST=${SERVICE_HOST} +ADMIN_PASSWORD=password +DATABASE_PASSWORD=$ADMIN_PASSWORD +RABBIT_PASSWORD=$ADMIN_PASSWORD +SERVICE_PASSWORD=$ADMIN_PASSWORD + +ENABLED_SERVICES="" + +# Neutron +enable_service q-agt + +# Kubernetes +STACKUBE_HOME=${STACKUBE_HOME:-$DEST/stackube} +# Kubernetes master IP, should set to master IP for minions +KUBERNETES_MASTER_IP=${SERVICE_HOST} +# Get token by running following command on the master node +# sudo kubeadm token list | awk '/kubeadm/{print $1}' +KUBEADM_TOKEN="token" +CONTAINER_CIDR="10.244.2.0/24" +enable_plugin stackube git://git.openstack.org/openstack/stackube +enable_service stackube +# Enable kubernetes node components +enable_service kubernetes_node diff --git a/devstack/local.conf.sample b/devstack/local.conf.sample new file mode 100644 index 0000000..f17189a --- /dev/null +++ b/devstack/local.conf.sample @@ -0,0 +1,33 @@ +[[local|localrc]] +ADMIN_PASSWORD=password +DATABASE_PASSWORD=$ADMIN_PASSWORD +RABBIT_PASSWORD=$ADMIN_PASSWORD +SERVICE_PASSWORD=$ADMIN_PASSWORD + +ENABLED_SERVICES="tls-proxy" + +# Keystone +enable_service key +enable_service mysql +enable_service rabbit + +# Neutron +enable_service neutron +enable_service q-agt +enable_service q-dhcp +enable_service q-l3 +enable_service q-svc +enable_plugin neutron-lbaas git://git.openstack.org/openstack/neutron-lbaas stable/ocata +enable_service q-lbaasv2 +NEUTRON_LBAAS_SERVICE_PROVIDERV2="LOADBALANCERV2:Haproxy:neutron_lbaas.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default" + +# Kubernetes +enable_plugin stackube git://git.openstack.org/openstack/stackube +enable_service stackube +# Enable kubernetes master components +enable_service kubernetes_master + +# Cinder +ENABLE_CEPH_CINDER=True +enable_service cinder c-api c-vol c-sch c-bak +enable_plugin devstack-plugin-ceph git://git.openstack.org/openstack/devstack-plugin-ceph diff --git a/devstack/plugin.sh b/devstack/plugin.sh new file mode 100644 index 0000000..fce1735 --- /dev/null +++ b/devstack/plugin.sh @@ -0,0 +1,215 @@ +#!/bin/bash +STACKUBE_ROOT=$(dirname "${BASH_SOURCE}") + +function configure_cni { + sudo mkdir -p /etc/cni/net.d + sudo sh -c "cat >/etc/cni/net.d/10-mynet.conf </etc/cni/net.d/99-loopback.conf < /dev/null 2>&1; then + echo "hyperd already installed on this host, using it instead" + else + curl -sSL https://hypercontainer.io/install | sudo bash + fi + sudo sh -c 'cat>/etc/hyper/config < /dev/null 2>&1; then + sudo rm -f /usr/bin/frakti + fi + sudo curl -sSL https://github.com/kubernetes/frakti/releases/download/${FRAKTI_VERSION}/frakti -o /usr/bin/frakti + sudo chmod +x /usr/bin/frakti + cgroup_driver=$(sudo docker info | awk '/Cgroup Driver/{print $3}') + sudo sh -c "cat > /lib/systemd/system/frakti.service < /etc/yum.repos.d/kubernetes.repo < /etc/apt/sources.list.d/kubernetes.list <