blob: bbab5df157f58778bba16d078db81eeea77b843f [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
Gary Wu950a3232019-03-26 13:08:29 -070037echo "__docker_proxy__" > /opt/config/docker_proxy.txt
38echo "__docker_version__" > /opt/config/docker_version.txt
Gary Wu950a3232019-03-26 13:08:29 -070039echo "__kubectl_version__" > /opt/config/kubectl_version.txt
40echo "__helm_version__" > /opt/config/helm_version.txt
41echo "__helm_deploy_delay__" > /opt/config/helm_deploy_delay.txt
42echo "__mtu__" > /opt/config/mtu.txt
43echo "__portal_hostname__" > /opt/config/portal_hostname.txt
44
45cat <<EOF > /opt/config/integration-override.yaml
46__integration_override_yaml__
47EOF
48sed -i 's/\_\_portal_hostname__/__portal_hostname__/g' /opt/config/integration-override.yaml
49sed -i 's/\_\_public_net_id__/__public_net_id__/g' /opt/config/integration-override.yaml
50sed -i 's|\_\_oam_network_cidr__|__oam_network_cidr__|g' /opt/config/integration-override.yaml
51sed -i 's/\_\_oam_network_id__/__oam_network_id__/g' /opt/config/integration-override.yaml
52sed -i 's/\_\_oam_subnet_id__/__oam_subnet_id__/g' /opt/config/integration-override.yaml
53sed -i 's/\_\_sec_group__/__sec_group__/g' /opt/config/integration-override.yaml
Gary Wud95bf2b2019-06-21 15:35:18 -070054sed -i 's/\_\_nfs_ip_addr__/__nfs_ip_addr__/g' /opt/config/integration-override.yaml
Gary Wu950a3232019-03-26 13:08:29 -070055sed -i 's/\_\_k8s_01_vm_ip__/__k8s_01_vm_ip__/g' /opt/config/integration-override.yaml
56sed -i 's/\_\_docker_proxy__/__docker_proxy__/g' /opt/config/integration-override.yaml
57cp /opt/config/integration-override.yaml /root
58cat /root/integration-override.yaml
59
60mkdir -p /etc/docker
61if [ ! -z "__docker_proxy__" ]; then
62 cat > /etc/docker/daemon.json <<EOF
63{
64 "mtu": __mtu__,
65 "insecure-registries" : ["__docker_proxy__"]
66}
67EOF
68else
69 cat > /etc/docker/daemon.json <<EOF
70{
71 "mtu": __mtu__
72}
73EOF
74fi
75if [ ! -z "__apt_proxy__" ]; then
76 cat > /etc/apt/apt.conf.d/30proxy<<EOF
77Acquire::http { Proxy "http://__apt_proxy__"; };
78Acquire::https::Proxy "DIRECT";
79EOF
80fi
81
82# workaround for OpenStack intermittent failure to change default apt mirrors
83sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list
84
85while ! hash jq &> /dev/null; do
86 apt-get -y update
Gary Wu9bb778b2019-06-21 16:16:18 -070087 apt-get -y install curl jq make nfs-kernel-server moreutils zfsutils-linux
Gary Wu950a3232019-03-26 13:08:29 -070088 sleep 10
89done
90
Gary Wu06b08122019-06-21 23:15:55 -070091sed -i 's/RPCNFSDCOUNT=.*/RPCNFSDCOUNT=32/' /etc/default/nfs-kernel-server
92service nfs-kernel-server restart
93
Gary Wu9bb778b2019-06-21 16:16:18 -070094nfs_volume_dev="/dev/disk/by-id/virtio-$(echo "__nfs_volume_id__" | cut -c -20)"
95
Konrad Bańkaa3990d02019-07-30 09:02:42 +020096until [ -b "$nfs_volume_dev" ]; do
97 sleep 1m
98done
99
Gary Wu9bb778b2019-06-21 16:16:18 -0700100zpool create -f -m /dockerdata-nfs dockerdata-nfs $nfs_volume_dev
101zfs set compression=lz4 dockerdata-nfs
102zfs set sharenfs="rw=*" dockerdata-nfs
Gary Wu950a3232019-03-26 13:08:29 -0700103
Gary Wu950a3232019-03-26 13:08:29 -0700104# update and initialize git
Konrad Bańkaa3990d02019-07-30 09:02:42 +0200105git config --system user.email root@nfs
106git config --system user.name root@nfs
107git config --system log.decorate auto
Gary Wu950a3232019-03-26 13:08:29 -0700108
109# version control the persistence volume to see what's happening
110chmod 777 /dockerdata-nfs/
111chown nobody:nogroup /dockerdata-nfs/
112cd /dockerdata-nfs/
113git init
Gary Wu950a3232019-03-26 13:08:29 -0700114git add -A
Konrad Bańkaa3990d02019-07-30 09:02:42 +0200115git commit -m "initial commit" --allow-empty
Gary Wu950a3232019-03-26 13:08:29 -0700116
Gary Wu0bc69832019-03-27 13:58:46 -0700117
118
Gary Wu950a3232019-03-26 13:08:29 -0700119cd ~
120
121# install kubectl __kubectl_version__
122curl -s -LO https://storage.googleapis.com/kubernetes-release/release/v__kubectl_version__/bin/linux/amd64/kubectl
123chmod +x ./kubectl
124sudo mv ./kubectl /usr/local/bin/kubectl
Gary Wu0bc69832019-03-27 13:58:46 -0700125mkdir -p ~/.kube
Gary Wu950a3232019-03-26 13:08:29 -0700126
127# install helm __helm_version__
128mkdir -p helm
129pushd helm
130wget -q http://storage.googleapis.com/kubernetes-helm/helm-v__helm_version__-linux-amd64.tar.gz
131tar -zxvf helm-v__helm_version__-linux-amd64.tar.gz
132sudo cp linux-amd64/helm /usr/local/bin/helm
133popd
134
Gary Wu950a3232019-03-26 13:08:29 -0700135
136
137
Gary Wu0bc69832019-03-27 13:58:46 -0700138# Clone OOM repo
Gary Wu950a3232019-03-26 13:08:29 -0700139cd ~
Gary Wuabf01f72019-04-30 08:08:28 -0700140git clone --recurse-submodules -b __oom_gerrit_branch__ https://gerrit.onap.org/r/oom
Gary Wu950a3232019-03-26 13:08:29 -0700141cd oom
142if [ ! -z "__oom_gerrit_refspec__" ]; then
143 git fetch https://gerrit.onap.org/r/oom __oom_gerrit_refspec__
144 git checkout FETCH_HEAD
145fi
146git checkout -b workarounds
147git log -1
148
Gary Wu0bc69832019-03-27 13:58:46 -0700149# Clone integration repo
Gary Wu950a3232019-03-26 13:08:29 -0700150cd ~
151git clone -b __integration_gerrit_branch__ https://gerrit.onap.org/r/integration
152cd integration
153if [ ! -z "__integration_gerrit_refspec__" ]; then
154 git fetch https://gerrit.onap.org/r/integration __integration_gerrit_refspec__
155 git checkout FETCH_HEAD
156fi
157
158
Gary Wu950a3232019-03-26 13:08:29 -0700159cd ~/oom
160# workaround to change onap portal cookie domain
Gary Wua7f1a942019-04-15 09:09:20 -0700161#sed -i "s/^cookie_domain.*=.*/cookie_domain = __portal_hostname__/g" ./kubernetes/portal/charts/portal-app/resources/config/deliveries/properties/ONAPPORTAL/system.properties
162#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 -0700163git diff
164git commit -a -m "set portal cookie domain"
165
166git tag -a "deploy0" -m "initial deployment"
167
168
Gary Wu0bc69832019-03-27 13:58:46 -0700169
170
171
172
173
174# wait for /root/.kube/config to show up; will be placed by deploy script after RKE completes
175while [ ! -e /root/.kube/config ]; do
176 sleep 1m
177done
178
179
180NAMESPACE=onap
181export KUBECONFIG=/root/.kube/config
182kubectl config set-context $(kubectl config current-context) --namespace=$NAMESPACE
183kubectl config view
184
185
186# Enable auto-completion for kubectl
187echo "source <(kubectl completion bash)" >> ~/.bashrc
188
189
190until [ $(kubectl get cs | tail -n +2 | grep -c Healthy) -ge 5 ]; do
191 sleep 1m
192done
193
194
195# install tiller/helm
Gary Wu950a3232019-03-26 13:08:29 -0700196kubectl -n kube-system create serviceaccount tiller
197kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
198helm init --service-account tiller
199kubectl -n kube-system rollout status deploy/tiller-deploy
Gary Wu950a3232019-03-26 13:08:29 -0700200helm serve &
201sleep 10
Gary Wu0bc69832019-03-27 13:58:46 -0700202
203# Make ONAP helm charts
204cd ~/oom/kubernetes/
Gary Wu950a3232019-03-26 13:08:29 -0700205helm repo add local http://127.0.0.1:8879
206helm repo list
207make all
208helm search -l | grep local
209
210# install helm deploy plugin
211rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
212# temporary workaround to throttle the helm deploy to alleviate startup disk contention issues
213if [ ! -z "__helm_deploy_delay__" ]; then
214 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 -0700215 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 -0700216fi
217
Gary Wu0bc69832019-03-27 13:58:46 -0700218# Deploy ONAP
Gary Wu950a3232019-03-26 13:08:29 -0700219helm deploy dev local/onap -f ~/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f ~/integration-override.yaml --namespace $NAMESPACE --verbose
220
221# re-install original helm deploy plugin
222rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
223
224helm list
225
226
227
228# Check ONAP status:
229sleep 10
230kubectl get pods --all-namespaces
231kubectl get nodes
232kubectl top nodes