Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 1 | #!/bin/bash -x |
Gary Wu | a3fb86f | 2018-06-04 16:23:54 -0700 | [diff] [blame] | 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 | |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 12 | export DEBIAN_FRONTEND=noninteractive |
Gary Wu | 895a4ac | 2018-10-31 12:30:54 -0700 | [diff] [blame] | 13 | HOST_IP=$(hostname -I) |
| 14 | echo $HOST_IP `hostname` >> /etc/hosts |
Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 15 | printenv |
| 16 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 17 | mkdir -p /opt/config |
| 18 | echo "__rancher_ip_addr__" > /opt/config/rancher_ip_addr.txt |
| 19 | echo "__k8s_vm_ips__" > /opt/config/k8s_vm_ips.txt |
Gary Wu | ad51372 | 2018-07-26 13:08:47 -0700 | [diff] [blame] | 20 | echo "__k8s_private_ips__" > /opt/config/k8s_private_ips.txt |
Gary Wu | 978171e | 2018-07-24 11:56:01 -0700 | [diff] [blame] | 21 | echo "__public_net_id__" > /opt/config/public_net_id.txt |
| 22 | echo "__oam_network_cidr__" > /opt/config/oam_network_cidr.txt |
Gary Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 23 | echo "__oam_network_id__" > /opt/config/oam_network_id.txt |
| 24 | echo "__oam_subnet_id__" > /opt/config/oam_subnet_id.txt |
Gary Wu | 17440fe | 2018-10-22 15:12:07 -0700 | [diff] [blame] | 25 | echo "__sec_group__" > /opt/config/sec_group.txt |
Gary Wu | 87aa8b5 | 2018-08-09 08:10:24 -0700 | [diff] [blame] | 26 | echo "__integration_gerrit_branch__" > /opt/config/integration_gerrit_branch.txt |
| 27 | echo "__integration_gerrit_refspec__" > /opt/config/integration_gerrit_refspec.txt |
| 28 | echo "__oom_gerrit_branch__" > /opt/config/oom_gerrit_branch.txt |
| 29 | echo "__oom_gerrit_refspec__" > /opt/config/oom_gerrit_refspec.txt |
Gary Wu | 81836d2 | 2018-06-22 13:48:50 -0700 | [diff] [blame] | 30 | echo "__docker_manifest__" > /opt/config/docker_manifest.txt |
Gary Wu | 978171e | 2018-07-24 11:56:01 -0700 | [diff] [blame] | 31 | echo "__docker_proxy__" > /opt/config/docker_proxy.txt |
Gary Wu | 7a04b3d | 2018-08-15 12:31:46 -0700 | [diff] [blame] | 32 | echo "__docker_version__" > /opt/config/docker_version.txt |
| 33 | echo "__rancher_version__" > /opt/config/rancher_version.txt |
| 34 | echo "__rancher_agent_version__" > /opt/config/rancher_agent_version.txt |
| 35 | echo "__kubectl_version__" > /opt/config/kubectl_version.txt |
| 36 | echo "__helm_version__" > /opt/config/helm_version.txt |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 37 | echo "__helm_deploy_delay__" > /opt/config/helm_deploy_delay.txt |
Gary Wu | b8be70a | 2018-11-17 17:14:38 -0800 | [diff] [blame] | 38 | echo "__mtu__" > /opt/config/mtu.txt |
Gary Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 39 | |
| 40 | cat <<EOF > /opt/config/integration-override.yaml |
| 41 | __integration_override_yaml__ |
| 42 | EOF |
Gary Wu | 978171e | 2018-07-24 11:56:01 -0700 | [diff] [blame] | 43 | sed -i 's/\_\_public_net_id__/__public_net_id__/g' /opt/config/integration-override.yaml |
| 44 | sed -i 's|\_\_oam_network_cidr__|__oam_network_cidr__|g' /opt/config/integration-override.yaml |
Gary Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 45 | sed -i 's/\_\_oam_network_id__/__oam_network_id__/g' /opt/config/integration-override.yaml |
| 46 | sed -i 's/\_\_oam_subnet_id__/__oam_subnet_id__/g' /opt/config/integration-override.yaml |
Gary Wu | 17440fe | 2018-10-22 15:12:07 -0700 | [diff] [blame] | 47 | sed -i 's/\_\_sec_group__/__sec_group__/g' /opt/config/integration-override.yaml |
Gary Wu | ed95ca7 | 2018-07-26 10:24:51 -0700 | [diff] [blame] | 48 | sed -i 's/\_\_rancher_ip_addr__/__rancher_ip_addr__/g' /opt/config/integration-override.yaml |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 49 | sed -i 's/\_\_k8s_01_vm_ip__/__k8s_01_vm_ip__/g' /opt/config/integration-override.yaml |
Gary Wu | 978171e | 2018-07-24 11:56:01 -0700 | [diff] [blame] | 50 | sed -i 's/\_\_docker_proxy__/__docker_proxy__/g' /opt/config/integration-override.yaml |
Gary Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 51 | cp /opt/config/integration-override.yaml /root |
Gary Wu | 978171e | 2018-07-24 11:56:01 -0700 | [diff] [blame] | 52 | cat /root/integration-override.yaml |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 53 | |
Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 54 | mkdir -p /etc/docker |
Gary Wu | 3ad596f | 2018-02-08 07:16:37 -0800 | [diff] [blame] | 55 | if [ ! -z "__docker_proxy__" ]; then |
| 56 | cat > /etc/docker/daemon.json <<EOF |
Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 57 | { |
Gary Wu | b8be70a | 2018-11-17 17:14:38 -0800 | [diff] [blame] | 58 | "mtu": __mtu__, |
Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 59 | "insecure-registries" : ["__docker_proxy__"] |
| 60 | } |
| 61 | EOF |
Gary Wu | b8be70a | 2018-11-17 17:14:38 -0800 | [diff] [blame] | 62 | else |
| 63 | cat > /etc/docker/daemon.json <<EOF |
| 64 | { |
| 65 | "mtu": __mtu__ |
| 66 | } |
| 67 | EOF |
Gary Wu | 3ad596f | 2018-02-08 07:16:37 -0800 | [diff] [blame] | 68 | fi |
| 69 | if [ ! -z "__apt_proxy__" ]; then |
| 70 | cat > /etc/apt/apt.conf.d/30proxy<<EOF |
Gary Wu | 1ff5667 | 2018-01-17 20:51:45 -0800 | [diff] [blame] | 71 | Acquire::http { Proxy "http://__apt_proxy__"; }; |
| 72 | Acquire::https::Proxy "DIRECT"; |
| 73 | EOF |
Gary Wu | 3ad596f | 2018-02-08 07:16:37 -0800 | [diff] [blame] | 74 | fi |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 75 | |
Gary Wu | 675eb15 | 2018-10-26 10:50:27 -0700 | [diff] [blame] | 76 | # workaround for OpenStack intermittent failure to change default apt mirrors |
| 77 | sed -i 's|http://archive.ubuntu.com|http://nova.clouds.archive.ubuntu.com|g' /etc/apt/sources.list |
| 78 | |
Gary Wu | b0e3650 | 2018-10-16 11:01:07 -0700 | [diff] [blame] | 79 | while ! hash jq &> /dev/null; do |
| 80 | apt-get -y update |
Gary Wu | 675eb15 | 2018-10-26 10:50:27 -0700 | [diff] [blame] | 81 | apt-get -y install linux-image-extra-$(uname -r) apt-transport-https ca-certificates curl software-properties-common jq make nfs-kernel-server moreutils |
Gary Wu | b0e3650 | 2018-10-16 11:01:07 -0700 | [diff] [blame] | 82 | sleep 10 |
| 83 | done |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 84 | |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 85 | mkdir -p /dockerdata-nfs |
Gary Wu | c474970 | 2018-06-26 14:27:41 -0700 | [diff] [blame] | 86 | |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 87 | # use RAM disk for /dockerdata-nfs for testing |
| 88 | if [ "__use_ramdisk__" = "true" ]; then |
| 89 | echo "tmpfs /dockerdata-nfs tmpfs noatime,size=75% 1 2" >> /etc/fstab |
| 90 | mount /dockerdata-nfs |
| 91 | fi |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 92 | # version control the persistence volume to see what's happening |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 93 | chmod 777 /dockerdata-nfs/ |
| 94 | chown nobody:nogroup /dockerdata-nfs/ |
| 95 | cd /dockerdata-nfs/ |
| 96 | git init |
Gary Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 97 | git config user.email "root@onap" |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 98 | git config user.name "root" |
| 99 | git add -A |
| 100 | git commit -m "initial commit" |
| 101 | |
| 102 | # export NFS mount |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 103 | echo "/dockerdata-nfs *(rw,fsid=1,async,no_root_squash,no_subtree_check)" | tee /etc/exports |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 104 | |
| 105 | |
| 106 | exportfs -a |
| 107 | systemctl restart nfs-kernel-server |
| 108 | |
| 109 | cd ~ |
| 110 | |
Gary Wu | 7a04b3d | 2018-08-15 12:31:46 -0700 | [diff] [blame] | 111 | # install docker __docker_version__ |
Gary Wu | b0e3650 | 2018-10-16 11:01:07 -0700 | [diff] [blame] | 112 | while ! hash docker &> /dev/null; do |
| 113 | curl -s https://releases.rancher.com/install-docker/__docker_version__.sh | sh |
| 114 | usermod -aG docker ubuntu |
| 115 | sleep 10 |
| 116 | done |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 117 | apt-mark hold docker-ce |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 118 | |
Gary Wu | 7a04b3d | 2018-08-15 12:31:46 -0700 | [diff] [blame] | 119 | # install rancher __rancher_version__ |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 120 | docker run --name rancher-server --restart unless-stopped -d -p 8080:8080 -e CATTLE_BOOTSTRAP_REQUIRED_IMAGE=__docker_proxy__/rancher/agent:v__rancher_agent_version__ __docker_proxy__/rancher/server:v__rancher_version__ |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 121 | |
Gary Wu | 7a04b3d | 2018-08-15 12:31:46 -0700 | [diff] [blame] | 122 | # install kubectl __kubectl_version__ |
| 123 | curl -s -LO https://storage.googleapis.com/kubernetes-release/release/v__kubectl_version__/bin/linux/amd64/kubectl |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 124 | chmod +x ./kubectl |
| 125 | sudo mv ./kubectl /usr/local/bin/kubectl |
| 126 | mkdir ~/.kube |
| 127 | |
Gary Wu | 7a04b3d | 2018-08-15 12:31:46 -0700 | [diff] [blame] | 128 | # install helm __helm_version__ |
Gary Wu | 895a4ac | 2018-10-31 12:30:54 -0700 | [diff] [blame] | 129 | mkdir -p helm |
| 130 | pushd helm |
Gary Wu | 7a04b3d | 2018-08-15 12:31:46 -0700 | [diff] [blame] | 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 |
Gary Wu | 895a4ac | 2018-10-31 12:30:54 -0700 | [diff] [blame] | 133 | sudo cp linux-amd64/helm /usr/local/bin/helm |
| 134 | popd |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 135 | |
Gary Wu | 895a4ac | 2018-10-31 12:30:54 -0700 | [diff] [blame] | 136 | mkdir -p rancher |
| 137 | pushd rancher |
Gary Wu | ad51372 | 2018-07-26 13:08:47 -0700 | [diff] [blame] | 138 | echo export RANCHER_IP=__rancher_private_ip_addr__ > api-keys-rc |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 139 | source api-keys-rc |
| 140 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 141 | until curl -s -o projects.json -H "Accept: application/json" http://$RANCHER_IP:8080/v2-beta/projects; do |
Gary Wu | b0e3650 | 2018-10-16 11:01:07 -0700 | [diff] [blame] | 142 | sleep 30 |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 143 | done |
| 144 | OLD_PID=$(jq -r '.data[0].id' projects.json) |
| 145 | |
| 146 | curl -s -H "Accept: application/json" -H "Content-Type: application/json" -d '{"accountId":"1a1"}' http://$RANCHER_IP:8080/v2-beta/apikeys > apikeys.json |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 147 | echo export CATTLE_ACCESS_KEY=`jq -r '.publicValue' apikeys.json` >> api-keys-rc |
| 148 | echo export CATTLE_SECRET_KEY=`jq -r '.secretValue' apikeys.json` >> api-keys-rc |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 149 | source api-keys-rc |
| 150 | |
| 151 | |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 152 | curl -u "${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY}" -X PUT -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"id":"registry.default","type":"activeSetting","baseType":"setting","name":"registry.default","activeValue":"__docker_proxy__","inDb":true,"source":"Database","value":"__docker_proxy__"}' http://$RANCHER_IP:8080/v2-beta/settings/registry.default |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 153 | |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 154 | curl -s -u "${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY}" -X DELETE -H 'Content-Type: application/json' "http://$RANCHER_IP:8080/v2-beta/projects/$OLD_PID" |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 155 | |
| 156 | until [ ! -z "$TEMPLATE_ID" ] && [ "$TEMPLATE_ID" != "null" ]; do |
| 157 | sleep 5 |
| 158 | curl -s -H "Accept: application/json" http://$RANCHER_IP:8080/v2-beta/projectTemplates?name=Kubernetes > projectTemplatesKubernetes.json |
| 159 | TEMPLATE_ID=$(jq -r '.data[0].id' projectTemplatesKubernetes.json) |
| 160 | done |
| 161 | |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 162 | |
| 163 | curl -s -u "${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY}" \ |
| 164 | -X PUT \ |
| 165 | -H 'Accept: application/json' \ |
| 166 | -H 'Content-Type: application/json' \ |
Gary Wu | b8be70a | 2018-11-17 17:14:38 -0800 | [diff] [blame] | 167 | -d '{"stacks":[{"type":"catalogTemplate", "answers":{"CONSTRAINT_TYPE":"required"}, "name":"kubernetes", "templateVersionId":"library:infra*k8s:52"}, {"type":"catalogTemplate", "name":"network-services", "templateId":"library:infra*network-services"}, {"type":"catalogTemplate", "name":"ipsec", "templateId":"library:infra*ipsec", "answers":{"MTU":"__mtu__"}}, {"type":"catalogTemplate", "name":"healthcheck", "templateId":"library:infra*healthcheck"}]}' \ |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 168 | "http://$RANCHER_IP:8080/v2-beta/projecttemplates/$TEMPLATE_ID" |
| 169 | |
| 170 | curl -s -u "${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY}" -X POST -H 'Content-Type: application/json' -d '{ "name":"oom", "projectTemplateId":"'$TEMPLATE_ID'" }' "http://$RANCHER_IP:8080/v2-beta/projects" > project.json |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 171 | PID=`jq -r '.id' project.json` |
| 172 | echo export RANCHER_URL=http://$RANCHER_IP:8080/v1/projects/$PID >> api-keys-rc |
| 173 | source api-keys-rc |
| 174 | |
| 175 | until [ $(jq -r '.state' project.json) == "active" ]; do |
| 176 | sleep 5 |
| 177 | curl -s -H "Accept: application/json" http://$RANCHER_IP:8080/v1/projects/$PID > project.json |
| 178 | done |
| 179 | |
| 180 | |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 181 | curl -s -u $CATTLE_ACCESS_KEY:$CATTLE_SECRET_KEY -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"name":"docker-proxy", "serverAddress":"__docker_proxy__"}' $RANCHER_URL/registries > registry.json |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 182 | RID=$(jq -r '.id' registry.json) |
| 183 | |
| 184 | |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 185 | curl -u "${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY}" -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"publicValue":"docker", "registryId":"'$RID'", "secretValue":"docker", "type":"registryCredential"}' "http://$RANCHER_IP:8080/v2-beta/projects/$PID/registrycredential" |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 186 | |
| 187 | |
| 188 | |
| 189 | TID=$(curl -s -X POST -H "Accept: application/json" -H "Content-Type: application/json" http://$RANCHER_IP:8080/v1/projects/$PID/registrationTokens | jq -r '.id') |
| 190 | touch token.json |
| 191 | while [ $(jq -r .command token.json | wc -c) -lt 10 ]; do |
| 192 | sleep 5 |
| 193 | curl -s -X GET -H "Accept: application/json" http://$RANCHER_IP:8080/v1/projects/$PID/registrationToken/$TID > token.json |
| 194 | done |
| 195 | jq -r .command token.json > rancher_agent_cmd.sh |
| 196 | chmod +x rancher_agent_cmd.sh |
| 197 | cp rancher_agent_cmd.sh /dockerdata-nfs |
Gary Wu | 895a4ac | 2018-10-31 12:30:54 -0700 | [diff] [blame] | 198 | popd |
| 199 | |
Gary Wu | 11c9874 | 2018-05-02 16:19:04 -0700 | [diff] [blame] | 200 | cd /dockerdata-nfs |
| 201 | git add -A |
| 202 | git commit -a -m "Add rancher agent command file" |
| 203 | cd ~ |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 204 | |
Gary Wu | 89f6723 | 2018-11-01 13:45:31 -0700 | [diff] [blame] | 205 | |
| 206 | # Uncomment this section to run orchestration plane on the Rancher VM |
| 207 | # |
| 208 | # cp /dockerdata-nfs/rancher_agent_cmd.sh . |
| 209 | # sed -i "s/docker run/docker run -e CATTLE_HOST_LABELS='orchestration=true' -e CATTLE_AGENT_IP=${HOST_IP}/g" rancher_agent_cmd.sh |
| 210 | # source rancher_agent_cmd.sh |
Gary Wu | 895a4ac | 2018-10-31 12:30:54 -0700 | [diff] [blame] | 211 | |
| 212 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 213 | |
Gary Wu | 3fd6c2a | 2018-10-28 21:44:00 -0700 | [diff] [blame] | 214 | KUBETOKEN=$(echo -n 'Basic '$(echo -n "$CATTLE_ACCESS_KEY:$CATTLE_SECRET_KEY" | base64 -w 0) | base64 -w 0) |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 215 | |
Gary Wu | e7f3361 | 2018-11-02 13:10:06 -0700 | [diff] [blame] | 216 | NAMESPACE=onap |
| 217 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 218 | # create .kube/config |
| 219 | cat > ~/.kube/config <<EOF |
| 220 | apiVersion: v1 |
| 221 | kind: Config |
| 222 | clusters: |
| 223 | - cluster: |
| 224 | api-version: v1 |
| 225 | insecure-skip-tls-verify: true |
Gary Wu | ad51372 | 2018-07-26 13:08:47 -0700 | [diff] [blame] | 226 | server: "https://__rancher_ip_addr__:8080/r/projects/$PID/kubernetes:6443" |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 227 | name: "oom" |
| 228 | contexts: |
| 229 | - context: |
| 230 | cluster: "oom" |
Gary Wu | e7f3361 | 2018-11-02 13:10:06 -0700 | [diff] [blame] | 231 | namespace: "$NAMESPACE" |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 232 | user: "oom" |
| 233 | name: "oom" |
| 234 | current-context: "oom" |
| 235 | users: |
| 236 | - name: "oom" |
| 237 | user: |
| 238 | token: "$KUBETOKEN" |
| 239 | EOF |
| 240 | |
| 241 | export KUBECONFIG=/root/.kube/config |
| 242 | kubectl config view |
| 243 | |
Gary Wu | 895a4ac | 2018-10-31 12:30:54 -0700 | [diff] [blame] | 244 | |
| 245 | |
Gary Wu | b0e3650 | 2018-10-16 11:01:07 -0700 | [diff] [blame] | 246 | # Enable auto-completion for kubectl |
| 247 | echo "source <(kubectl completion bash)" >> ~/.bashrc |
| 248 | |
| 249 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 250 | # wait for kubernetes to initialze |
Gary Wu | b0e3650 | 2018-10-16 11:01:07 -0700 | [diff] [blame] | 251 | sleep 3m |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 252 | until [ $(kubectl get pods --namespace kube-system | tail -n +2 | grep -c Running) -ge 6 ]; do |
Gary Wu | b0e3650 | 2018-10-16 11:01:07 -0700 | [diff] [blame] | 253 | sleep 1m |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 254 | done |
| 255 | |
| 256 | |
| 257 | # Install using OOM |
| 258 | export HOME=/root |
Gary Wu | 978171e | 2018-07-24 11:56:01 -0700 | [diff] [blame] | 259 | mkdir -p ~/.ssh |
| 260 | cp ~ubuntu/.ssh/authorized_keys ~/.ssh |
| 261 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 262 | |
Gary Wu | 0dfbea3 | 2018-05-12 09:27:44 -0700 | [diff] [blame] | 263 | # update and initialize git |
| 264 | apt-get -y install git |
| 265 | git config --global user.email root@rancher |
| 266 | git config --global user.name root@rancher |
| 267 | git config --global log.decorate auto |
| 268 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 269 | # Clone OOM: |
| 270 | cd ~ |
Gary Wu | 87aa8b5 | 2018-08-09 08:10:24 -0700 | [diff] [blame] | 271 | git clone -b __oom_gerrit_branch__ https://gerrit.onap.org/r/oom |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 272 | cd oom |
Gary Wu | 6842fa3 | 2018-11-20 10:29:22 -0800 | [diff] [blame] | 273 | if [ ! -z "__oom_gerrit_refspec__" ]; then |
| 274 | git fetch https://gerrit.onap.org/r/oom __oom_gerrit_refspec__ |
| 275 | git checkout FETCH_HEAD |
| 276 | fi |
Gary Wu | 0dfbea3 | 2018-05-12 09:27:44 -0700 | [diff] [blame] | 277 | git checkout -b workarounds |
Gary Wu | 87aa8b5 | 2018-08-09 08:10:24 -0700 | [diff] [blame] | 278 | git log -1 |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 279 | |
Gary Wu | 81836d2 | 2018-06-22 13:48:50 -0700 | [diff] [blame] | 280 | # Clone integration |
| 281 | cd ~ |
Gary Wu | 87aa8b5 | 2018-08-09 08:10:24 -0700 | [diff] [blame] | 282 | git clone -b __integration_gerrit_branch__ https://gerrit.onap.org/r/integration |
Gary Wu | 81836d2 | 2018-06-22 13:48:50 -0700 | [diff] [blame] | 283 | cd integration |
Gary Wu | 6842fa3 | 2018-11-20 10:29:22 -0800 | [diff] [blame] | 284 | if [ ! -z "__integration_gerrit_refspec__" ]; then |
| 285 | git fetch https://gerrit.onap.org/r/integration __integration_gerrit_refspec__ |
| 286 | git checkout FETCH_HEAD |
| 287 | fi |
Gary Wu | 81836d2 | 2018-06-22 13:48:50 -0700 | [diff] [blame] | 288 | |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 289 | |
Gary Wu | 87aa8b5 | 2018-08-09 08:10:24 -0700 | [diff] [blame] | 290 | if [ ! -z "__docker_manifest__" ]; then |
| 291 | cd version-manifest/src/main/scripts |
| 292 | ./update-oom-image-versions.sh ../resources/__docker_manifest__ ~/oom/ |
| 293 | fi |
Gary Wu | 81836d2 | 2018-06-22 13:48:50 -0700 | [diff] [blame] | 294 | |
| 295 | cd ~/oom |
| 296 | git diff |
Gary Wu | 87aa8b5 | 2018-08-09 08:10:24 -0700 | [diff] [blame] | 297 | git commit -a -m "apply manifest versions" |
| 298 | git tag -a "deploy0" -m "initial deployment" |
Gary Wu | 81836d2 | 2018-06-22 13:48:50 -0700 | [diff] [blame] | 299 | |
| 300 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 301 | # Run ONAP: |
| 302 | cd ~/oom/kubernetes/ |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 303 | helm init --client-only |
| 304 | helm init --upgrade |
| 305 | helm serve & |
Gary Wu | b0e3650 | 2018-10-16 11:01:07 -0700 | [diff] [blame] | 306 | sleep 10 |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 307 | helm repo add local http://127.0.0.1:8879 |
| 308 | helm repo list |
| 309 | make all |
| 310 | helm search -l | grep local |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 311 | |
| 312 | # install helm deploy plugin |
| 313 | rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/ |
| 314 | # temporary workaround to throttle the helm deploy to alleviate startup disk contention issues |
| 315 | if [ ! -z "__helm_deploy_delay__" ]; then |
| 316 | sed -i "/\^enabled:/a\ echo sleep __helm_deploy_delay__\n sleep __helm_deploy_delay__" ~/.helm/plugins/deploy/deploy.sh |
| 317 | fi |
| 318 | |
| 319 | helm deploy dev local/onap -f ~/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f ~/integration-override.yaml --namespace $NAMESPACE --verbose |
| 320 | |
| 321 | # re-install original helm deploy plugin |
| 322 | rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/ |
| 323 | |
Gary Wu | 389aa90 | 2018-09-17 13:53:54 -0700 | [diff] [blame] | 324 | helm list |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 325 | |
| 326 | |
Gary Wu | 48a3294 | 2018-11-08 07:34:49 -0800 | [diff] [blame] | 327 | |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 328 | # Check ONAP status: |
Gary Wu | b0e3650 | 2018-10-16 11:01:07 -0700 | [diff] [blame] | 329 | sleep 10 |
Gary Wu | 14a6b30 | 2018-05-01 15:59:28 -0700 | [diff] [blame] | 330 | kubectl get pods --all-namespaces |
Gary Wu | b0e3650 | 2018-10-16 11:01:07 -0700 | [diff] [blame] | 331 | kubectl get nodes |
| 332 | kubectl top nodes |