blob: 65c16dacee2786c73bca28f60ec91f83450dc362 [file] [log] [blame]
Gary Wu950a3232019-03-26 13:08:29 -07001#!/bin/bash -x
2#
3# Copyright 2018 Huawei Technologies Co., Ltd.
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
12# allow root login
13export HOME=/root
14mkdir -p ~/.ssh
15cp ~ubuntu/.ssh/authorized_keys ~/.ssh
16
17export DEBIAN_FRONTEND=noninteractive
18HOST_IP=$(hostname -I)
19echo $HOST_IP `hostname` >> /etc/hosts
20printenv
21
22mkdir -p /opt/config
23echo "__rancher_ip_addr__" > /opt/config/rancher_ip_addr.txt
24echo "__k8s_vm_ips__" > /opt/config/k8s_vm_ips.txt
25echo "__k8s_private_ips__" > /opt/config/k8s_private_ips.txt
26echo "__public_net_id__" > /opt/config/public_net_id.txt
27echo "__oam_network_cidr__" > /opt/config/oam_network_cidr.txt
28echo "__oam_network_id__" > /opt/config/oam_network_id.txt
29echo "__oam_subnet_id__" > /opt/config/oam_subnet_id.txt
30echo "__sec_group__" > /opt/config/sec_group.txt
31echo "__integration_gerrit_branch__" > /opt/config/integration_gerrit_branch.txt
32echo "__integration_gerrit_refspec__" > /opt/config/integration_gerrit_refspec.txt
33echo "__oom_gerrit_branch__" > /opt/config/oom_gerrit_branch.txt
34echo "__oom_gerrit_refspec__" > /opt/config/oom_gerrit_refspec.txt
35echo "__docker_manifest__" > /opt/config/docker_manifest.txt
36echo "__docker_proxy__" > /opt/config/docker_proxy.txt
37echo "__docker_version__" > /opt/config/docker_version.txt
Gary Wu950a3232019-03-26 13:08:29 -070038echo "__kubectl_version__" > /opt/config/kubectl_version.txt
39echo "__helm_version__" > /opt/config/helm_version.txt
40echo "__helm_deploy_delay__" > /opt/config/helm_deploy_delay.txt
41echo "__mtu__" > /opt/config/mtu.txt
42echo "__portal_hostname__" > /opt/config/portal_hostname.txt
43
44cat <<EOF > /opt/config/integration-override.yaml
45__integration_override_yaml__
46EOF
47sed -i 's/\_\_portal_hostname__/__portal_hostname__/g' /opt/config/integration-override.yaml
48sed -i 's/\_\_public_net_id__/__public_net_id__/g' /opt/config/integration-override.yaml
49sed -i 's|\_\_oam_network_cidr__|__oam_network_cidr__|g' /opt/config/integration-override.yaml
50sed -i 's/\_\_oam_network_id__/__oam_network_id__/g' /opt/config/integration-override.yaml
51sed -i 's/\_\_oam_subnet_id__/__oam_subnet_id__/g' /opt/config/integration-override.yaml
52sed -i 's/\_\_sec_group__/__sec_group__/g' /opt/config/integration-override.yaml
53sed -i 's/\_\_rancher_ip_addr__/__rancher_ip_addr__/g' /opt/config/integration-override.yaml
54sed -i 's/\_\_k8s_01_vm_ip__/__k8s_01_vm_ip__/g' /opt/config/integration-override.yaml
55sed -i 's/\_\_docker_proxy__/__docker_proxy__/g' /opt/config/integration-override.yaml
56cp /opt/config/integration-override.yaml /root
57cat /root/integration-override.yaml
58
59mkdir -p /etc/docker
60if [ ! -z "__docker_proxy__" ]; then
61 cat > /etc/docker/daemon.json <<EOF
62{
63 "mtu": __mtu__,
64 "insecure-registries" : ["__docker_proxy__"]
65}
66EOF
67else
68 cat > /etc/docker/daemon.json <<EOF
69{
70 "mtu": __mtu__
71}
72EOF
73fi
74if [ ! -z "__apt_proxy__" ]; then
75 cat > /etc/apt/apt.conf.d/30proxy<<EOF
76Acquire::http { Proxy "http://__apt_proxy__"; };
77Acquire::https::Proxy "DIRECT";
78EOF
79fi
80
81# workaround for OpenStack intermittent failure to change default apt mirrors
82sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list
83
84while ! hash jq &> /dev/null; do
85 apt-get -y update
Gary Wu0bc69832019-03-27 13:58:46 -070086 apt-get -y install curl jq make nfs-kernel-server moreutils
Gary Wu950a3232019-03-26 13:08:29 -070087 sleep 10
88done
89
90mkdir -p /dockerdata-nfs
91
92# use RAM disk for /dockerdata-nfs for testing
93if [ "__use_ramdisk__" = "true" ]; then
94 echo "tmpfs /dockerdata-nfs tmpfs noatime,size=75% 1 2" >> /etc/fstab
95 mount /dockerdata-nfs
96fi
97
98# update and initialize git
99git config --global user.email root@rancher
100git config --global user.name root@rancher
101git config --global log.decorate auto
102
103# version control the persistence volume to see what's happening
104chmod 777 /dockerdata-nfs/
105chown nobody:nogroup /dockerdata-nfs/
106cd /dockerdata-nfs/
107git init
Gary Wu950a3232019-03-26 13:08:29 -0700108git add -A
109git commit -m "initial commit"
110
111# export NFS mount
112echo "/dockerdata-nfs *(rw,fsid=1,async,no_root_squash,no_subtree_check)" | tee /etc/exports
Gary Wu950a3232019-03-26 13:08:29 -0700113exportfs -a
114systemctl restart nfs-kernel-server
115
Gary Wu0bc69832019-03-27 13:58:46 -0700116
117
Gary Wu950a3232019-03-26 13:08:29 -0700118cd ~
119
120# install kubectl __kubectl_version__
121curl -s -LO https://storage.googleapis.com/kubernetes-release/release/v__kubectl_version__/bin/linux/amd64/kubectl
122chmod +x ./kubectl
123sudo mv ./kubectl /usr/local/bin/kubectl
Gary Wu0bc69832019-03-27 13:58:46 -0700124mkdir -p ~/.kube
Gary Wu950a3232019-03-26 13:08:29 -0700125
126# install helm __helm_version__
127mkdir -p helm
128pushd helm
129wget -q http://storage.googleapis.com/kubernetes-helm/helm-v__helm_version__-linux-amd64.tar.gz
130tar -zxvf helm-v__helm_version__-linux-amd64.tar.gz
131sudo cp linux-amd64/helm /usr/local/bin/helm
132popd
133
Gary Wu950a3232019-03-26 13:08:29 -0700134
135
136
Gary Wu0bc69832019-03-27 13:58:46 -0700137# Clone OOM repo
Gary Wu950a3232019-03-26 13:08:29 -0700138cd ~
Gary Wuabf01f72019-04-30 08:08:28 -0700139git clone --recurse-submodules -b __oom_gerrit_branch__ https://gerrit.onap.org/r/oom
Gary Wu950a3232019-03-26 13:08:29 -0700140cd oom
141if [ ! -z "__oom_gerrit_refspec__" ]; then
142 git fetch https://gerrit.onap.org/r/oom __oom_gerrit_refspec__
143 git checkout FETCH_HEAD
144fi
145git checkout -b workarounds
146git log -1
147
Gary Wu0bc69832019-03-27 13:58:46 -0700148# Clone integration repo
Gary Wu950a3232019-03-26 13:08:29 -0700149cd ~
150git clone -b __integration_gerrit_branch__ https://gerrit.onap.org/r/integration
151cd integration
152if [ ! -z "__integration_gerrit_refspec__" ]; then
153 git fetch https://gerrit.onap.org/r/integration __integration_gerrit_refspec__
154 git checkout FETCH_HEAD
155fi
156
157
158if [ ! -z "__docker_manifest__" ]; then
159 cd version-manifest/src/main/scripts
160 ./update-oom-image-versions.sh ../resources/__docker_manifest__ ~/oom/
161fi
162
163cd ~/oom
164git diff
Gary Wu7e835452019-04-30 10:57:51 -0700165git submodule foreach --recursive 'git commit -a -m "apply manifest versions" || :'
Gary Wu950a3232019-03-26 13:08:29 -0700166git commit -a -m "apply manifest versions"
167
168cd ~/oom
169# workaround to change onap portal cookie domain
Gary Wua7f1a942019-04-15 09:09:20 -0700170#sed -i "s/^cookie_domain.*=.*/cookie_domain = __portal_hostname__/g" ./kubernetes/portal/charts/portal-app/resources/config/deliveries/properties/ONAPPORTAL/system.properties
171#sed -i "s/^cookie_domain.*=.*/cookie_domain = __portal_hostname__/g" ./kubernetes/portal/charts/portal-sdk/resources/config/deliveries/properties/ONAPPORTALSDK/system.properties
Gary Wu950a3232019-03-26 13:08:29 -0700172git diff
173git commit -a -m "set portal cookie domain"
174
175git tag -a "deploy0" -m "initial deployment"
176
177
Gary Wu0bc69832019-03-27 13:58:46 -0700178
179
180
181
182
183# wait for /root/.kube/config to show up; will be placed by deploy script after RKE completes
184while [ ! -e /root/.kube/config ]; do
185 sleep 1m
186done
187
188
189NAMESPACE=onap
190export KUBECONFIG=/root/.kube/config
191kubectl config set-context $(kubectl config current-context) --namespace=$NAMESPACE
192kubectl config view
193
194
195# Enable auto-completion for kubectl
196echo "source <(kubectl completion bash)" >> ~/.bashrc
197
198
199until [ $(kubectl get cs | tail -n +2 | grep -c Healthy) -ge 5 ]; do
200 sleep 1m
201done
202
203
204# install tiller/helm
Gary Wu950a3232019-03-26 13:08:29 -0700205kubectl -n kube-system create serviceaccount tiller
206kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
207helm init --service-account tiller
208kubectl -n kube-system rollout status deploy/tiller-deploy
Gary Wu950a3232019-03-26 13:08:29 -0700209helm serve &
210sleep 10
Gary Wu0bc69832019-03-27 13:58:46 -0700211
212# Make ONAP helm charts
213cd ~/oom/kubernetes/
Gary Wu950a3232019-03-26 13:08:29 -0700214helm repo add local http://127.0.0.1:8879
215helm repo list
216make all
217helm search -l | grep local
218
219# install helm deploy plugin
220rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
221# temporary workaround to throttle the helm deploy to alleviate startup disk contention issues
222if [ ! -z "__helm_deploy_delay__" ]; then
223 sed -i "/\^enabled:/a\ echo sleep __helm_deploy_delay__\n sleep __helm_deploy_delay__" ~/.helm/plugins/deploy/deploy.sh
224fi
225
Gary Wu0bc69832019-03-27 13:58:46 -0700226# Deploy ONAP
Gary Wu950a3232019-03-26 13:08:29 -0700227helm deploy dev local/onap -f ~/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f ~/integration-override.yaml --namespace $NAMESPACE --verbose
228
229# re-install original helm deploy plugin
230rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
231
232helm list
233
234
235
236# Check ONAP status:
237sleep 10
238kubectl get pods --all-namespaces
239kubectl get nodes
240kubectl top nodes