aboutsummaryrefslogtreecommitdiffstats
path: root/deployment/heat/onap-oom
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2018-01-19 12:28:33 -0800
committerGary Wu <gary.i.wu@huawei.com>2018-01-19 12:28:33 -0800
commitb4b4f3145c20eb95cb6cc9a7c1db397558a4a892 (patch)
tree36620f15f3727b4f42ad0c0917d55b35d3f6fa03 /deployment/heat/onap-oom
parentfe1deb3f4a651268b23a180666028014eea06476 (diff)
Refactored OOM heat template/env file locations
Change-Id: Ib0fcf2cac1fe209b252027d183f12ce7cdfee953 Issue-ID: INT-381 Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'deployment/heat/onap-oom')
-rw-r--r--deployment/heat/onap-oom/env/gwu/onap.env25
-rw-r--r--deployment/heat/onap-oom/env/huawei/onap-beijing-oom.env25
-rw-r--r--deployment/heat/onap-oom/k8s_vm_entrypoint.sh196
-rw-r--r--deployment/heat/onap-oom/onap-oom.yaml130
-rw-r--r--deployment/heat/onap-oom/rancher_vm_entrypoint.sh18
5 files changed, 394 insertions, 0 deletions
diff --git a/deployment/heat/onap-oom/env/gwu/onap.env b/deployment/heat/onap-oom/env/gwu/onap.env
new file mode 100644
index 000000000..1f3b9e5d7
--- /dev/null
+++ b/deployment/heat/onap-oom/env/gwu/onap.env
@@ -0,0 +1,25 @@
+parameters:
+
+ keystone_url: http://192.168.1.11:5000
+ openstack_tenant_id: 4c93f99551604bf7af25a8f80c7f34cb
+ openstack_tenant_name: onap
+ openstack_username: demo
+ openstack_api_key: demo
+
+ ubuntu_1404_image: trusty
+ ubuntu_1604_image: xenial
+ centos_7_image: centos7
+
+ apt_proxy: 192.168.1.51:3142
+ docker_proxy: 192.168.1.51:5000
+
+ rancher_vm_flavor: m1.small
+ k8s_vm_flavor: m2.xxlarge
+
+ public_net_id: 024582bd-ef9b-48b9-9e70-e6732559d9df
+ public_net_name: provider
+
+ oam_network_cidr: 172.16.0.0/16
+ dcae_ip_addr: 172.16.0.4
+ dns_list: ["192.168.1.11", "192.168.1.3"]
+ dns_forwarder: 192.168.1.11
diff --git a/deployment/heat/onap-oom/env/huawei/onap-beijing-oom.env b/deployment/heat/onap-oom/env/huawei/onap-beijing-oom.env
new file mode 100644
index 000000000..00f3bd2cb
--- /dev/null
+++ b/deployment/heat/onap-oom/env/huawei/onap-beijing-oom.env
@@ -0,0 +1,25 @@
+parameters:
+
+ keystone_url: http://10.145.122.117:5000
+ openstack_tenant_id: 3d228d2fcbb7447bbba3cde703431bc1
+ openstack_tenant_name: onap-beijing-oom
+ openstack_username: demo
+ openstack_api_key: demo
+
+ ubuntu_1404_image: trusty
+ ubuntu_1604_image: xenial
+ centos_7_image: centos7
+
+ apt_proxy: 10.145.122.118:3142
+ docker_proxy: 10.145.122.118:5000
+
+ rancher_vm_flavor: m1.small
+ k8s_vm_flavor: m1.xxlarge
+
+ public_net_id: 3a6247f1-fac6-4167-a49f-33cc8415ccf4
+ public_net_name: provider
+
+ oam_network_cidr: 172.16.0.0/16
+ dcae_ip_addr: 172.16.0.4
+ dns_list: ["10.145.122.117", "10.145.122.118"]
+ dns_forwarder: 10.145.122.117
diff --git a/deployment/heat/onap-oom/k8s_vm_entrypoint.sh b/deployment/heat/onap-oom/k8s_vm_entrypoint.sh
new file mode 100644
index 000000000..cae0f392b
--- /dev/null
+++ b/deployment/heat/onap-oom/k8s_vm_entrypoint.sh
@@ -0,0 +1,196 @@
+#!/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 <<EOF
+{
+ "insecure-registries" : ["__docker_proxy__"]
+}
+EOF
+cat > /etc/apt/apt.conf.d/30proxy<<EOF
+Acquire::http { Proxy "http://__apt_proxy__"; };
+Acquire::https::Proxy "DIRECT";
+EOF
+apt-get -y update
+apt-get -y install jq
+
+cd ~
+
+# install docker 1.12
+curl -s https://releases.rancher.com/install-docker/1.12.sh | sh
+usermod -aG docker ubuntu
+
+# install kubernetes 1.8.6
+curl -s -LO https://storage.googleapis.com/kubernetes-release/release/v1.8.6/bin/linux/amd64/kubectl
+chmod +x ./kubectl
+sudo mv ./kubectl /usr/local/bin/kubectl
+mkdir ~/.kube
+
+# install helm 2.3
+wget -q http://storage.googleapis.com/kubernetes-helm/helm-v2.3.0-linux-amd64.tar.gz
+tar -zxvf helm-v2.3.0-linux-amd64.tar.gz
+sudo mv linux-amd64/helm /usr/local/bin/helm
+
+# Fix virtual memory allocation for onap-log:elasticsearch:
+echo "vm.max_map_count=262144" >> /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 -s -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 -s -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` oneclick/setenv.bash
+
+KUBETOKEN=$(echo -n 'Basic '$(echo -n "$RANCHER_ACCESS_KEY:$RANCHER_SECRET_KEY" | base64 -w 0) | base64 -w 0)
+
+# create .kube/config
+cat > ~/.kube/config <<EOF
+apiVersion: v1
+kind: Config
+clusters:
+- cluster:
+ api-version: v1
+ insecure-skip-tls-verify: true
+ server: "https://$RANCHER_IP:8080/r/projects/$PID/kubernetes:6443"
+ name: "oom"
+contexts:
+- context:
+ cluster: "oom"
+ user: "oom"
+ name: "oom"
+current-context: "oom"
+users:
+- name: "oom"
+ user:
+ token: "$KUBETOKEN"
+EOF
+
+export KUBECONFIG=/root/.kube/config
+kubectl config view
+
+# Update ~/oom/kubernetes/kube2msb/values.yaml kubeMasterAuthToken to use the token from ~/.kube/config
+sed -i "s/kubeMasterAuthToken:.*/kubeMasterAuthToken: $KUBETOKEN/" ~/oom/kubernetes/kube2msb/values.yaml
+
+# Put your onap_key ssh private key in ~/.ssh/onap_key
+
+# Create or edit ~/oom/kubernetes/config/onap-parameters.yaml
+cp ~/oom/kubernetes/config/onap-parameters-sample.yaml ~/oom/kubernetes/config/onap-parameters.yaml
+cat >> ~/oom/kubernetes/config/onap-parameters.yaml <<EOF
+
+####################################
+# Overridden by k8s_vm_entrypoint.sh
+####################################
+
+OPENSTACK_UBUNTU_14_IMAGE: "__ubuntu_1404_image__"
+OPENSTACK_UBUNTU_16_IMAGE: "__ubuntu_1604_image__"
+OPENSTACK_CENTOS_7_IMAGE: "__centos_7_image__"
+OPENSTACK_PUBLIC_NET_ID: "__public_net_id__"
+OPENSTACK_PUBLIC_NET_NAME: "__public_net_name__"
+OPENSTACK_OAM_NETWORK_CIDR: "__oam_network_cidr__"
+OPENSTACK_TENANT_NAME: "__openstack_tenant_name__"
+OPENSTACK_TENANT_ID: "__openstack_tenant_id__"
+OPENSTACK_USERNAME: "__openstack_username__"
+OPENSTACK_API_KEY: "__openstack_api_key__"
+OPENSTACK_KEYSTONE_URL: "__keystone_url__"
+DCAE_IP_ADDR: "__dcae_ip_addr__"
+DCAE_KEYSTONE_URL: "__keystone_url__/v2.0"
+DNS_LIST: "__dns_list__"
+DNS_FORWARDER: "__dns_forwarder__"
+EXTERNAL_DNS: "8.8.8.8"
+DNSAAS_REGION: "RegionOne"
+DNSAAS_KEYSTONE_URL: "__keystone_url__/v2.0"
+DNSAAS_TENANT_NAME: "__openstack_tenant_name__"
+DNSAAS_USERNAME: "__openstack_username__"
+DNSAAS_PASSWORD: "__openstack_api_key__"
+
+EOF
+cat ~/oom/kubernetes/config/onap-parameters.yaml
+
+
+# wait for kubernetes to initialze
+sleep 100
+until [ $(kubectl get pods --namespace kube-system | tail -n +2 | grep -c Running) -ge 6 ]; do
+ sleep 10
+done
+
+# Source the environment file:
+cd ~/oom/kubernetes/oneclick/
+source setenv.bash
+
+# run the config pod creation
+cd ~/oom/kubernetes/config
+./createConfig.sh -n onap
+
+# Wait until the config container completes.
+sleep 200
+until [ $(kubectl get pods --namespace onap -a | tail -n +2 | grep -c Completed) -eq 1 ]; do
+ sleep 10
+done
+
+# version control the config to see what's happening
+cd /dockerdata-nfs/
+git init
+git config user.email "root@k8s"
+git config user.name "root"
+git add -A
+git commit -m "initial commit"
+
+# Run ONAP:
+cd ~/oom/kubernetes/oneclick/
+./createAll.bash -n onap
+
+# Check ONAP status:
+sleep 3
+kubectl get pods --all-namespaces
diff --git a/deployment/heat/onap-oom/onap-oom.yaml b/deployment/heat/onap-oom/onap-oom.yaml
new file mode 100644
index 000000000..5db534471
--- /dev/null
+++ b/deployment/heat/onap-oom/onap-oom.yaml
@@ -0,0 +1,130 @@
+heat_template_version: 2015-10-15
+description: ONAP on Kubernetes using OOM
+
+parameters:
+ docker_proxy:
+ type: string
+
+ apt_proxy:
+ type: string
+
+ public_net_id:
+ type: string
+ description: The ID of the Public network for floating IP address allocation
+
+ public_net_name:
+ type: string
+ description: The name of the Public network referred by public_net_id
+
+ dns_list:
+ type: comma_delimited_list
+ description: List of External DNS for OAM ONAP network
+
+ oam_network_cidr:
+ type: string
+ description: CIDR of the OAM ONAP network
+
+ keystone_url:
+ type: string
+ description: URL of OpenStack Keystone
+
+ openstack_tenant_id:
+ type: string
+ description: OpenStack tenant ID
+
+ openstack_tenant_name:
+ type: string
+ description: OpenStack tenant name (matching with the openstack_tenant_id)
+
+ openstack_username:
+ type: string
+ description: OpenStack username
+
+ openstack_api_key:
+ type: string
+ description: OpenStack password or API Key
+
+ ubuntu_1404_image:
+ type: string
+ description: Name of the Ubuntu 14.04 image
+
+ ubuntu_1604_image:
+ type: string
+ description: Name of the Ubuntu 16.04 image
+
+ centos_7_image:
+ type: string
+ description: the id/name of the CentOS 7 VM imange
+
+ rancher_vm_flavor:
+ type: string
+ description: Name of the Ubuntu 14.04 image
+
+ k8s_vm_flavor:
+ type: string
+ description: Name of the Ubuntu 14.04 image
+
+ dcae_ip_addr:
+ type: string
+
+ dns_forwarder:
+ type: string
+ description: the forwarder address for setting up ONAP's private DNS server
+
+
+resources:
+ random-str:
+ type: OS::Heat::RandomString
+ properties:
+ length: 4
+
+ rancher_vm:
+ type: OS::Nova::Server
+ properties:
+ name: rancher
+ image: xenial
+ flavor: { get_param: rancher_vm_flavor }
+ key_name: onap_key
+ networks:
+ - network: { get_param: public_net_id }
+ user_data_format: RAW
+ user_data:
+ str_replace:
+ params:
+ __docker_proxy__: { get_param: docker_proxy }
+ __apt_proxy__: { get_param: apt_proxy }
+ template:
+ get_file: rancher_vm_entrypoint.sh
+
+ k8s_vm:
+ type: OS::Nova::Server
+ properties:
+ name: k8s
+ image: xenial
+ flavor: { get_param: k8s_vm_flavor }
+ key_name: onap_key
+ networks:
+ - network: { get_param: public_net_id }
+ user_data_format: RAW
+ user_data:
+ str_replace:
+ params:
+ __docker_proxy__: { get_param: docker_proxy }
+ __apt_proxy__: { get_param: apt_proxy }
+ __rancher_ip_addr__: { get_attr: [rancher_vm, first_address] }
+ __openstack_tenant_id__: { get_param: openstack_tenant_id }
+ __openstack_tenant_name__: { get_param: openstack_tenant_name }
+ __openstack_username__: { get_param: openstack_username }
+ __openstack_api_key__: { get_param : openstack_api_key }
+ __public_net_id__: { get_param: public_net_id }
+ __public_net_name__: { get_param: public_net_name }
+ __oam_network_cidr__: { get_param: oam_network_cidr }
+ __ubuntu_1404_image__: { get_param: ubuntu_1404_image }
+ __ubuntu_1604_image__: { get_param: ubuntu_1604_image }
+ __centos_7_image__: { get_param: centos_7_image }
+ __keystone_url__: { get_param: keystone_url }
+ __dcae_ip_addr__: { get_param: dcae_ip_addr }
+ __dns_list__: { get_param: [dns_list, 0] }
+ __dns_forwarder__: { get_param: dns_forwarder }
+ template:
+ get_file: k8s_vm_entrypoint.sh
diff --git a/deployment/heat/onap-oom/rancher_vm_entrypoint.sh b/deployment/heat/onap-oom/rancher_vm_entrypoint.sh
new file mode 100644
index 000000000..da1955446
--- /dev/null
+++ b/deployment/heat/onap-oom/rancher_vm_entrypoint.sh
@@ -0,0 +1,18 @@
+#!/bin/bash -x
+printenv
+
+echo `hostname -I` `hostname` >> /etc/hosts
+mkdir -p /etc/docker
+cat > /etc/docker/daemon.json <<EOF
+{
+ "insecure-registries" : ["__docker_proxy__"]
+}
+EOF
+cat > /etc/apt/apt.conf.d/30proxy<<EOF
+Acquire::http { Proxy "http://__apt_proxy__"; };
+Acquire::https::Proxy "DIRECT";
+EOF
+apt-get -y update
+apt-get -y install docker.io
+usermod -aG docker ubuntu
+docker run --restart unless-stopped -d -p 8080:8080 rancher/server:v1.6.10