#!/bin/bash ############################################################################# # # Copyright © 2019 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, RHEL 7.6 (root only), physical or cloud azure/aws 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 # beijing # Rancher 1.6.14, Kubernetes 1.8.10, Kubectl 1.8.10, Helm 2.8.2, Docker 17.03 # casablanca (until RC1) # Rancher 1.6.18, Kubernetes 1.10.3, Kubectl 1.10.3, Helm 2.9.2, Docker 17.03 # casablanca - integration change alignment for INT-586 - 29th Oct via LOG-806 # Rancher 1.6.22, Kubernetes 1.11.5, kubectl 1.11.5, Helm 2.9.1, Docker 17.03 # master/dublin - LOG-895 # Rancher 1.6.25, Kubernetes 1.11.5, kubectl 1.11.5, Helm 2.9.1, 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+ - installed via yum groupinstall Development Tools in RHEL" # ubuntu specific 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 for json parsing" sudo wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 -O jq sudo chmod 777 jq # not +x or jq will not be runnable from your non-root user sudo mv jq /usr/local/bin echo "wait for rancher server container to finish - 3 min" echo "if you are planning on running a co-located host to bring up more than 110 pods on a single vm - you have 3 min to add --max-pods=900 in additional kublet flags - in the k8s template" 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 to 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 <