From f3519424a5c99b59e2b508dae510cdac27cc6dc5 Mon Sep 17 00:00:00 2001 From: "stark, steven" Date: Thu, 5 Dec 2019 14:14:32 -0800 Subject: [INT] various updates to AKS deployment scripts - Adding support for pluggable post-install scripts. See README. - Adding pre_install check to validate the correct software is installed before attempting deployment. - Updating AKS deploy command line to support azure cli 2.0.75. Issue-ID: INT-1398 Signed-off-by: stark, steven Change-Id: I1ff819e96a3f34c88580e90e8d6f2b79979a7a61 --- deployment/aks/README.md | 41 +++++ deployment/aks/bootstrap_onap.sh | 91 ----------- deployment/aks/cloud.sh | 88 +++++++---- deployment/aks/create_aks.sh | 4 +- deployment/aks/create_onap.sh | 9 +- deployment/aks/post-install/000_bootstrap_onap.sh | 91 +++++++++++ deployment/aks/post-install/bootstrap.sh | 176 --------------------- deployment/aks/post-install/bootstrap/bootstrap.sh | 176 +++++++++++++++++++++ deployment/aks/post-install/bootstrap/create_az.sh | 42 +++++ .../aks/post-install/bootstrap/create_clli.sh | 59 +++++++ .../post-install/bootstrap/create_cloud_region.sh | 75 +++++++++ .../bootstrap/create_cloud_region_relationship.sh | 46 ++++++ .../create_cloud_region_subscriber_relationship.sh | 62 ++++++++ .../post-install/bootstrap/create_cloud_site.sh | 50 ++++++ .../aks/post-install/bootstrap/create_customer.sh | 43 +++++ .../aks/post-install/bootstrap/create_lob.sh | 34 ++++ .../post-install/bootstrap/create_owning_entity.sh | 34 ++++ .../aks/post-install/bootstrap/create_platform.sh | 34 ++++ .../aks/post-install/bootstrap/create_project.sh | 34 ++++ .../post-install/bootstrap/create_service_type.sh | 42 +++++ .../post-install/bootstrap/create_subscription.sh | 65 ++++++++ deployment/aks/post-install/create_az.sh | 42 ----- deployment/aks/post-install/create_clli.sh | 59 ------- deployment/aks/post-install/create_cloud_region.sh | 75 --------- .../create_cloud_region_relationship.sh | 46 ------ .../create_cloud_region_subscriber_relationship.sh | 62 -------- deployment/aks/post-install/create_cloud_site.sh | 50 ------ deployment/aks/post-install/create_customer.sh | 43 ----- deployment/aks/post-install/create_lob.sh | 34 ---- .../aks/post-install/create_owning_entity.sh | 34 ---- deployment/aks/post-install/create_platform.sh | 34 ---- deployment/aks/post-install/create_project.sh | 34 ---- deployment/aks/post-install/create_service_type.sh | 42 ----- deployment/aks/post-install/create_subscription.sh | 65 -------- deployment/aks/post_install.sh | 31 ++++ deployment/aks/pre_install.sh | 108 +++++++++++++ 36 files changed, 1133 insertions(+), 922 deletions(-) delete mode 100755 deployment/aks/bootstrap_onap.sh create mode 100755 deployment/aks/post-install/000_bootstrap_onap.sh delete mode 100755 deployment/aks/post-install/bootstrap.sh create mode 100755 deployment/aks/post-install/bootstrap/bootstrap.sh create mode 100755 deployment/aks/post-install/bootstrap/create_az.sh create mode 100755 deployment/aks/post-install/bootstrap/create_clli.sh create mode 100755 deployment/aks/post-install/bootstrap/create_cloud_region.sh create mode 100755 deployment/aks/post-install/bootstrap/create_cloud_region_relationship.sh create mode 100755 deployment/aks/post-install/bootstrap/create_cloud_region_subscriber_relationship.sh create mode 100755 deployment/aks/post-install/bootstrap/create_cloud_site.sh create mode 100755 deployment/aks/post-install/bootstrap/create_customer.sh create mode 100755 deployment/aks/post-install/bootstrap/create_lob.sh create mode 100755 deployment/aks/post-install/bootstrap/create_owning_entity.sh create mode 100755 deployment/aks/post-install/bootstrap/create_platform.sh create mode 100755 deployment/aks/post-install/bootstrap/create_project.sh create mode 100755 deployment/aks/post-install/bootstrap/create_service_type.sh create mode 100755 deployment/aks/post-install/bootstrap/create_subscription.sh delete mode 100755 deployment/aks/post-install/create_az.sh delete mode 100755 deployment/aks/post-install/create_clli.sh delete mode 100755 deployment/aks/post-install/create_cloud_region.sh delete mode 100755 deployment/aks/post-install/create_cloud_region_relationship.sh delete mode 100755 deployment/aks/post-install/create_cloud_region_subscriber_relationship.sh delete mode 100755 deployment/aks/post-install/create_cloud_site.sh delete mode 100755 deployment/aks/post-install/create_customer.sh delete mode 100755 deployment/aks/post-install/create_lob.sh delete mode 100755 deployment/aks/post-install/create_owning_entity.sh delete mode 100755 deployment/aks/post-install/create_platform.sh delete mode 100755 deployment/aks/post-install/create_project.sh delete mode 100755 deployment/aks/post-install/create_service_type.sh delete mode 100755 deployment/aks/post-install/create_subscription.sh create mode 100755 deployment/aks/post_install.sh create mode 100755 deployment/aks/pre_install.sh (limited to 'deployment/aks') diff --git a/deployment/aks/README.md b/deployment/aks/README.md index 4eb37cbc3..a5be9a904 100644 --- a/deployment/aks/README.md +++ b/deployment/aks/README.md @@ -54,6 +54,8 @@ options: -f, --no-prompt executes with no prompt for confirmation -n, --no-install don't install ONAP -o, --override create integration override for robot configuration +-d, --no-validate dont validate pre-reqs before executing deployment +-p, --post-install execute post-install scripts -h, --help provide brief overview of script This script deploys a cloud environment in Azure. @@ -173,6 +175,45 @@ The template used to create the override file is ``./util/integration-override.t In ``cloud.conf``, there's a parameter ``OOM_OVERRIDES`` available that's used to provide command line overrides to ``helm deploy``. This uses the standard helm syntax, so if you're using it the value should look like ``OOM_OVERRIDES="--set vid.enabled=false,so.image=abc"``. If you don't want to override anything, just set this value to an empty string. +### Pre Install + +When you run ``cloud.sh`` it will execute ``pre_install.sh`` first, which checks a few things: + +- It checks you have the correct pre-reqs installed. So, it'll make sure you have kubectl, azure cli, helm, etc... +- It checks that the version of kubernetes in ``cloud.conf`` is available in Azure. +- It checks the version of azure cli is >= to the baselined version (you can check this version by looking at the top of ``pre_install.sh``). The Azure cli is introduced changes in minor versions that aren't backwards compatible. +- It checks that the version of kubectl installed is at **MOST** 1 minor version different than the version of kubernetes in ``cloud.conf``. + +If you would like to skip ``pre_install.sh`` and run the deployment anyways, pass the flag ``--no-validate`` to ``cloud.sh``, like this: + +``` +$ ./cloud.sh --no-validate + +``` + + +### Post Install + +After ONAP is deployed, you have the option of executing an arbitrary set of post-install scripts. This is enabled by passing the ``--post-install`` flag to ``cloud.sh``, like this: + +``` +$ ./cloud.sh --post-install + +``` + +These post-install scripts need to be executable from the command line, and will be provided two parameters that they can use to perform their function: + +- /path/to/onap.conf : This is created during the deployment, and has various ONAP and OpenStack parameters. +- /path/to/cloud.conf : this is the same ``cloud.conf`` that's used during the original deployment. + + +Your post-install scripts can disregard these parameters, or source them and use the parameters as-needed. + +Included with this repo is one post-install script (``000_bootstrap_onap.sh``)that bootstraps AAI, VID, and SO with cloud and customer details so that ONAP is ready to model and instantiate a VNF. + +In order to include other custom post-install scripts, simply put them in the ``post-install`` directory, and make sure to set its mode to executable. They are executed in alphabetical order. + + ## Post Deployment After ONAP and DevStack are deployed, there will be a ``deployment.notes`` file with instructions on how to access the various components. The ``BUILD_DIR`` specified in ``cloud.conf`` will contain a new ssh key, kubeconfig, and other deployment artifacts as well. diff --git a/deployment/aks/bootstrap_onap.sh b/deployment/aks/bootstrap_onap.sh deleted file mode 100755 index 99661a9b6..000000000 --- a/deployment/aks/bootstrap_onap.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash -# Copyright 2019 AT&T Intellectual Property. 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. - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -CONF=$1 - -if [ -z "$CONF" ]; then - echo "Configuration file required, exiting..." - exit 1 -fi - -. $CONF - -kubectl create configmap onap-bootstrap --from-file=$DIR/post-install/ --from-file=kubeconfig=$KUBECONFIG --from-file=onap.conf=$CONF - -cat < /tmp/onap-bootstrap-log - -kubectl delete pod onap-bootstrap -kubectl delete configmap onap-bootstrap - -if [ "$podstatus" = "Error" ]; then - echo "ONAP bootstrap failed!" -fi diff --git a/deployment/aks/cloud.sh b/deployment/aks/cloud.sh index ac471a91b..555ba12cc 100755 --- a/deployment/aks/cloud.sh +++ b/deployment/aks/cloud.sh @@ -17,6 +17,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" NO_PROMPT=0 NO_INSTALL=0 +NO_VALIDATE=0 +POST_INSTALL=0 OVERRIDE=0 OPENSTACK_CLI_POD="os-cli-0" @@ -38,6 +40,8 @@ while test $# -gt 0; do echo "-f, --no-prompt executes with no prompt for confirmation" echo "-n, --no-install don't install ONAP" echo "-o, --override create integration override for robot configuration" + echo "-d, --no-validate dont validate pre-reqs before executing deployment" + echo "-p, --post-install execute post-install scripts" echo "-h, --help provide brief overview of script" echo " " echo "This script deploys a cloud environment in Azure." @@ -62,6 +66,14 @@ while test $# -gt 0; do shift OVERRIDE=1 ;; + -d|--no-validate) + shift + NO_VALIDATE=1 + ;; + -p|--post-install) + shift + POST_INSTALL=1 + ;; *) echo "Unknown Argument. Try running with --help ." exit 0 @@ -69,6 +81,13 @@ while test $# -gt 0; do esac done +if [ $NO_VALIDATE = 0 ]; then + $DIR/pre_install.sh "$AKS_K8_VERSION" "$LOCATION" + if [ $? -ne 0 ]; then + exit 1 + fi +fi + cat < "$BUILD_DIR/onap.conf" < "$BUILD_DIR/deployment.notes" < "$BUILD_DIR/onap.conf" </dev/null 2>&1 && pwd )" + +CONF=$1 + +if [ -z "$CONF" ]; then + echo "Configuration file required, exiting..." + exit 1 +fi + +. $CONF + +kubectl create configmap onap-bootstrap --from-file=$DIR/bootstrap/ --from-file=kubeconfig=$KUBECONFIG --from-file=onap.conf=$CONF + +cat < /tmp/onap-bootstrap-log + +kubectl delete pod onap-bootstrap +kubectl delete configmap onap-bootstrap + +if [ "$podstatus" = "Error" ]; then + echo "ONAP bootstrap failed!" +fi diff --git a/deployment/aks/post-install/bootstrap.sh b/deployment/aks/post-install/bootstrap.sh deleted file mode 100755 index 646a502e2..000000000 --- a/deployment/aks/post-install/bootstrap.sh +++ /dev/null @@ -1,176 +0,0 @@ -#!/bin/bash -# Copyright 2019 AT&T Intellectual Property. 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. - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -set -x - -if [ ! -d $BUILD_DIR ]; then - mkdir -p $BUILD_DIR -fi - -# TODO -# Get these from values.yaml -export AAI_DNS_NAME=aai.onap -export AAI_PORT=8443 -export AAI_USER=AAI -export AAI_PASS=AAI -export AAI_PROTOCOL=https -export VID_DNS_NAME=vid.onap -export VID_PORT=8443 -export VID_PROTOCOL=https -export SDC_DNS_NAME=sdc-fe.onap -export SDC_PORT=9443 -export SDC_PROTOCOL=https - -DATA_FILE=$BUILD_DIR"/get_tenant_id.json" - -cat > $DATA_FILE </dev/null 2>&1 && pwd )" + +set -x + +if [ ! -d $BUILD_DIR ]; then + mkdir -p $BUILD_DIR +fi + +# TODO +# Get these from values.yaml +export AAI_DNS_NAME=aai.onap +export AAI_PORT=8443 +export AAI_USER=AAI +export AAI_PASS=AAI +export AAI_PROTOCOL=https +export VID_DNS_NAME=vid.onap +export VID_PORT=8443 +export VID_PROTOCOL=https +export SDC_DNS_NAME=sdc-fe.onap +export SDC_PORT=9443 +export SDC_PROTOCOL=https + +DATA_FILE=$BUILD_DIR"/get_tenant_id.json" + +cat > $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE < $DATA_FILE </dev/null 2>&1 && pwd )" + +ONAP_CONF=$1 +CLOUD_CONF=$2 + +pushd . + +cd $DIR/post-install + +for filename in *; do + if [ -f $filename ]; then + ./$filename "$ONAP_CONF" "$CLOUD_CONF" + fi +done + +popd \ No newline at end of file diff --git a/deployment/aks/pre_install.sh b/deployment/aks/pre_install.sh new file mode 100755 index 000000000..6bbbab9b6 --- /dev/null +++ b/deployment/aks/pre_install.sh @@ -0,0 +1,108 @@ +#!/bin/bash +# Copyright 2019 AT&T Intellectual Property. 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. + +KUBE_VERSION=$1 +LOCATION=$2 + +COMMANDS="kubectl helm make java az" + +CLI_MAJOR="2" +CLI_MINOR="0" +CLI_INC="75" + +function check_requirement() { + req=$1 + + command -v $1 + if [ $? -ne 0 ]; then + echo "$1 was not found on machine. Please install it before proceeding." + exit 1 + fi +} + +echo "Checking requirements are installed..." + +for req in $COMMANDS; do + check_requirement $req +done + +echo "Checking K8 version is available in Azure..." +if [ -z "$KUBE_VERSION" ]; then + echo "K8 version not provided in cloud.conf." + echo "Update cloud.conf with the desired version." + exit 1 +fi + +if [ -z "$LOCATION" ]; then + echo "Location not provided in cloud.conf." + echo "Update cloud.conf with the desired location." + exit 1 +fi + +supported_k8_versions=`az aks get-versions --location $LOCATION --output json --query 'orchestrators[].orchestratorVersion'` +echo $supported_k8_versions | grep -q $KUBE_VERSION +if [ $? -ne 0 ]; then + echo "K8 version $KUBE_VERSION is not supported in location $LOCATION" + echo "The supported versions are $supported_k8_versions." + echo "Update cloud.conf with a supported version." + exit 1 +fi + +echo "Checking Azure CLI version..." +installed_cli_version=`az --version | grep -e "^azure-cli" | awk '{print $2}'` +installed_major=`echo $installed_cli_version | cut -d "." -f 1` +installed_minor=`echo $installed_cli_version | cut -d "." -f 2` +installed_inc=`echo $installed_cli_version | cut -d "." -f 3` + +if [ $installed_major -lt $CLI_MAJOR ]; then + echo "Azure cli version is out of date." + echo "Major version required is $CLI_MAJOR but $installed_major is installed." + exit 1 +fi + +if [ $installed_minor -lt $CLI_MINOR ]; then + echo "Azure cli version is out of date." + echo "Minor version required is $CLI_INC but $installed_inc is installed." + exit 1 +fi + +if [ $installed_inc -lt $CLI_INC ]; then + echo "Azure cli version is out of date." + echo "Incremental version required is $CLI_INC but $installed_inc is installed." + exit 1 +fi + +echo "Checking kubectl version is compatible with the K8 version..." +kubectl_version=`kubectl version --client --short | awk '{print $3}'` +kubectl_major=`echo $kubectl_version | cut -d "." -f 1 | sed 's/v//'` +kubectl_minor=`echo $kubectl_version | cut -d "." -f 2` +k8_major=`echo $KUBE_VERSION | cut -d "." -f 1` +k8_minor=`echo $KUBE_VERSION | cut -d "." -f 2` + +if [ $kubectl_major -ne $k8_major ]; then + echo "kubectl major version $kubectl_major doesn't equal kubernetes server version $k8_major" + exit 1 +fi + +minor_difference=`echo "$(($kubectl_minor-$k8_minor))"` +minor_abs_diff=`echo $minor_difference | tr -d -` +if [ $minor_abs_diff -gt 1 ]; then + echo "The difference between k8 minor version $KUBE_VERSION and kubectl minor version $kubectl_version is greater than 1" + echo "Kubernetes supports kubectl within 1 minor version." + exit 1 +fi + +echo "All requirements satisfied..." +sleep 1 -- cgit 1.2.3-korg