Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 1 | #!/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 |
| 13 | export HOME=/root |
| 14 | mkdir -p ~/.ssh |
| 15 | cp ~ubuntu/.ssh/authorized_keys ~/.ssh |
| 16 | |
| 17 | export DEBIAN_FRONTEND=noninteractive |
| 18 | HOST_IP=$(hostname -I) |
| 19 | echo $HOST_IP `hostname` >> /etc/hosts |
| 20 | printenv |
| 21 | |
| 22 | mkdir -p /opt/config |
Gary Wu | d95bf2b | 2019-06-21 15:35:18 -0700 | [diff] [blame^] | 23 | echo "__nfs_ip_addr__" > /opt/config/nfs_ip_addr.txt |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 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 |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 38 | echo "__kubectl_version__" > /opt/config/kubectl_version.txt |
| 39 | echo "__helm_version__" > /opt/config/helm_version.txt |
| 40 | echo "__helm_deploy_delay__" > /opt/config/helm_deploy_delay.txt |
| 41 | echo "__mtu__" > /opt/config/mtu.txt |
| 42 | echo "__portal_hostname__" > /opt/config/portal_hostname.txt |
| 43 | |
| 44 | cat <<EOF > /opt/config/integration-override.yaml |
| 45 | __integration_override_yaml__ |
| 46 | EOF |
| 47 | sed -i 's/\_\_portal_hostname__/__portal_hostname__/g' /opt/config/integration-override.yaml |
| 48 | sed -i 's/\_\_public_net_id__/__public_net_id__/g' /opt/config/integration-override.yaml |
| 49 | sed -i 's|\_\_oam_network_cidr__|__oam_network_cidr__|g' /opt/config/integration-override.yaml |
| 50 | sed -i 's/\_\_oam_network_id__/__oam_network_id__/g' /opt/config/integration-override.yaml |
| 51 | sed -i 's/\_\_oam_subnet_id__/__oam_subnet_id__/g' /opt/config/integration-override.yaml |
| 52 | sed -i 's/\_\_sec_group__/__sec_group__/g' /opt/config/integration-override.yaml |
Gary Wu | d95bf2b | 2019-06-21 15:35:18 -0700 | [diff] [blame^] | 53 | sed -i 's/\_\_nfs_ip_addr__/__nfs_ip_addr__/g' /opt/config/integration-override.yaml |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 54 | sed -i 's/\_\_k8s_01_vm_ip__/__k8s_01_vm_ip__/g' /opt/config/integration-override.yaml |
| 55 | sed -i 's/\_\_docker_proxy__/__docker_proxy__/g' /opt/config/integration-override.yaml |
| 56 | cp /opt/config/integration-override.yaml /root |
| 57 | cat /root/integration-override.yaml |
| 58 | |
| 59 | mkdir -p /etc/docker |
| 60 | if [ ! -z "__docker_proxy__" ]; then |
| 61 | cat > /etc/docker/daemon.json <<EOF |
| 62 | { |
| 63 | "mtu": __mtu__, |
| 64 | "insecure-registries" : ["__docker_proxy__"] |
| 65 | } |
| 66 | EOF |
| 67 | else |
| 68 | cat > /etc/docker/daemon.json <<EOF |
| 69 | { |
| 70 | "mtu": __mtu__ |
| 71 | } |
| 72 | EOF |
| 73 | fi |
| 74 | if [ ! -z "__apt_proxy__" ]; then |
| 75 | cat > /etc/apt/apt.conf.d/30proxy<<EOF |
| 76 | Acquire::http { Proxy "http://__apt_proxy__"; }; |
| 77 | Acquire::https::Proxy "DIRECT"; |
| 78 | EOF |
| 79 | fi |
| 80 | |
| 81 | # workaround for OpenStack intermittent failure to change default apt mirrors |
| 82 | sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list |
| 83 | |
| 84 | while ! hash jq &> /dev/null; do |
| 85 | apt-get -y update |
Gary Wu | 0bc6983 | 2019-03-27 13:58:46 -0700 | [diff] [blame] | 86 | apt-get -y install curl jq make nfs-kernel-server moreutils |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 87 | sleep 10 |
| 88 | done |
| 89 | |
| 90 | mkdir -p /dockerdata-nfs |
| 91 | |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 92 | # update and initialize git |
Gary Wu | d95bf2b | 2019-06-21 15:35:18 -0700 | [diff] [blame^] | 93 | git config --global user.email root@nfs |
| 94 | git config --global user.name root@nfs |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 95 | git config --global log.decorate auto |
| 96 | |
| 97 | # version control the persistence volume to see what's happening |
| 98 | chmod 777 /dockerdata-nfs/ |
| 99 | chown nobody:nogroup /dockerdata-nfs/ |
| 100 | cd /dockerdata-nfs/ |
| 101 | git init |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 102 | git add -A |
| 103 | git commit -m "initial commit" |
| 104 | |
| 105 | # export NFS mount |
| 106 | echo "/dockerdata-nfs *(rw,fsid=1,async,no_root_squash,no_subtree_check)" | tee /etc/exports |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 107 | exportfs -a |
| 108 | systemctl restart nfs-kernel-server |
| 109 | |
Gary Wu | 0bc6983 | 2019-03-27 13:58:46 -0700 | [diff] [blame] | 110 | |
| 111 | |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 112 | cd ~ |
| 113 | |
| 114 | # install kubectl __kubectl_version__ |
| 115 | curl -s -LO https://storage.googleapis.com/kubernetes-release/release/v__kubectl_version__/bin/linux/amd64/kubectl |
| 116 | chmod +x ./kubectl |
| 117 | sudo mv ./kubectl /usr/local/bin/kubectl |
Gary Wu | 0bc6983 | 2019-03-27 13:58:46 -0700 | [diff] [blame] | 118 | mkdir -p ~/.kube |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 119 | |
| 120 | # install helm __helm_version__ |
| 121 | mkdir -p helm |
| 122 | pushd helm |
| 123 | wget -q http://storage.googleapis.com/kubernetes-helm/helm-v__helm_version__-linux-amd64.tar.gz |
| 124 | tar -zxvf helm-v__helm_version__-linux-amd64.tar.gz |
| 125 | sudo cp linux-amd64/helm /usr/local/bin/helm |
| 126 | popd |
| 127 | |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 128 | |
| 129 | |
| 130 | |
Gary Wu | 0bc6983 | 2019-03-27 13:58:46 -0700 | [diff] [blame] | 131 | # Clone OOM repo |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 132 | cd ~ |
Gary Wu | abf01f7 | 2019-04-30 08:08:28 -0700 | [diff] [blame] | 133 | git clone --recurse-submodules -b __oom_gerrit_branch__ https://gerrit.onap.org/r/oom |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 134 | cd oom |
| 135 | if [ ! -z "__oom_gerrit_refspec__" ]; then |
| 136 | git fetch https://gerrit.onap.org/r/oom __oom_gerrit_refspec__ |
| 137 | git checkout FETCH_HEAD |
| 138 | fi |
| 139 | git checkout -b workarounds |
| 140 | git log -1 |
| 141 | |
Gary Wu | 0bc6983 | 2019-03-27 13:58:46 -0700 | [diff] [blame] | 142 | # Clone integration repo |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 143 | cd ~ |
| 144 | git clone -b __integration_gerrit_branch__ https://gerrit.onap.org/r/integration |
| 145 | cd integration |
| 146 | if [ ! -z "__integration_gerrit_refspec__" ]; then |
| 147 | git fetch https://gerrit.onap.org/r/integration __integration_gerrit_refspec__ |
| 148 | git checkout FETCH_HEAD |
| 149 | fi |
| 150 | |
| 151 | |
| 152 | if [ ! -z "__docker_manifest__" ]; then |
| 153 | cd version-manifest/src/main/scripts |
| 154 | ./update-oom-image-versions.sh ../resources/__docker_manifest__ ~/oom/ |
| 155 | fi |
| 156 | |
| 157 | cd ~/oom |
| 158 | git diff |
Gary Wu | 7e83545 | 2019-04-30 10:57:51 -0700 | [diff] [blame] | 159 | git submodule foreach --recursive 'git commit -a -m "apply manifest versions" || :' |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 160 | git commit -a -m "apply manifest versions" |
| 161 | |
| 162 | cd ~/oom |
| 163 | # workaround to change onap portal cookie domain |
Gary Wu | a7f1a94 | 2019-04-15 09:09:20 -0700 | [diff] [blame] | 164 | #sed -i "s/^cookie_domain.*=.*/cookie_domain = __portal_hostname__/g" ./kubernetes/portal/charts/portal-app/resources/config/deliveries/properties/ONAPPORTAL/system.properties |
| 165 | #sed -i "s/^cookie_domain.*=.*/cookie_domain = __portal_hostname__/g" ./kubernetes/portal/charts/portal-sdk/resources/config/deliveries/properties/ONAPPORTALSDK/system.properties |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 166 | git diff |
| 167 | git commit -a -m "set portal cookie domain" |
| 168 | |
| 169 | git tag -a "deploy0" -m "initial deployment" |
| 170 | |
| 171 | |
Gary Wu | 0bc6983 | 2019-03-27 13:58:46 -0700 | [diff] [blame] | 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | # wait for /root/.kube/config to show up; will be placed by deploy script after RKE completes |
| 178 | while [ ! -e /root/.kube/config ]; do |
| 179 | sleep 1m |
| 180 | done |
| 181 | |
| 182 | |
| 183 | NAMESPACE=onap |
| 184 | export KUBECONFIG=/root/.kube/config |
| 185 | kubectl config set-context $(kubectl config current-context) --namespace=$NAMESPACE |
| 186 | kubectl config view |
| 187 | |
| 188 | |
| 189 | # Enable auto-completion for kubectl |
| 190 | echo "source <(kubectl completion bash)" >> ~/.bashrc |
| 191 | |
| 192 | |
| 193 | until [ $(kubectl get cs | tail -n +2 | grep -c Healthy) -ge 5 ]; do |
| 194 | sleep 1m |
| 195 | done |
| 196 | |
| 197 | |
| 198 | # install tiller/helm |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 199 | kubectl -n kube-system create serviceaccount tiller |
| 200 | kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller |
| 201 | helm init --service-account tiller |
| 202 | kubectl -n kube-system rollout status deploy/tiller-deploy |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 203 | helm serve & |
| 204 | sleep 10 |
Gary Wu | 0bc6983 | 2019-03-27 13:58:46 -0700 | [diff] [blame] | 205 | |
| 206 | # Make ONAP helm charts |
| 207 | cd ~/oom/kubernetes/ |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 208 | helm repo add local http://127.0.0.1:8879 |
| 209 | helm repo list |
| 210 | make all |
| 211 | helm search -l | grep local |
| 212 | |
| 213 | # install helm deploy plugin |
| 214 | rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/ |
| 215 | # temporary workaround to throttle the helm deploy to alleviate startup disk contention issues |
| 216 | if [ ! -z "__helm_deploy_delay__" ]; then |
| 217 | sed -i "/\^enabled:/a\ echo sleep __helm_deploy_delay__\n sleep __helm_deploy_delay__" ~/.helm/plugins/deploy/deploy.sh |
Gary Wu | a56df52 | 2019-06-07 00:34:43 -0700 | [diff] [blame] | 218 | sed -i 's/for subchart in \*/for subchart in aaf cassandra mariadb-galera dmaap */' ~/.helm/plugins/deploy/deploy.sh |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 219 | fi |
| 220 | |
Gary Wu | 0bc6983 | 2019-03-27 13:58:46 -0700 | [diff] [blame] | 221 | # Deploy ONAP |
Gary Wu | 950a323 | 2019-03-26 13:08:29 -0700 | [diff] [blame] | 222 | helm deploy dev local/onap -f ~/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f ~/integration-override.yaml --namespace $NAMESPACE --verbose |
| 223 | |
| 224 | # re-install original helm deploy plugin |
| 225 | rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/ |
| 226 | |
| 227 | helm list |
| 228 | |
| 229 | |
| 230 | |
| 231 | # Check ONAP status: |
| 232 | sleep 10 |
| 233 | kubectl get pods --all-namespaces |
| 234 | kubectl get nodes |
| 235 | kubectl top nodes |