Merge "Put VID staging back to 3.2-STAGING-latest"
[integration.git] / deployment / heat / onap-oom / rancher_vm_entrypoint.sh
index ed1dc88..bd39963 100644 (file)
@@ -34,6 +34,8 @@ echo "__rancher_version__" > /opt/config/rancher_version.txt
 echo "__rancher_agent_version__" > /opt/config/rancher_agent_version.txt
 echo "__kubectl_version__" > /opt/config/kubectl_version.txt
 echo "__helm_version__" > /opt/config/helm_version.txt
+echo "__helm_deploy_delay__" > /opt/config/helm_deploy_delay.txt
+echo "__mtu__" > /opt/config/mtu.txt
 
 cat <<EOF > /opt/config/integration-override.yaml
 __integration_override_yaml__
@@ -44,19 +46,25 @@ sed -i 's/\_\_oam_network_id__/__oam_network_id__/g' /opt/config/integration-ove
 sed -i 's/\_\_oam_subnet_id__/__oam_subnet_id__/g' /opt/config/integration-override.yaml
 sed -i 's/\_\_sec_group__/__sec_group__/g' /opt/config/integration-override.yaml
 sed -i 's/\_\_rancher_ip_addr__/__rancher_ip_addr__/g' /opt/config/integration-override.yaml
-sed -i 's/\_\_k8s_1_vm_ip__/__k8s_1_vm_ip__/g' /opt/config/integration-override.yaml
+sed -i 's/\_\_k8s_01_vm_ip__/__k8s_01_vm_ip__/g' /opt/config/integration-override.yaml
 sed -i 's/\_\_docker_proxy__/__docker_proxy__/g' /opt/config/integration-override.yaml
 cp /opt/config/integration-override.yaml /root
 cat /root/integration-override.yaml
 
-echo `hostname -I` `hostname` >> /etc/hosts
 mkdir -p /etc/docker
 if [ ! -z "__docker_proxy__" ]; then
     cat > /etc/docker/daemon.json <<EOF
 {
+  "mtu": __mtu__,
   "insecure-registries" : ["__docker_proxy__"]
 }
 EOF
+else
+    cat > /etc/docker/daemon.json <<EOF
+{
+  "mtu": __mtu__
+}
+EOF
 fi
 if [ ! -z "__apt_proxy__" ]; then
     cat > /etc/apt/apt.conf.d/30proxy<<EOF
@@ -74,11 +82,13 @@ while ! hash jq &> /dev/null; do
     sleep 10
 done
 
-# use RAM disk for /dockerdata-nfs for testing
-echo "tmpfs /dockerdata-nfs tmpfs noatime,size=75% 1 2" >> /etc/fstab
-mkdir -pv /dockerdata-nfs
-mount /dockerdata-nfs
+mkdir -p /dockerdata-nfs
 
+# use RAM disk for /dockerdata-nfs for testing
+if [ "__use_ramdisk__" = "true" ]; then
+    echo "tmpfs /dockerdata-nfs tmpfs noatime,size=75% 1 2" >> /etc/fstab
+    mount /dockerdata-nfs
+fi
 # version control the persistence volume to see what's happening
 chmod 777 /dockerdata-nfs/
 chown nobody:nogroup /dockerdata-nfs/
@@ -154,7 +164,7 @@ curl -s -u "${CATTLE_ACCESS_KEY}:${CATTLE_SECRET_KEY}" \
 -X PUT \
 -H 'Accept: application/json' \
 -H 'Content-Type: application/json' \
--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"}, {"type":"catalogTemplate", "name":"healthcheck", "templateId":"library:infra*healthcheck"}]}' \
+-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"}]}' \
 "http://$RANCHER_IP:8080/v2-beta/projecttemplates/$TEMPLATE_ID"
 
 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
@@ -203,6 +213,8 @@ cd ~
 
 KUBETOKEN=$(echo -n 'Basic '$(echo -n "$CATTLE_ACCESS_KEY:$CATTLE_SECRET_KEY" | base64 -w 0) | base64 -w 0)
 
+NAMESPACE=onap
+
 # create .kube/config
 cat > ~/.kube/config <<EOF
 apiVersion: v1
@@ -216,6 +228,7 @@ clusters:
 contexts:
 - context:
     cluster: "oom"
+    namespace: "$NAMESPACE"
     user: "oom"
   name: "oom"
 current-context: "oom"
@@ -269,6 +282,7 @@ cd integration
 git fetch https://gerrit.onap.org/r/integration __integration_gerrit_refspec__
 git checkout FETCH_HEAD
 
+
 if [ ! -z "__docker_manifest__" ]; then
     cd version-manifest/src/main/scripts
     ./update-oom-image-versions.sh ../resources/__docker_manifest__ ~/oom/
@@ -289,12 +303,24 @@ sleep 10
 helm repo add local http://127.0.0.1:8879
 helm repo list
 make all
-rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
 helm search -l | grep local
-helm deploy dev local/onap -f ~/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f ~/integration-override.yaml --namespace onap | tee ~/helm-deploy.log
+
+# install helm deploy plugin
+rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
+# temporary workaround to throttle the helm deploy to alleviate startup disk contention issues
+if [ ! -z "__helm_deploy_delay__" ]; then
+    sed -i "/\^enabled:/a\      echo sleep __helm_deploy_delay__\n      sleep __helm_deploy_delay__" ~/.helm/plugins/deploy/deploy.sh
+fi
+
+helm deploy dev local/onap -f ~/oom/kubernetes/onap/resources/environments/public-cloud.yaml -f ~/integration-override.yaml --namespace $NAMESPACE --verbose
+
+# re-install original helm deploy plugin
+rsync -avt ~/oom/kubernetes/helm/plugins ~/.helm/
+
 helm list
 
 
+
 # Check ONAP status:
 sleep 10
 kubectl get pods --all-namespaces