From 1ff56674c8cf98a292ddaad5081d43d79f9f7cfd Mon Sep 17 00:00:00 2001 From: Gary Wu Date: Wed, 17 Jan 2018 20:51:45 -0800 Subject: Heat template for ONAP OOM deployment Change-Id: I8f4ae420d613de037c178287462b1f9dbd4d40a9 Issue-ID: INT-381 Signed-off-by: Gary Wu --- test/ete/labs/huawei/k8s_vm_entrypoint.sh | 173 ++++++++++++++++++++++ test/ete/labs/huawei/onap-oom.yaml | 197 +------------------------- test/ete/labs/huawei/rancher_vm_entrypoint.sh | 18 +++ 3 files changed, 195 insertions(+), 193 deletions(-) create mode 100644 test/ete/labs/huawei/k8s_vm_entrypoint.sh create mode 100644 test/ete/labs/huawei/rancher_vm_entrypoint.sh (limited to 'test/ete/labs') diff --git a/test/ete/labs/huawei/k8s_vm_entrypoint.sh b/test/ete/labs/huawei/k8s_vm_entrypoint.sh new file mode 100644 index 000000000..0dc432b10 --- /dev/null +++ b/test/ete/labs/huawei/k8s_vm_entrypoint.sh @@ -0,0 +1,173 @@ +#!/bin/bash -x +printenv + +mkdir -p /opt/config +echo "__rancher_ip_addr__" > /opt/config/rancher_ip_addr.txt +echo `hostname -I` `hostname` >> /etc/hosts +mkdir -p /etc/docker +cat > /etc/docker/daemon.json < /etc/apt/apt.conf.d/30proxy<> /etc/sysctl.conf +sysctl -p + +# install rancher agent +echo export RANCHER_IP=__rancher_ip_addr__ > api-keys-rc +source api-keys-rc + +sleep 50 +until curl -s -o projects.json -H "Accept: application/json" http://$RANCHER_IP:8080/v2-beta/projects; do + sleep 10 +done +OLD_PID=$(jq -r '.data[0].id' projects.json) + +curl -s -H "Accept: application/json" -H "Content-Type: application/json" -d '{"accountId":"1a1"}' http://$RANCHER_IP:8080/v2-beta/apikeys | tee apikeys.json +echo export RANCHER_ACCESS_KEY=`jq -r '.publicValue' apikeys.json` >> api-keys-rc +echo export RANCHER_SECRET_KEY=`jq -r '.secretValue' apikeys.json` >> api-keys-rc +source api-keys-rc + +curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" -X DELETE -H 'Content-Type: application/json' "http://$RANCHER_IP:8080/v2-beta/projects/$OLD_PID" + +until [ ! -z "$TEMPLATE_ID" ] && [ "$TEMPLATE_ID" != "null" ]; do + sleep 5 + curl -s -H "Accept: application/json" http://$RANCHER_IP:8080/v2-beta/projectTemplates?name=Kubernetes | tee projectTemplatesKubernetes.json + TEMPLATE_ID=$(jq -r '.data[0].id' projectTemplatesKubernetes.json) +done + +curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" -X POST -H 'Content-Type: application/json' -d '{ "name":"oom", "projectTemplateId":"'$TEMPLATE_ID'" }' "http://$RANCHER_IP:8080/v2-beta/projects" | tee project.json +PID=`jq -r '.id' project.json` +echo export RANCHER_URL=http://$RANCHER_IP:8080/v1/projects/$PID >> api-keys-rc +source api-keys-rc + +until [ $(jq -r '.state' project.json) == "active" ]; do + sleep 5 + curl -s -H "Accept: application/json" http://$RANCHER_IP:8080/v1/projects/$PID | tee project.json +done + +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') +touch token.json +while [ $(jq -r .command token.json | wc -c) -lt 10 ]; do + sleep 5 + curl -s -X GET -H "Accept: application/json" http://$RANCHER_IP:8080/v1/projects/$PID/registrationToken/$TID | tee token.json +done +CMD=$(jq -r .command token.json) +eval $CMD + +# download rancher CLI +wget -q https://github.com/rancher/cli/releases/download/v0.6.7/rancher-linux-amd64-v0.6.7.tar.xz +unxz rancher-linux-amd64-v0.6.7.tar.xz +tar xvf rancher-linux-amd64-v0.6.7.tar + +# Clone OOM: +cd ~ +git clone -b amsterdam http://gerrit.onap.org/r/oom + +# Update values.yaml to point to docker-proxy instead of nexus3: +cd ~/oom/kubernetes +perl -p -i -e 's/nexus3.onap.org:10001/__docker_proxy__/g' `find ./ -name values.yaml` + +KUBETOKEN=$(echo -n 'Basic '$(echo -n "$RANCHER_ACCESS_KEY:$RANCHER_SECRET_KEY" | base64 -w 0) | base64 -w 0) + +# create .kube/config +cat > ~/.kube/config <> ~/oom/kubernetes/config/onap-parameters.yaml <> /etc/hosts - mkdir -p /etc/docker - cat > /etc/docker/daemon.json < /etc/apt/apt.conf.d/30proxy< /opt/config/rancher_ip_addr.txt - echo `hostname -I` `hostname` >> /etc/hosts - mkdir -p /etc/docker - cat > /etc/docker/daemon.json < /etc/apt/apt.conf.d/30proxy<> /etc/sysctl.conf - sysctl -p - - # install rancher agent - echo export RANCHER_IP=__rancher_ip_addr__ > api-keys-rc - source api-keys-rc - - sleep 50 - until curl -s -o projects.json -H "Accept: application/json" http://$RANCHER_IP:8080/v2-beta/projects; do - sleep 10 - done - OLD_PID=$(jq -r '.data[0].id' projects.json) - - curl -s -H "Accept: application/json" -H "Content-Type: application/json" -d '{"accountId":"1a1"}' http://$RANCHER_IP:8080/v2-beta/apikeys | tee apikeys.json - echo export RANCHER_ACCESS_KEY=`jq -r '.publicValue' apikeys.json` >> api-keys-rc - echo export RANCHER_SECRET_KEY=`jq -r '.secretValue' apikeys.json` >> api-keys-rc - source api-keys-rc - - curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" -X DELETE -H 'Content-Type: application/json' "http://$RANCHER_IP:8080/v2-beta/projects/$OLD_PID" - - until [ ! -z "$TEMPLATE_ID" ] && [ "$TEMPLATE_ID" != "null" ]; do - sleep 5 - curl -s -H "Accept: application/json" http://$RANCHER_IP:8080/v2-beta/projectTemplates?name=Kubernetes | tee projectTemplatesKubernetes.json - TEMPLATE_ID=$(jq -r '.data[0].id' projectTemplatesKubernetes.json) - done - - curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" -X POST -H 'Content-Type: application/json' -d '{ "name":"oom", "projectTemplateId":"'$TEMPLATE_ID'" }' "http://$RANCHER_IP:8080/v2-beta/projects" | tee project.json - PID=`jq -r '.id' project.json` - echo export RANCHER_URL=http://$RANCHER_IP:8080/v1/projects/$PID >> api-keys-rc - source api-keys-rc - - until [ $(jq -r '.state' project.json) == "active" ]; do - sleep 5 - curl -s -H "Accept: application/json" http://$RANCHER_IP:8080/v1/projects/$PID | tee project.json - done - - 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') - touch token.json - while [ $(jq -r .command token.json | wc -c) -lt 10 ]; do - sleep 5 - curl -s -X GET -H "Accept: application/json" http://$RANCHER_IP:8080/v1/projects/$PID/registrationToken/$TID | tee token.json - done - CMD=$(jq -r .command token.json) - eval $CMD - - # download rancher CLI - wget -q https://github.com/rancher/cli/releases/download/v0.6.7/rancher-linux-amd64-v0.6.7.tar.xz - unxz rancher-linux-amd64-v0.6.7.tar.xz - tar xvf rancher-linux-amd64-v0.6.7.tar - - # Clone OOM: - cd ~ - git clone -b amsterdam http://gerrit.onap.org/r/oom - - # Update values.yaml to point to docker-proxy instead of nexus3: - cd ~/oom/kubernetes - perl -p -i -e 's/nexus3.onap.org:10001/__docker_proxy__/g' `find ./ -name values.yaml` - - KUBETOKEN=$(echo -n 'Basic '$(echo -n "$RANCHER_ACCESS_KEY:$RANCHER_SECRET_KEY" | base64 -w 0) | base64 -w 0) - - # create .kube/config - cat > ~/.kube/config <> ~/oom/kubernetes/config/onap-parameters.yaml <> /etc/hosts +mkdir -p /etc/docker +cat > /etc/docker/daemon.json < /etc/apt/apt.conf.d/30proxy<