From 6cdbe0e89cc275fab34afb0e3c9cb640bb1de26f Mon Sep 17 00:00:00 2001 From: Bryan Sullivan Date: Thu, 30 Nov 2017 14:34:45 -0800 Subject: Factor out build script for clearwater-docker etc JIRA: MODELS-2 Change-Id: I36f1f7c7b1a37bb34ad4e31240b2b27512348b52 Signed-off-by: Bryan Sullivan --- tools/cloudify/k8s-cloudify-clearwater.sh | 45 ++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'tools/cloudify/k8s-cloudify-clearwater.sh') diff --git a/tools/cloudify/k8s-cloudify-clearwater.sh b/tools/cloudify/k8s-cloudify-clearwater.sh index 800d357..430d31a 100644 --- a/tools/cloudify/k8s-cloudify-clearwater.sh +++ b/tools/cloudify/k8s-cloudify-clearwater.sh @@ -16,13 +16,20 @@ #. What this is: Setup script for clearwater-docker as deployed by Cloudify #. with Kubernetes. See https://github.com/Metaswitch/clearwater-docker #. for more info. +#. #. Prerequisites: #. - Kubernetes cluster installed per k8s-cluster.sh (in this repo) #. - user (running this script) added to the "docker" group +#. - clearwater-docker images created and uploaded to docker hub under the +#. account as /clearwater- where vnfc is the name +#. of the specific containers as built by build/clearwater-docker.sh +#. #. Usage: #. From a server with access to the kubernetes master node: #. $ git clone https://gerrit.opnfv.org/gerrit/models ~/models - +#. $ cd ~/models/tools/cloudify/ +#. $ bash k8s-cloudify-clearwater.sh +#. #. Status: this is a work in progress, under test. function fail() { @@ -37,7 +44,7 @@ function log() { echo "$f:$l ($(date)) $1" } -function setup() { +function build_local() { master=$1 log "deploy local docker registry on k8s master" # Per https://docs.docker.com/registry/deploying/ @@ -57,6 +64,27 @@ function setup() { docker build -t clearwater/$i $i done + # workaround for https://www.bountysource.com/issues/37326551-server-gave-http-response-to-https-client-error + # May not need both... + if [[ "$dist" == "ubuntu" ]]; then + check=$(grep -c $master /etc/default/docker) + if [[ $check -eq 0 ]]; then + echo "DOCKER_OPTS=\"--insecure-registry $master:5000\"" | sudo tee -a /etc/default/docker + sudo systemctl daemon-reload + sudo service docker restart + fi + fi + check=$(grep -c insecure-registry /lib/systemd/system/docker.service) + if [[ $check -eq 0 ]]; then + sudo sed -i -- "s~ExecStart=/usr/bin/dockerd -H fd://~ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry $master:5000~" /lib/systemd/system/docker.service + sudo systemctl daemon-reload + sudo service docker restart + fi + + log "deploy local docker registry on k8s master" + # Per https://docs.docker.com/registry/deploying/ + # sudo docker run -d -p 5000:5000 --restart=always --name registry registry:2 + log "push images to local docker repo on k8s master" for i in $vnfc ; do docker tag clearwater/$i:latest $master:5000/clearwater/$i:latest @@ -64,6 +92,7 @@ function setup() { done } + function start() { master=$1 } @@ -72,24 +101,14 @@ function stop() { master=$1 } -function clean() { - master=$1 -} - -dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'` +dist=$(grep --m 1 ID /etc/os-release | awk -F '=' '{print $2}') case "$1" in - "setup") - setup $2 - ;; "start") start $2 ;; "stop") stop $2 ;; - "clean") - clean - ;; *) grep '#. ' $0 esac -- cgit 1.2.3-korg