~narindergupta/opnfv/stable-R2

640 by AakashKT
Scripts for deploying clearwater on kubernetes-cluster (with loadbalancer)
1
#!/bin/bash
2
3
# Copyright 2017 Aakash KT <aakashkt0@gmail.com> <aakash.kt@research.iiit.ac.in>
4
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at
8
9
#     http://www.apache.org/licenses/LICENSE-2.0
10
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
16
17
18
19
function setup_docker() {
20
	echo "Installing docker..."
21
	sudo apt-get install -y docker.io
22
23
	sudo docker login --username="aakashkt" --password="joid123"
24
}
25
26
function setup_clearwater() {
27
	echo "Preparing docker images..."
28
29
	git clone --recursive https://github.com/Metaswitch/clearwater-docker.git
30
	pushd clearwater-docker
31
32
	for i in base astaire cassandra chronos bono ellis homer homestead ralf sprout
33
	do
34
		sudo docker build -t clearwater/$i $i
35
	done
36
37
	for i in base astaire cassandra chronos bono ellis homer homestead ralf sprout
38
  	do
39
    	sudo docker tag clearwater/$i:latest $1/$i:latest
40
    	sudo docker push $1/$i:latest
41
	done
42
43
	popd
44
}
45
46
function setup_k8s() {
47
	echo "Preparing the k8s cluster..."
48
	python set_depl_files.py $1 $2
49
}
50
51
function deploy() {
52
	juju run --application kubeapi-load-balancer 'open-port 5060'
53
54
	juju run --application kubernetes-master 'open-port 30080'
55
	juju run --application kubernetes-worker 'open-port 30080'
56
57
	sudo kubectl create -f clearwater-docker/kubernetes
58
	echo "Done"
59
}
60
61
cp set_depl_files.py /tmp/
62
pushd /tmp/
63
64
juju run --application kubeapi-load-balancer 'unit-get public-address'
65
load_balancer_ip=$?
66
docker_repo="aakashkt"
67
68
setup_docker
69
setup_clearwater $docker_repo
70
setup_k8s $docker_repo $load_balancer_ip
71
deploy
72
73
popd