diff options
Diffstat (limited to 'deploy')
-rw-r--r-- | deploy/azure/_arm_deploy_onap_cd.json | 274 | ||||
-rw-r--r-- | deploy/azure/_arm_deploy_onap_cd_z_parameters.json | 18 | ||||
-rwxr-xr-x | deploy/azure/oom_deployment.sh | 92 | ||||
-rwxr-xr-x | deploy/rancher/oom_entrypoint.sh | 93 | ||||
-rwxr-xr-x | deploy/rancher/oom_rancher_setup.sh | 228 |
5 files changed, 705 insertions, 0 deletions
diff --git a/deploy/azure/_arm_deploy_onap_cd.json b/deploy/azure/_arm_deploy_onap_cd.json new file mode 100644 index 0000000..de3d5a0 --- /dev/null +++ b/deploy/azure/_arm_deploy_onap_cd.json @@ -0,0 +1,274 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "scriptURL": { "type": "string","metadata": { "description": "entrypoint script location" }}, + "scriptName": { "type": "string", "metadata": { "description": "entrypoint script name"}}, + "onapBranch": { "type": "string","metadata": { "description": "onap branch amsterdam or master" }}, + "onapEnvironment": { "type": "string","metadata": { "description": "onap environment usually defaults to onap" }}, + "vmName": { "type": "string","metadata": { "description": "Name of the VM" }}, + "osType": { "type": "string", "allowedValues": ["Linux"], "metadata": { "description": "Type of OS" }}, + "adminUsername": { "type": "string", "metadata": { "description": "User name for the VM" }}, + "sshKeyData": { "type": "string", "metadata": { "description": "SSH rsa public key file as a string." }}, + "dnsLabelPrefix": { "type": "string", "metadata": { "description": "Unique DNS Name for the Public IP used to access the Virtual Machine." }}, + "ubuntuOSVersion": { "type": "string", "defaultValue": "16.04.0-LTS", "allowedValues": ["16.04.0-LTS"], "metadata": { "description": "The OS"}}, + "vmSize": { "type": "string", + "defaultValue": "Standard_D1", + "allowedValues": [ + "Standard_E8_v3", + "Standard_E2_v3", + "Standard_D1", + "Standard_D4_v3", + "Standard_D8S_v3", + "Standard_D32s_v3", + "Standard_D16s_v3", + "Standard_E16_v3", + "Standard_E64_v3"], + "metadata": { "description": "VM size" }} + }, + "variables": { + "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'salinuxvm')]", + "imagePublisher": "Canonical", + "imageOffer": "UbuntuServer", + "nicName": "[concat(parameters('vmName'),'VMNic')]", + "addressPrefix": "10.0.0.0/16", + "subnetName": "Subnet", + "subnetPrefix": "10.0.0.0/24", + "storageAccountType": "Standard_LRS", + "publicIPAddressName": "[concat(parameters('vmName'),'PublicIP')]", + "publicIPAddressType": "Dynamic", + "virtualNetworkName": "[concat(parameters('vmName'),'VNET')]", + "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]", + "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", + "networkSecurityGroupName": "[concat(parameters('vmName'), '_obrien_local_nsg')]", + "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]" + }, + "resources": [ + { + "type": "Microsoft.Storage/storageAccounts", + "name": "[variables('storageAccountName')]", + "apiVersion": "2017-06-01", + "location": "[resourceGroup().location]", + "sku": { "name": "[variables('storageAccountType')]"}, + "kind": "Storage", + "properties": {} + }, + { + "apiVersion": "2017-03-01", + "type": "Microsoft.Network/networkSecurityGroups", + "name": "[variables('networkSecurityGroupName')]", + "location": "[resourceGroup().location]", + "tags": { "displayName": "NSG" }, + "properties": { + "securityRules": [ + { + "name": "port_10249-10255_172", + "properties": { + "description": "port_10249-10255_172", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "10249-10255", + "sourceAddressPrefix": "172.17.0.1/32", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 120, + "direction": "Inbound" + } + }, + { + "name": "port_10249-10255_127", + "properties": { + "description": "port_10249-10255_127", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "10249-10255", + "sourceAddressPrefix": "127.0.0.1/32", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 122, + "direction": "Inbound" + } + }, + { + "name": "Port_10249-10255-block", + "properties": { + "description": "Port_10249-10255-block", + "protocol": "Tcp", + "sourcePortRange": "*", + "destinationPortRange": "10249-10255", + "sourceAddressPrefix": "Internet", + "destinationAddressPrefix": "*", + "access": "Deny", + "priority": 130, + "direction": "Inbound" + } + }, + { + "name": "in-rule", + "properties": { + "description": "All in", + "protocol": "Tcp", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "Internet", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 140, + "direction": "Inbound" + } + }, + { + "name": "block-8080", + "properties": { + "description": "block-8080", + "protocol": "Tcp", + "sourcePortRange": "8080", + "destinationPortRange": "*", + "sourceAddressPrefix": "Internet", + "destinationAddressPrefix": "*", + "access": "Deny", + "priority": 104, + "direction": "Outbound" + } + }, + { + "name": "out-rule", + "properties": { + "description": "All out", + "protocol": "Tcp", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "Internet", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 110, + "direction": "Outbound" + } + } + ] + } + }, + { + "apiVersion": "2017-04-01", + "type": "Microsoft.Network/publicIPAddresses", + "name": "[variables('publicIPAddressName')]", + "location": "[resourceGroup().location]", + "properties": { + "publicIPAllocationMethod": "[variables('publicIPAddressType')]", + "dnsSettings": { + "domainNameLabel": "[concat(parameters('vmName'), parameters('dnsLabelPrefix'))]" + } + } + }, + { + "apiVersion": "2017-04-01", + "type": "Microsoft.Network/virtualNetworks", + "name": "[variables('virtualNetworkName')]", + "location": "[resourceGroup().location]", + "dependson": [ + "[concat('Microsoft.Network/networkSecurityGroups/', variables('networkSecurityGroupName'))]" + ], + "properties": { + "addressSpace": { + "addressPrefixes": [ "[variables('addressPrefix')]" ] + }, + "subnets": [ + { + "name": "[variables('subnetName')]", + "properties": { + "addressPrefix": "[variables('subnetPrefix')]", + "networkSecurityGroup": { + "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]" + } + } + } + ] + } + }, + { + "apiVersion": "2017-04-01", + "type": "Microsoft.Network/networkInterfaces", + "name": "[variables('nicName')]", + "location": "[resourceGroup().location]", + "dependsOn": [ + "[resourceId('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", + "[resourceId('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" + ], + "properties": { + "ipConfigurations": [ { + "name": "ipconfig1", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]" }, + "subnet": { "id": "[variables('subnetRef')]" } + } + } + ] + } + }, + { + "apiVersion": "2017-03-30", + "type": "Microsoft.Compute/virtualMachines", + "name": "[parameters('vmName')]", + "location": "[resourceGroup().location]", + "dependsOn": [ + "[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]", + "[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"], + "properties": { + "hardwareProfile": { "vmSize": "[parameters('vmSize')]"}, + "osProfile": { + "computerName": "[parameters('vmName')]", + "adminUsername": "[parameters('adminUsername')]", + "linuxConfiguration": { + "disablePasswordAuthentication": true, + "ssh": { "publicKeys": [{ + "path": "[variables('sshKeyPath')]", + "keyData": "[parameters('sshKeyData')]" + }]}}}, + "storageProfile": { + "imageReference": { + "publisher": "[variables('imagePublisher')]", + "offer": "[variables('imageOffer')]", + "sku": "[parameters('ubuntuOSVersion')]", + "version": "latest" + }, + "osDisk": { "diskSizeGB": 127, "createOption": "FromImage" }, + "dataDisks": [ {"diskSizeGB": 127, "lun": 0, "createOption": "Empty" }]}, + "networkProfile": { + "networkInterfaces": [{ "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"}]}, + "diagnosticsProfile": { + "bootDiagnostics": { "enabled": true, + "storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName')), '2016-01-01').primaryEndpoints.blob)]" + }} } + }, + + { + "apiVersion": "2017-12-01", + "type": "Microsoft.Compute/virtualMachines/extensions", + "name": "[concat(parameters('vmName'),'/onap')]", + "location": "[resourceGroup().location]", + "dependsOn": ["[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]"], + "properties": { + "publisher": "Microsoft.Azure.Extensions", + "type": "CustomScript", + "typeHandlerVersion": "2.0", + "autoUpgradeMinorVersion": true, + "settings": { + "fileUris": [ "[parameters('scriptURL')]" ], + "commandToExecute": "[concat('./' , parameters('scriptName'), ' -b ', parameters('onapBranch'), ' -s ', parameters('vmName'), ' -e ', parameters('onapEnvironment'))]" + } + } + } + + ], + "outputs": { + "hostname": { + "type": "string", + "value": "[reference(variables('publicIPAddressName')).dnsSettings.fqdn]" + }, + "sshCommand": { + "type": "string", + "value": "[concat('ssh ', parameters('adminUsername'), '@', reference(variables('publicIPAddressName')).dnsSettings.fqdn)]" + } + } +} diff --git a/deploy/azure/_arm_deploy_onap_cd_z_parameters.json b/deploy/azure/_arm_deploy_onap_cd_z_parameters.json new file mode 100644 index 0000000..93cb676 --- /dev/null +++ b/deploy/azure/_arm_deploy_onap_cd_z_parameters.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "scriptURL": { "value": "https://jira.onap.org/secure/attachment/11609/oom_entrypoint.sh"}, + "onapBranch": { "value": "master" }, + "onapEnvironment": { "value": "onap"}, + "vmName": { "value": "a-replace-this-0" }, + "sshKeyData": { + "value": "ssh-rsa AA-add-your-public-key-obrienbiometrics" + }, + "dnsLabelPrefix": { "value": "replacethis0" }, + "vmSize": { "value": "Standard_D32s_v3" }, + "scriptName": { "value": "oom_entrypoint.sh"}, + "osType": { "value": "Linux" }, + "adminUsername": { "value": "ubuntu"} + } +} diff --git a/deploy/azure/oom_deployment.sh b/deploy/azure/oom_deployment.sh new file mode 100755 index 0000000..3c4196c --- /dev/null +++ b/deploy/azure/oom_deployment.sh @@ -0,0 +1,92 @@ +#!/bin/bash +############################################################################# +# +# Copyright © 2018 Amdocs. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################# +# +# This installation is for a rancher managed install of kubernetes +# after this run the standard oom install +# this installation can be run on amy ubuntu 16.04 VM or physical host +# https://wiki.onap.org/display/DW/ONAP+on+Kubernetes +# source from https://jira.onap.org/browse/OOM-715 +# Michael O'Brien +# Amsterdam +# Rancher 1.6.10, Kubernetes 1.7.7, Kubectl 1.7.7, Helm 2.3.0, Docker 1.12 +# master +# Rancher 1.6.14, Kubernetes 1.8.6, Kubectl 1.8.6, Helm 2.6.1, Docker 17.03 +# run as root - because of the logout that would be required after the docker user set +usage() { +cat <<EOF +Usage: $0 [PARAMs] +-u : Display usage +-b [branch] : branch = master or amsterdam (required) +-s [server] : server = IP or DNS name (required) +-e [environment] : use the default (onap) +-r [resourcegroup] : ARM resource group name +-t [template] : ARM template file +-p [parameters] : ARM parameters file +EOF +} + +install_onap() { + az group delete --name $RESOURCE_GROUP -y + az group create --name $RESOURCE_GROUP --location eastus2 + az group deployment create --resource-group $RESOURCE_GROUP --template-file $TEMPLATE --parameters @$PARAMETERS +} + + +BRANCH= +SERVER= +ENVIRON= +RESOURCE_GROUP= +TEMPLATE= +PARAMETERS= +while getopts ":b:s:e:r:t:p:u:" PARAM; do + case $PARAM in + u) + usage + exit 1 + ;; + b) + BRANCH=${OPTARG} + ;; + e) + ENVIRON=${OPTARG} + ;; + s) + SERVER=${OPTARG} + ;; + r) + RESOURCE_GROUP=${OPTARG} + ;; + t) + TEMPLATE=${OPTARG} + ;; + p) + PARAMETERS=${OPTARG} + ;; + ?) + usage + exit + ;; + esac +done + +if [[ -z $BRANCH ]]; then + usage + exit 1 +fi + +install_onap $RESOURCE_GROUP $TEMPLATE $BRANCH $SERVER $ENVIRON $PARAMETERS diff --git a/deploy/rancher/oom_entrypoint.sh b/deploy/rancher/oom_entrypoint.sh new file mode 100755 index 0000000..551f404 --- /dev/null +++ b/deploy/rancher/oom_entrypoint.sh @@ -0,0 +1,93 @@ +#!/bin/bash +############################################################################# +# +# Copyright © 2018 Amdocs. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################# +# +# This installation is for a rancher managed install of kubernetes +# after this run the standard oom install +# this installation can be run on amy ubuntu 16.04 VM or physical host +# https://wiki.onap.org/display/DW/ONAP+on+Kubernetes +# source from https://jira.onap.org/browse/OOM-715 +# Michael O'Brien +# +# Amsterdam +# Rancher 1.6.10, Kubernetes 1.7.7, Kubectl 1.7.7, Helm 2.3.0, Docker 1.12 +# master +# Rancher 1.6.14, Kubernetes 1.8.10, Kubectl 1.8.10, Helm 2.8.2, Docker 17.03 +# run as root - because of the logout that would be required after the docker user set + +usage() { +cat <<EOF +Usage: $0 [PARAMs] +-u : Display usage +-b [branch] : branch = master or amsterdam (required) +-s [server] : server = IP or DNS name (required) +-e [environment] : use the default (onap) +EOF +} + +install_rancher_and_onap() { + echo "Running rancher install first - 20 min" + # the curl commands are until OOM-710 is merged + wget https://jira.onap.org/secure/attachment/11558/oom_rancher_setup.sh + sudo chmod 777 oom_rancher_setup.sh + sudo ./oom_rancher_setup.sh -b $BRANCH -s $SERVER -e $ENVIRON + echo "Running oom install - 45-90 min" + wget https://jira.onap.org/secure/attachment/11608/cd.sh + sudo chmod 777 cd.sh + wget https://jira.onap.org/secure/attachment/11124/aaiapisimpledemoopenecomporg.cer + if [ "$BRANCH" == "amsterdam" ]; then + wget https://jira.onap.org/secure/attachment/11218/onap-parameters-amsterdam.yaml + sudo cp onap-parameters-amsterdam.yaml onap-parameters.yaml + else + wget https://jira.onap.org/secure/attachment/11414/values.yaml + fi + wget https://jira.onap.org/secure/attachment/11126/aai-cloud-region-put.json + sudo ./cd.sh -b $BRANCH -e $ENVIRON +} + +BRANCH=master +SERVER= +ENVIRON=onap + +while getopts ":b:s:e:u:" PARAM; do + case $PARAM in + u) + usage + exit 1 + ;; + b) + BRANCH=${OPTARG} + ;; + e) + ENVIRON=${OPTARG} + ;; + s) + SERVER=${OPTARG} + ;; + ?) + usage + exit + ;; + esac +done + +if [[ -z $SERVER ]]; then + usage + exit 1 +fi + +install_rancher_and_onap $BRANCH $SERVER $ENVIRON diff --git a/deploy/rancher/oom_rancher_setup.sh b/deploy/rancher/oom_rancher_setup.sh new file mode 100755 index 0000000..328d513 --- /dev/null +++ b/deploy/rancher/oom_rancher_setup.sh @@ -0,0 +1,228 @@ +#!/bin/bash +############################################################################# +# +# Copyright © 2018 Amdocs, Bell. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################# +# +# This installation is for a rancher managed install of kubernetes +# after this run the standard oom install +# this installation can be run on amy ubuntu 16.04 VM or physical host +# https://wiki.onap.org/display/DW/ONAP+on+Kubernetes +# source from https://jira.onap.org/browse/OOM-715 +# Michael O'Brien +# Amsterdam +# Rancher 1.6.10, Kubernetes 1.7.7, Kubectl 1.7.7, Helm 2.3.0, Docker 1.12 +# master +# Rancher 1.6.14, Kubernetes 1.8.10, Kubectl 1.8.10, Helm 2.8.2, Docker 17.03 +# run as root - because of the logout that would be required after the docker user set + +usage() { +cat <<EOF +Usage: $0 [PARAMs] +-u : Display usage +-b [branch] : branch = master or amsterdam (required) +-s [server] : server = IP or DNS name (required) +-e [environment] : use the default (onap) +EOF +} + +install_onap() { + if [ "$BRANCH" == "amsterdam" ]; then + RANCHER_VERSION=1.6.10 + KUBECTL_VERSION=1.7.7 + HELM_VERSION=2.3.0 + DOCKER_VERSION=1.12 + else + RANCHER_VERSION=1.6.14 + KUBECTL_VERSION=1.8.10 + HELM_VERSION=2.8.2 + DOCKER_VERSION=17.03 + fi + + echo "Installing on ${SERVER} for ${BRANCH}: Rancher: ${RANCHER_VERSION} Kubectl: ${KUBECTL_VERSION} Helm: ${HELM_VERSION} Docker: ${DOCKER_VERSION}" + sudo echo "127.0.0.1 ${SERVER}" >> /etc/hosts + + echo "If you must install as non-root - comment out the docker install below - run it separately, run the user mod, logout/login and continue this script" + curl https://releases.rancher.com/install-docker/$DOCKER_VERSION.sh | sh + # when running as non-root (ubuntu) run the following and logout/log back in + #sudo usermod -aG docker ubuntu + + echo "install make - required for beijing+" + sudo apt-get install make -y + + sudo docker run -d --restart=unless-stopped -p 8880:8080 --name rancher_server rancher/server:v$RANCHER_VERSION + sudo curl -LO https://storage.googleapis.com/kubernetes-release/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl + sudo chmod +x ./kubectl + sudo mv ./kubectl /usr/local/bin/kubectl + sudo mkdir ~/.kube + wget http://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-linux-amd64.tar.gz + sudo tar -zxvf helm-v${HELM_VERSION}-linux-amd64.tar.gz + sudo mv linux-amd64/helm /usr/local/bin/helm + + # create kubernetes environment on rancher using cli + RANCHER_CLI_VER=0.6.7 + KUBE_ENV_NAME=$ENVIRON + wget https://releases.rancher.com/cli/v${RANCHER_CLI_VER}/rancher-linux-amd64-v${RANCHER_CLI_VER}.tar.gz + sudo tar -zxvf rancher-linux-amd64-v${RANCHER_CLI_VER}.tar.gz + sudo cp rancher-v${RANCHER_CLI_VER}/rancher . + sudo chmod +x ./rancher + + echo "install jq" + apt install jq -y + echo "wait for rancher server container to finish - 3 min" + sleep 60 + echo "2 more min" + sleep 60 + echo "1 min left" + sleep 60 + + echo "get public and private tokens back to the rancher server so we can register the client later" + API_RESPONSE=`curl -s 'http://127.0.0.1:8880/v2-beta/apikey' -d '{"type":"apikey","accountId":"1a1","name":"autoinstall","description":"autoinstall","created":null,"kind":null,"removeTime":null,"removed":null,"uuid":null}'` + # Extract and store token + echo "API_RESPONSE: $API_RESPONSE" + KEY_PUBLIC=`echo $API_RESPONSE | jq -r .publicValue` + KEY_SECRET=`echo $API_RESPONSE | jq -r .secretValue` + echo "publicValue: $KEY_PUBLIC secretValue: $KEY_SECRET" + + export RANCHER_URL=http://${SERVER}:8880 + export RANCHER_ACCESS_KEY=$KEY_PUBLIC + export RANCHER_SECRET_KEY=$KEY_SECRET + ./rancher env ls + echo "wait 60 sec for rancher environments can settle before we create the onap kubernetes one" + sleep 60 + + echo "Creating kubernetes environment named ${KUBE_ENV_NAME}" + ./rancher env create -t kubernetes $KUBE_ENV_NAME > kube_env_id.json + PROJECT_ID=$(<kube_env_id.json) + echo "env id: $PROJECT_ID" + export RANCHER_HOST_URL=http://${SERVER}:8880/v1/projects/$PROJECT_ID + echo "you should see an additional kubernetes environment usually with id 1a7" + ./rancher env ls + # optionally disable cattle env + + # add host registration url + # https://github.com/rancher/rancher/issues/2599 + # wait for REGISTERING to ACTIVE + echo "sleep 90 to wait for REG to ACTIVE" + ./rancher env ls + sleep 30 + echo "check on environments again before registering the URL response" + ./rancher env ls + sleep 30 + ./rancher env ls + echo "60 more sec" + sleep 60 + + REG_URL_RESPONSE=`curl -X POST -u $KEY_PUBLIC:$KEY_SECRET -H 'Accept: application/json' -H 'ContentType: application/json' -d '{"name":"$SERVER"}' "http://$SERVER:8880/v1/projects/$PROJECT_ID/registrationtokens"` + echo "REG_URL_RESPONSE: $REG_URL_RESPONSE" + echo "wait for server to finish url configuration - 5 min" + sleep 240 + echo "60 more sec" + sleep 60 + # see registrationUrl in + REGISTRATION_TOKENS=`curl http://127.0.0.1:8880/v2-beta/registrationtokens` + echo "REGISTRATION_TOKENS: $REGISTRATION_TOKENS" + REGISTRATION_URL=`echo $REGISTRATION_TOKENS | jq -r .data[0].registrationUrl` + REGISTRATION_DOCKER=`echo $REGISTRATION_TOKENS | jq -r .data[0].image` + REGISTRATION_TOKEN=`echo $REGISTRATION_TOKENS | jq -r .data[0].token` + echo "Registering host for image: $REGISTRATION_DOCKER url: $REGISTRATION_URL registrationToken: $REGISTRATION_TOKEN" + HOST_REG_COMMAND=`echo $REGISTRATION_TOKENS | jq -r .data[0].command` + sudo docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/racher:/var/lib/rancher $REGISTRATION_DOCKER $RANCHER_URL/v1/scripts/$REGISTRATION_TOKEN + echo "waiting 8 min for host registration to finish" + sleep 420 + echo "1 more min" + sleep 60 + #read -p "wait for host registration to complete before generating the client token....." + + # base64 encode the kubectl token from the auth pair + # generate this after the host is registered + KUBECTL_TOKEN=$(echo -n 'Basic '$(echo -n "$RANCHER_ACCESS_KEY:$RANCHER_SECRET_KEY" | base64 -w 0) | base64 -w 0) + echo "KUBECTL_TOKEN base64 encoded: ${KUBECTL_TOKEN}" + # add kubectl config - NOTE: the following spacing has to be "exact" or kubectl will not connect - with a localhost:8080 error + cat > ~/.kube/config <<EOF +apiVersion: v1 +kind: Config +clusters: +- cluster: + api-version: v1 + insecure-skip-tls-verify: true + server: "https://$SERVER:8880/r/projects/$PROJECT_ID/kubernetes:6443" + name: "${ENVIRON}" +contexts: +- context: + cluster: "${ENVIRON}" + user: "${ENVIRON}" + name: "${ENVIRON}" +current-context: "${ENVIRON}" +users: +- name: "${ENVIRON}" + user: + token: "$KUBECTL_TOKEN" + +EOF + + echo "run the following if you installed a higher kubectl version than the server" + echo "helm init --upgrade" + echo "Verify all pods up on the kubernetes system - will return localhost:8080 until a host is added" + echo "kubectl get pods --all-namespaces" + kubectl get pods --all-namespaces + echo "upgrade server side of helm in kubernetes" + sudo helm version + sudo helm init --upgrade + echo "sleep 90" + sleep 90 + sudo helm version + echo "start helm server" + sudo helm serve & + echo "sleep 30" + sleep 30 + echo "add local helm repo" + sudo helm repo add local http://127.0.0.1:8879 + sudo helm repo list +} + +BRANCH= +SERVER= +ENVIRON= + +while getopts ":b:s:e:u:" PARAM; do + case $PARAM in + u) + usage + exit 1 + ;; + b) + BRANCH=${OPTARG} + ;; + e) + ENVIRON=${OPTARG} + ;; + s) + SERVER=${OPTARG} + ;; + ?) + usage + exit + ;; + esac +done + +if [[ -z $BRANCH ]]; then + usage + exit 1 +fi + +install_onap $BRANCH $SERVER $ENVIRON + |