blob: b307023bec7231a5d3c3cfe7af5e39586de6d34f [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
Gary Wu9bb778b2019-06-21 16:16:18 -070023echo "__nfs_volume_id__" > /opt/config/nfs_volume_id.txt
Gary Wud95bf2b2019-06-21 15:35:18 -070024echo "__nfs_ip_addr__" > /opt/config/nfs_ip_addr.txt
Gary Wu9bb778b2019-06-21 16:16:18 -070025echo "__nfs_private_ip_addr__" > /opt/config/nfs_private_ip_addr.txt
Gary Wu950a3232019-03-26 13:08:29 -070026echo "__k8s_vm_ips__" > /opt/config/k8s_vm_ips.txt
27echo "__k8s_private_ips__" > /opt/config/k8s_private_ips.txt
28echo "__public_net_id__" > /opt/config/public_net_id.txt
29echo "__oam_network_cidr__" > /opt/config/oam_network_cidr.txt
30echo "__oam_network_id__" > /opt/config/oam_network_id.txt
31echo "__oam_subnet_id__" > /opt/config/oam_subnet_id.txt
32echo "__sec_group__" > /opt/config/sec_group.txt
33echo "__integration_gerrit_branch__" > /opt/config/integration_gerrit_branch.txt
34echo "__integration_gerrit_refspec__" > /opt/config/integration_gerrit_refspec.txt
35echo "__oom_gerrit_branch__" > /opt/config/oom_gerrit_branch.txt
36echo "__oom_gerrit_refspec__" > /opt/config/oom_gerrit_refspec.txt
37echo "__docker_manifest__" > /opt/config/docker_manifest.txt
38echo "__docker_proxy__" > /opt/config/docker_proxy.txt
39echo "__docker_version__" > /opt/config/docker_version.txt
Gary Wu950a3232019-03-26 13:08:29 -070040echo "__kubectl_version__" > /opt/config/kubectl_version.txt
41echo "__helm_version__" > /opt/config/helm_version.txt
42echo "__helm_deploy_delay__" > /opt/config/helm_deploy_delay.txt
43echo "__mtu__" > /opt/config/mtu.txt
44echo "__portal_hostname__" > /opt/config/portal_hostname.txt
45
46cat <<EOF > /opt/config/integration-override.yaml
47__integration_override_yaml__
48EOF
49sed -i 's/\_\_portal_hostname__/__portal_hostname__/g' /opt/config/integration-override.yaml
50sed -i 's/\_\_public_net_id__/__public_net_id__/g' /opt/config/integration-override.yaml
51sed -i 's|\_\_oam_network_cidr__|__oam_network_cidr__|g' /opt/config/integration-override.yaml
52sed -i 's/\_\_oam_network_id__/__oam_network_id__/g' /opt/config/integration-override.yaml
53sed -i 's/\_\_oam_subnet_id__/__oam_subnet_id__/g' /opt/config/integration-override.yaml
54sed -i 's/\_\_sec_group__/__sec_group__/g' /opt/config/integration-override.yaml
Gary Wud95bf2b2019-06-21 15:35:18 -070055sed -i 's/\_\_nfs_ip_addr__/__nfs_ip_addr__/g' /opt/config/integration-override.yaml
Gary Wu950a3232019-03-26 13:08:29 -070056sed -i 's/\_\_k8s_01_vm_ip__/__k8s_01_vm_ip__/g' /opt/config/integration-override.yaml
57sed -i 's/\_\_docker_proxy__/__docker_proxy__/g' /opt/config/integration-override.yaml
58cp /opt/config/integration-override.yaml /root
59cat /root/integration-override.yaml
60
61mkdir -p /etc/docker
62if [ ! -z "__docker_proxy__" ]; then
63 cat > /etc/docker/daemon.json <<EOF
64{
65 "mtu": __mtu__,
66 "insecure-registries" : ["__docker_proxy__"]
67}
68EOF
69else
70 cat > /etc/docker/daemon.json <<EOF
71{
72 "mtu": __mtu__
73}
74EOF
75fi
76if [ ! -z "__apt_proxy__" ]; then
77 cat > /etc/apt/apt.conf.d/30proxy<<EOF
78Acquire::http { Proxy "http://__apt_proxy__"; };
79Acquire::https::Proxy "DIRECT";
80EOF
81fi
82
83# workaround for OpenStack intermittent failure to change default apt mirrors
84sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list
85
86while ! hash jq &> /dev/null; do
87 apt-get -y update
Gary Wu9bb778b2019-06-21 16:16:18 -070088 apt-get -y install curl jq make nfs-kernel-server moreutils zfsutils-linux
Gary Wu950a3232019-03-26 13:08:29 -070089 sleep 10
90done
91
Gary Wu9bb778b2019-06-21 16:16:18 -070092nfs_volume_dev="/dev/disk/by-id/virtio-$(echo "__nfs_volume_id__" | cut -c -20)"
93
94zpool create -f -m /dockerdata-nfs dockerdata-nfs $nfs_volume_dev
95zfs set compression=lz4 dockerdata-nfs
96zfs set sharenfs="rw=*" dockerdata-nfs
Gary Wu950a3232019-03-26 13:08:29 -070097
Gary Wu950a3232019-03-26 13:08:29 -070098# update and initialize git
Gary Wud95bf2b2019-06-21 15:35:18 -070099git config --global user.email root@nfs
100git config --global user.name root@nfs
Gary Wu950a3232019-03-26 13:08:29 -0700101git 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
Gary Wu0bc69832019-03-27 13:58:46 -0700111
112
Gary Wu950a3232019-03-26 13:08:29 -0700113cd ~
114
115# install kubectl __kubectl_version__
116curl -s -LO https://storage.googleapis.com/kubernetes-release/release/v__kubectl_version__/bin/linux/amd64/kubectl
117chmod +x ./kubectl
118sudo mv ./kubectl /usr/local/bin/kubectl
Gary Wu0bc69832019-03-27 13:58:46 -0700119mkdir -p ~/.kube
Gary Wu950a3232019-03-26 13:08:29 -0700120
121# install helm __helm_version__
122mkdir -p helm
123pushd helm
124wget -q http://storage.googleapis.com/kubernetes-helm/helm-v__helm_version__-linux-amd64.tar.gz
125tar -zxvf helm-v__helm_version__-linux-amd64.tar.gz
126sudo cp linux-amd64/helm /usr/local/bin/helm
127popd
128
Gary Wu950a3232019-03-26 13:08:29 -0700129
130
131
Gary Wu0bc69832019-03-27 13:58:46 -0700132# Clone OOM repo
Gary Wu950a3232019-03-26 13:08:29 -0700133cd ~
Gary Wuabf01f72019-04-30 08:08:28 -0700134git clone --recurse-submodules -b __oom_gerrit_branch__ https://gerrit.onap.org/r/oom
Gary Wu950a3232019-03-26 13:08:29 -0700135cd oom
136if [ ! -z "__oom_gerrit_refspec__" ]; then
137 git fetch https://gerrit.onap.org/r/oom __oom_gerrit_refspec__
138 git checkout FETCH_HEAD
139fi
140git checkout -b workarounds
141git log -1
142
Gary Wu0bc69832019-03-27 13:58:46 -0700143# Clone integration repo
Gary Wu950a3232019-03-26 13:08:29 -0700144cd ~
145git clone -b __integration_gerrit_branch__ https://gerrit.onap.org/r/integration
146cd integration
147if [ ! -z "__integration_gerrit_refspec__" ]; then
148 git fetch https://gerrit.onap.org/r/integration __integration_gerrit_refspec__
149 git checkout FETCH_HEAD
150fi
151
152
153if [ ! -z "__docker_manifest__" ]; then
154 cd version-manifest/src/main/scripts
155 ./update-oom-image-versions.sh ../resources/__docker_manifest__ ~/oom/
156fi
157
158cd ~/oom
159git diff
Gary Wu7e835452019-04-30 10:57:51 -0700160git submodule foreach --recursive 'git commit -a -m "apply manifest versions" || :'
Gary Wu950a3232019-03-26 13:08:29 -0700161git commit -a -m "apply manifest versions"
162
163cd ~/oom
164# workaround to change onap portal cookie domain
Gary Wua7f1a942019-04-15 09:09:20 -0700165#sed -i "s/^cookie_domain.*=.*/cookie_domain = __portal_hostname__/g" ./kubernetes/portal/charts/portal-app/resources/config/deliveries/properties/ONAPPORTAL/system.properties
166#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 -0700167git diff
168git commit -a -m "set portal cookie domain"
169
170git tag -a "deploy0" -m "initial deployment"
171
172
Gary Wu0bc69832019-03-27 13:58:46 -0700173
174
175
176
177
178# wait for /root/.kube/config to show up; will be placed by deploy script after RKE completes
179while [ ! -e /root/.kube/config ]; do
180 sleep 1m
181done
182
183
184NAMESPACE=onap
185export KUBECONFIG=/root/.kube/config
186kubectl config set-context $(kubectl config current-context) --namespace=$NAMESPACE
187kubectl config view
188
189
190# Enable auto-completion for kubectl
191echo "source <(kubectl completion bash)" >> ~/.bashrc
192
193
194until [ $(kubectl get cs | tail -n +2 | grep -c Healthy) -ge 5 ]; do
195 sleep 1m
196done
197
198
199# install tiller/helm
Gary Wu950a3232019-03-26 13:08:29 -0700200kubectl -n kube-system create serviceaccount tiller
201kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
202helm init --service-account tiller
203kubectl -n kube-system rollout status deploy/tiller-deploy
Gary Wu950a3232019-03-26 13:08:29 -0700204helm serve &
205sleep 10
Gary Wu0bc69832019-03-27 13:58:46 -0700206
207# Make ONAP helm charts
208cd ~/oom/kubernetes/
Gary Wu950a3232019-03-26 13:08:29 -0700209helm repo add local http://127.0.0.1:8879
210helm repo list
211make all
212helm search -l | grep local
213
214# install helm deploy plugin
215rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
216# temporary workaround to throttle the helm deploy to alleviate startup disk contention issues
217if [ ! -z "__helm_deploy_delay__" ]; then
218 sed -i "/\^enabled:/a\ echo sleep __helm_deploy_delay__\n sleep __helm_deploy_delay__" ~/.helm/plugins/deploy/deploy.sh
Gary Wua56df522019-06-07 00:34:43 -0700219 sed -i 's/for subchart in \*/for subchart in aaf cassandra mariadb-galera dmaap */' ~/.helm/plugins/deploy/deploy.sh
Gary Wu950a3232019-03-26 13:08:29 -0700220fi
221
Gary Wu0bc69832019-03-27 13:58:46 -0700222# Deploy ONAP
Gary Wu950a3232019-03-26 13:08:29 -0700223helm deploy dev local/onap -f ~/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f ~/integration-override.yaml --namespace $NAMESPACE --verbose
224
225# re-install original helm deploy plugin
226rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
227
228helm list
229
230
231
232# Check ONAP status:
233sleep 10
234kubectl get pods --all-namespaces
235kubectl get nodes
236kubectl top nodes