#!/bin/bash ############################################################################# # Copyright © 2019 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 an RKE 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/OOM+RKE+Kubernetes+Deployment # source from https://jira.onap.org/browse/OOM-1598 # # master/dublin # RKE 0.1.16 Kubernetes 1.11.6, kubectl 1.11.6, Helm 2.9.1, Docker 18.06 # single node install, HA pending usage() { cat < cluster.yml <> /etc/hosts echo "Install docker - 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 RKE" sudo wget https://github.com/rancher/rke/releases/download/v$RKE_VERSION/rke_linux-amd64 mv rke_linux-amd64 rke sudo chmod +x rke sudo mv ./rke /usr/local/bin/rke echo "Install make - required for beijing+ - installed via yum groupinstall Development Tools in RHEL" # ubuntu specific sudo apt-get install make -y 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 echo "Bringing RKE up - using supplied cluster.yml" sudo rke up echo "wait 2 extra min for the cluster" sleep 60 echo "1 more min" sleep 60 echo "copy kube_config_cluter.yaml generated - to ~/.kube/config" sudo cp kube_config_cluster.yml ~/.kube/config # avoid using sudo for kubectl sudo chmod 777 ~/.kube/config 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 "install tiller/helm" kubectl -n kube-system create serviceaccount tiller kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller helm init --service-account tiller kubectl -n kube-system rollout status deploy/tiller-deploy echo "upgrade server side of helm in kubernetes" if [ "$USERNAME" == "root" ]; then helm version else sudo helm version fi echo "sleep 30" sleep 30 if [ "$USERNAME" == "root" ]; then helm init --upgrade else sudo helm init --upgrade fi echo "sleep 30" sleep 30 echo "verify both versions are the same below" if [ "$USERNAME" == "root" ]; then helm version else sudo helm version fi echo "start helm server" if [ "$USERNAME" == "root" ]; then helm serve & else sudo helm serve & fi echo "sleep 30" sleep 30 echo "add local helm repo" if [ "$USERNAME" == "root" ]; then helm repo add local http://127.0.0.1:8879 helm repo list else sudo helm repo add local http://127.0.0.1:8879 sudo helm repo list fi echo "To enable grafana dashboard - do this after running cd.sh which brings up onap - or you may get a 302xx port conflict" echo "kubectl expose -n kube-system deployment monitoring-grafana --type=LoadBalancer --name monitoring-grafana-client" echo "to get the nodeport for a specific VM running grafana" echo "kubectl get services --all-namespaces | grep graf" sudo docker version helm version kubectl version kubectl get services --all-namespaces kubectl get pods --all-namespaces echo "finished!" } BRANCH= SERVER= ENVIRON= VALIDATE=false USERNAME=ubuntu SSHPATH_PREFIX=~/.ssh while getopts ":b:s:e:u:l:k:v" PARAM; do case $PARAM in u) usage exit 1 ;; b) BRANCH=${OPTARG} ;; e) ENVIRON=${OPTARG} ;; s) SERVER=${OPTARG} ;; l) USERNAME=${OPTARG} ;; k) SSHKEY=${OPTARG} ;; v) VALIDATE=${OPTARG} ;; ?) usage exit ;; esac done if [[ -z $BRANCH ]]; then usage exit 1 fi install_onap $BRANCH $SERVER $ENVIRON $USERNAME $SSHPATH_PREFIX $SSHKEY $VALIDATE