#!/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/Cloud+Native+Deployment # source from https://jira.onap.org/browse/LOG-320 # Michael O'Brien # Amsterdam # Rancher 1.6.10, Kubernetes 1.7.7, Kubectl 1.7.7, Helm 2.3.0, Docker 1.12 # master/beijing # Rancher 1.6.18, Kubernetes 1.8.10, Kubectl 1.8.10, Helm 2.8.2, Docker 17.03 usage() { cat <> /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 sudo usermod -aG docker $USERNAME echo "install make - required for beijing+" sudo apt-get install make -y sudo docker run -d --restart=unless-stopped -p $PORT: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}:$PORT 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/config <