3 # Copyright 2018 Huawei Technologies Co., Ltd.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
15 cp ~ubuntu/.ssh/authorized_keys ~/.ssh
17 export DEBIAN_FRONTEND=noninteractive
18 HOST_IP=$(hostname -I)
19 echo $HOST_IP `hostname` >> /etc/hosts
23 echo "__rancher_ip_addr__" > /opt/config/rancher_ip_addr.txt
24 echo "__k8s_vm_ips__" > /opt/config/k8s_vm_ips.txt
25 echo "__k8s_private_ips__" > /opt/config/k8s_private_ips.txt
26 echo "__public_net_id__" > /opt/config/public_net_id.txt
27 echo "__oam_network_cidr__" > /opt/config/oam_network_cidr.txt
28 echo "__oam_network_id__" > /opt/config/oam_network_id.txt
29 echo "__oam_subnet_id__" > /opt/config/oam_subnet_id.txt
30 echo "__sec_group__" > /opt/config/sec_group.txt
31 echo "__integration_gerrit_branch__" > /opt/config/integration_gerrit_branch.txt
32 echo "__integration_gerrit_refspec__" > /opt/config/integration_gerrit_refspec.txt
33 echo "__oom_gerrit_branch__" > /opt/config/oom_gerrit_branch.txt
34 echo "__oom_gerrit_refspec__" > /opt/config/oom_gerrit_refspec.txt
35 echo "__docker_manifest__" > /opt/config/docker_manifest.txt
36 echo "__docker_proxy__" > /opt/config/docker_proxy.txt
37 echo "__docker_version__" > /opt/config/docker_version.txt
38 echo "__rancher_version__" > /opt/config/rancher_version.txt
39 echo "__rancher_agent_version__" > /opt/config/rancher_agent_version.txt
40 echo "__kubectl_version__" > /opt/config/kubectl_version.txt
41 echo "__helm_version__" > /opt/config/helm_version.txt
42 echo "__helm_deploy_delay__" > /opt/config/helm_deploy_delay.txt
43 echo "__mtu__" > /opt/config/mtu.txt
44 echo "__portal_hostname__" > /opt/config/portal_hostname.txt
46 cat <<EOF > /opt/config/integration-override.yaml
47 __integration_override_yaml__
49 sed -i 's/\_\_portal_hostname__/__portal_hostname__/g' /opt/config/integration-override.yaml
50 sed -i 's/\_\_public_net_id__/__public_net_id__/g' /opt/config/integration-override.yaml
51 sed -i 's|\_\_oam_network_cidr__|__oam_network_cidr__|g' /opt/config/integration-override.yaml
52 sed -i 's/\_\_oam_network_id__/__oam_network_id__/g' /opt/config/integration-override.yaml
53 sed -i 's/\_\_oam_subnet_id__/__oam_subnet_id__/g' /opt/config/integration-override.yaml
54 sed -i 's/\_\_sec_group__/__sec_group__/g' /opt/config/integration-override.yaml
55 sed -i 's/\_\_rancher_ip_addr__/__rancher_ip_addr__/g' /opt/config/integration-override.yaml
56 sed -i 's/\_\_k8s_01_vm_ip__/__k8s_01_vm_ip__/g' /opt/config/integration-override.yaml
57 sed -i 's/\_\_docker_proxy__/__docker_proxy__/g' /opt/config/integration-override.yaml
58 cp /opt/config/integration-override.yaml /root
59 cat /root/integration-override.yaml
62 if [ ! -z "__docker_proxy__" ]; then
63 cat > /etc/docker/daemon.json <<EOF
66 "insecure-registries" : ["__docker_proxy__"]
70 cat > /etc/docker/daemon.json <<EOF
76 if [ ! -z "__apt_proxy__" ]; then
77 cat > /etc/apt/apt.conf.d/30proxy<<EOF
78 Acquire::http { Proxy "http://__apt_proxy__"; };
79 Acquire::https::Proxy "DIRECT";
83 # workaround for OpenStack intermittent failure to change default apt mirrors
84 sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list
86 while ! hash jq &> /dev/null; do
88 apt-get -y install curl jq make nfs-kernel-server moreutils
92 mkdir -p /dockerdata-nfs
94 # use RAM disk for /dockerdata-nfs for testing
95 if [ "__use_ramdisk__" = "true" ]; then
96 echo "tmpfs /dockerdata-nfs tmpfs noatime,size=75% 1 2" >> /etc/fstab
100 # update and initialize git
101 git config --global user.email root@rancher
102 git config --global user.name root@rancher
103 git config --global log.decorate auto
105 # version control the persistence volume to see what's happening
106 chmod 777 /dockerdata-nfs/
107 chown nobody:nogroup /dockerdata-nfs/
111 git commit -m "initial commit"
114 echo "/dockerdata-nfs *(rw,fsid=1,async,no_root_squash,no_subtree_check)" | tee /etc/exports
116 systemctl restart nfs-kernel-server
122 # install kubectl __kubectl_version__
123 curl -s -LO https://storage.googleapis.com/kubernetes-release/release/v__kubectl_version__/bin/linux/amd64/kubectl
125 sudo mv ./kubectl /usr/local/bin/kubectl
128 # install helm __helm_version__
131 wget -q http://storage.googleapis.com/kubernetes-helm/helm-v__helm_version__-linux-amd64.tar.gz
132 tar -zxvf helm-v__helm_version__-linux-amd64.tar.gz
133 sudo cp linux-amd64/helm /usr/local/bin/helm
141 git clone -b __oom_gerrit_branch__ https://gerrit.onap.org/r/oom
143 if [ ! -z "__oom_gerrit_refspec__" ]; then
144 git fetch https://gerrit.onap.org/r/oom __oom_gerrit_refspec__
145 git checkout FETCH_HEAD
147 git checkout -b workarounds
150 # Clone integration repo
152 git clone -b __integration_gerrit_branch__ https://gerrit.onap.org/r/integration
154 if [ ! -z "__integration_gerrit_refspec__" ]; then
155 git fetch https://gerrit.onap.org/r/integration __integration_gerrit_refspec__
156 git checkout FETCH_HEAD
160 if [ ! -z "__docker_manifest__" ]; then
161 cd version-manifest/src/main/scripts
162 ./update-oom-image-versions.sh ../resources/__docker_manifest__ ~/oom/
167 git commit -a -m "apply manifest versions"
170 # workaround to change onap portal cookie domain
171 sed -i "s/^cookie_domain.*=.*/cookie_domain = __portal_hostname__/g" ./kubernetes/portal/charts/portal-app/resources/config/deliveries/properties/ONAPPORTAL/system.properties
172 sed -i "s/^cookie_domain.*=.*/cookie_domain = __portal_hostname__/g" ./kubernetes/portal/charts/portal-sdk/resources/config/deliveries/properties/ONAPPORTALSDK/system.properties
174 git commit -a -m "set portal cookie domain"
176 git tag -a "deploy0" -m "initial deployment"
184 # wait for /root/.kube/config to show up; will be placed by deploy script after RKE completes
185 while [ ! -e /root/.kube/config ]; do
191 export KUBECONFIG=/root/.kube/config
192 kubectl config set-context $(kubectl config current-context) --namespace=$NAMESPACE
196 # Enable auto-completion for kubectl
197 echo "source <(kubectl completion bash)" >> ~/.bashrc
200 until [ $(kubectl get cs | tail -n +2 | grep -c Healthy) -ge 5 ]; do
205 # install tiller/helm
206 kubectl -n kube-system create serviceaccount tiller
207 kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
208 helm init --service-account tiller
209 kubectl -n kube-system rollout status deploy/tiller-deploy
213 # Make ONAP helm charts
215 helm repo add local http://127.0.0.1:8879
218 helm search -l | grep local
220 # install helm deploy plugin
221 rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
222 # temporary workaround to throttle the helm deploy to alleviate startup disk contention issues
223 if [ ! -z "__helm_deploy_delay__" ]; then
224 sed -i "/\^enabled:/a\ echo sleep __helm_deploy_delay__\n sleep __helm_deploy_delay__" ~/.helm/plugins/deploy/deploy.sh
228 helm deploy dev local/onap -f ~/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f ~/integration-override.yaml --namespace $NAMESPACE --verbose
230 # re-install original helm deploy plugin
231 rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
239 kubectl get pods --all-namespaces