From: garciadeblas Date: Thu, 13 Apr 2023 16:07:44 +0000 (+0200) Subject: Replace OSM_STACK_NAME by OSM_NAMESPACE in installers scripts X-Git-Tag: release-v14.0-start~85 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F02%2F13202%2F1;p=osm%2Fdevops.git Replace OSM_STACK_NAME by OSM_NAMESPACE in installers scripts Change-Id: I5ce4bdc392fd64b4bed7479768b91adba53c67e4 Signed-off-by: garciadeblas --- diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index 489326db..449ca49e 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -30,7 +30,7 @@ function usage(){ echo -e " -b tags/v1.1.0 (a specific tag)" echo -e " ..." echo -e " -a : use this apt proxy url when downloading apt packages (air-gapped installation)" - echo -e " -s or user defined stack name when installed using swarm or namespace when installed using k8s, default is osm" + echo -e " -s namespace when installed using k8s, default is osm" echo -e " -H use specific juju host controller IP" echo -e " -S use VCA/juju secret key" echo -e " -P use VCA/juju public key file" @@ -112,12 +112,12 @@ function set_vca_variables() { OSM_VCA_CLOUDNAME="lxd-cloud" [ -n "$OSM_VCA_HOST" ] && OSM_VCA_CLOUDNAME="localhost" if [ -z "$OSM_VCA_HOST" ]; then - [ -z "$CONTROLLER_NAME" ] && OSM_VCA_HOST=`sg lxd -c "juju show-controller $OSM_STACK_NAME"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'` + [ -z "$CONTROLLER_NAME" ] && OSM_VCA_HOST=`sg lxd -c "juju show-controller $OSM_NAMESPACE"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'` [ -n "$CONTROLLER_NAME" ] && OSM_VCA_HOST=`juju show-controller $CONTROLLER_NAME |grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'` [ -z "$OSM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address" fi if [ -z "$OSM_VCA_SECRET" ]; then - [ -z "$CONTROLLER_NAME" ] && OSM_VCA_SECRET=$(parse_juju_password $OSM_STACK_NAME) + [ -z "$CONTROLLER_NAME" ] && OSM_VCA_SECRET=$(parse_juju_password $OSM_NAMESPACE) [ -n "$CONTROLLER_NAME" ] && OSM_VCA_SECRET=$(parse_juju_password $CONTROLLER_NAME) [ -z "$OSM_VCA_SECRET" ] && FATAL "Cannot obtain juju secret" fi @@ -126,7 +126,7 @@ function set_vca_variables() { [ -z "$OSM_VCA_PUBKEY" ] && FATAL "Cannot obtain juju public key" fi if [ -z "$OSM_VCA_CACERT" ]; then - [ -z "$CONTROLLER_NAME" ] && OSM_VCA_CACERT=$(juju controllers --format json | jq -r --arg controller $OSM_STACK_NAME '.controllers[$controller]["ca-cert"]' | base64 | tr -d \\n) + [ -z "$CONTROLLER_NAME" ] && OSM_VCA_CACERT=$(juju controllers --format json | jq -r --arg controller $OSM_NAMESPACE '.controllers[$controller]["ca-cert"]' | base64 | tr -d \\n) [ -n "$CONTROLLER_NAME" ] && OSM_VCA_CACERT=$(juju controllers --format json | jq -r --arg controller $CONTROLLER_NAME '.controllers[$controller]["ca-cert"]' | base64 | tr -d \\n) [ -z "$OSM_VCA_CACERT" ] && FATAL "Cannot obtain juju CA certificate" fi @@ -491,17 +491,17 @@ function generate_docker_env_files() { #creates secrets from env files which will be used by containers function kube_secrets(){ [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - kubectl create ns $OSM_STACK_NAME - kubectl create secret generic lcm-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/lcm.env - kubectl create secret generic mon-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/mon.env - kubectl create secret generic nbi-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/nbi.env - kubectl create secret generic ro-db-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/ro-db.env - kubectl create secret generic ro-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/ro.env - kubectl create secret generic keystone-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/keystone.env - kubectl create secret generic pol-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/pol.env + kubectl create ns $OSM_NAMESPACE + kubectl create secret generic lcm-secret -n $OSM_NAMESPACE --from-env-file=$OSM_DOCKER_WORK_DIR/lcm.env + kubectl create secret generic mon-secret -n $OSM_NAMESPACE --from-env-file=$OSM_DOCKER_WORK_DIR/mon.env + kubectl create secret generic nbi-secret -n $OSM_NAMESPACE --from-env-file=$OSM_DOCKER_WORK_DIR/nbi.env + kubectl create secret generic ro-db-secret -n $OSM_NAMESPACE --from-env-file=$OSM_DOCKER_WORK_DIR/ro-db.env + kubectl create secret generic ro-secret -n $OSM_NAMESPACE --from-env-file=$OSM_DOCKER_WORK_DIR/ro.env + kubectl create secret generic keystone-secret -n $OSM_NAMESPACE --from-env-file=$OSM_DOCKER_WORK_DIR/keystone.env + kubectl create secret generic pol-secret -n $OSM_NAMESPACE --from-env-file=$OSM_DOCKER_WORK_DIR/pol.env if [ -n "${INSTALL_NGSA}" ]; then - kubectl create secret generic ngsa-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/ngsa.env - kubectl create secret generic webhook-translator-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/webhook-translator.env + kubectl create secret generic ngsa-secret -n $OSM_NAMESPACE --from-env-file=$OSM_DOCKER_WORK_DIR/ngsa.env + kubectl create secret generic webhook-translator-secret -n $OSM_NAMESPACE --from-env-file=$OSM_DOCKER_WORK_DIR/webhook-translator.env fi [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -509,22 +509,22 @@ function kube_secrets(){ #deploys osm pods and services function deploy_osm_services() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - kubectl apply -n $OSM_STACK_NAME -f $OSM_K8S_WORK_DIR + kubectl apply -n $OSM_NAMESPACE -f $OSM_K8S_WORK_DIR [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } #deploy charmed services function deploy_charmed_services() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - juju add-model $OSM_STACK_NAME $OSM_VCA_K8S_CLOUDNAME - juju deploy ch:mongodb-k8s -m $OSM_STACK_NAME + juju add-model $OSM_NAMESPACE $OSM_VCA_K8S_CLOUDNAME + juju deploy ch:mongodb-k8s -m $OSM_NAMESPACE [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } function deploy_osm_pla_service() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function # corresponding to deploy_osm_services - kubectl apply -n $OSM_STACK_NAME -f $OSM_DOCKER_WORK_DIR/osm_pla + kubectl apply -n $OSM_NAMESPACE -f $OSM_DOCKER_WORK_DIR/osm_pla [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -720,9 +720,6 @@ function install_osm() { find_devops_folder - # TODO: the use of stacks come from docker-compose. We should probably remove - [ "${OSM_STACK_NAME}" == "osm" ] || OSM_DOCKER_WORK_DIR="$OSM_WORK_DIR/stack/$OSM_STACK_NAME" - track start release $RELEASE none none docker_tag $OSM_DOCKER_TAG none none installation_type $OSM_INSTALLATION_TYPE none none track checks checkingroot_ok @@ -771,7 +768,7 @@ function install_osm() { FATAL_TRACK k8scluster "install_kubeadm_cluster.sh failed" track k8scluster k8scluster_ok - JUJU_OPTS="-D ${OSM_DEVOPS} -s ${OSM_STACK_NAME} -i ${OSM_DEFAULT_IP} ${DEBUG_INSTALL} ${INSTALL_NOJUJU} ${INSTALL_CACHELXDIMAGES}" + JUJU_OPTS="-D ${OSM_DEVOPS} -s ${OSM_NAMESPACE} -i ${OSM_DEFAULT_IP} ${DEBUG_INSTALL} ${INSTALL_NOJUJU} ${INSTALL_CACHELXDIMAGES}" [ -n "${OSM_VCA_HOST}" ] && JUJU_OPTS="$JUJU_OPTS -H ${OSM_VCA_HOST}" [ -n "${LXD_CLOUD_FILE}" ] && JUJU_OPTS="$JUJU_OPTS -l ${LXD_CLOUD_FILE}" [ -n "${LXD_CRED_FILE}" ] && JUJU_OPTS="$JUJU_OPTS -L ${LXD_CRED_FILE}" @@ -825,9 +822,9 @@ function install_osm() { track osmclient osmclient_ok echo -e "Checking OSM health state..." - $OSM_DEVOPS/installers/osm_health.sh -s ${OSM_STACK_NAME} -k || \ + $OSM_DEVOPS/installers/osm_health.sh -s ${OSM_NAMESPACE} -k || \ (echo -e "OSM is not healthy, but will probably converge to a healthy state soon." && \ - echo -e "Check OSM status with: kubectl -n ${OSM_STACK_NAME} get all" && \ + echo -e "Check OSM status with: kubectl -n ${OSM_NAMESPACE} get all" && \ track healthchecks osm_unhealthy didnotconverge) track healthchecks after_healthcheck_ok @@ -946,7 +943,7 @@ function dump_vars(){ echo "OSM_DOCKER_WORK_DIR=$OSM_DOCKER_WORK_DIR" echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR" echo "OSM_K8S_WORK_DIR=$OSM_K8S_WORK_DIR" - echo "OSM_STACK_NAME=$OSM_STACK_NAME" + echo "OSM_NAMESPACE=$OSM_NAMESPACE" echo "OSM_VCA_HOST=$OSM_VCA_HOST" echo "OSM_VCA_PUBKEY=$OSM_VCA_PUBKEY" echo "OSM_VCA_SECRET=$OSM_VCA_SECRET" @@ -1023,7 +1020,7 @@ OSM_VCA_SECRET= OSM_VCA_PUBKEY= OSM_VCA_CLOUDNAME="localhost" OSM_VCA_K8S_CLOUDNAME="k8scloud" -OSM_STACK_NAME=osm +OSM_NAMESPACE=osm NO_HOST_PORTS="" DOCKER_NOBUILD="" REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg" @@ -1033,7 +1030,7 @@ OSM_DOCKER_WORK_DIR="${OSM_WORK_DIR}/docker" OSM_K8S_WORK_DIR="${OSM_DOCKER_WORK_DIR}/osm_pods" OSM_HELM_WORK_DIR="${OSM_WORK_DIR}/helm" OSM_HOST_VOL="/var/lib/osm" -OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_STACK_NAME}" +OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_NAMESPACE}" OSM_DOCKER_TAG=latest DOCKER_USER=opensourcemano PULL_IMAGES="y" @@ -1130,7 +1127,7 @@ while getopts ":a:b:r:n:k:u:R:D:o:O:m:N:H:S:s:t:U:P:A:l:L:K:d:p:T:f:F:-: hy" o; OSM_VCA_SECRET="${OPTARG}" ;; s) - OSM_STACK_NAME="${OPTARG}" && [[ ! "${OPTARG}" =~ $RE_CHECK ]] && echo "Namespace $OPTARG is invalid. Regex used for validation is $RE_CHECK" && exit 0 + OSM_NAMESPACE="${OPTARG}" && [[ ! "${OPTARG}" =~ $RE_CHECK ]] && echo "Namespace $OPTARG is invalid. Regex used for validation is $RE_CHECK" && exit 0 ;; t) OSM_DOCKER_TAG="${OPTARG}" @@ -1267,7 +1264,7 @@ fi [ -n "$TO_REBUILD" ] && [ "$TO_REBUILD" == " PLA" ] && [ -z "$INSTALL_PLA" ] && FATAL "Incompatible option: -m PLA cannot be used without --pla option" # if develop, we force master [ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master" -OSM_K8S_WORK_DIR="$OSM_DOCKER_WORK_DIR/osm_pods" && OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_STACK_NAME}" +OSM_K8S_WORK_DIR="$OSM_DOCKER_WORK_DIR/osm_pods" && OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_NAMESPACE}" [ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_K8S_MONITOR" ] && install_k8s_monitoring [ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_NGSA" ] && install_osm_ngsa_service [ -n "$INSTALL_ONLY" ] && echo -e "\nDONE" && exit 0 diff --git a/installers/install_juju.sh b/installers/install_juju.sh index dd9eb3b3..68c86280 100755 --- a/installers/install_juju.sh +++ b/installers/install_juju.sh @@ -73,11 +73,11 @@ snap-https-proxy: ${HTTPS_PROXY} EOF JUJU_BOOTSTRAP_OPTS="--model-default /tmp/.osm/model-config.yaml" fi - juju bootstrap -v --debug $OSM_VCA_K8S_CLOUDNAME $OSM_STACK_NAME \ + juju bootstrap -v --debug $OSM_VCA_K8S_CLOUDNAME $OSM_NAMESPACE \ --config controller-service-type=loadbalancer \ --agent-version=$JUJU_AGENT_VERSION \ ${JUJU_BOOTSTRAP_OPTS} \ - || FATAL "Failed to bootstrap controller $OSM_STACK_NAME in cloud $OSM_VCA_K8S_CLOUDNAME" + || FATAL "Failed to bootstrap controller $OSM_NAMESPACE in cloud $OSM_VCA_K8S_CLOUDNAME" [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -109,8 +109,8 @@ credentials: client-key: /tmp/.osm/client.key EOF lxc config trust add local: /tmp/.osm/client.crt - juju add-cloud -c $OSM_STACK_NAME $OSM_VCA_CLOUDNAME $LXD_CLOUD --force - juju add-credential -c $OSM_STACK_NAME $OSM_VCA_CLOUDNAME -f $LXD_CREDENTIALS + juju add-cloud -c $OSM_NAMESPACE $OSM_VCA_CLOUDNAME $LXD_CLOUD --force + juju add-credential -c $OSM_NAMESPACE $OSM_VCA_CLOUDNAME -f $LXD_CREDENTIALS sg lxd -c "lxd waitready" juju controller-config features=[k8s-operators] if [ -n "${OSM_BEHIND_PROXY}" ] ; then @@ -160,7 +160,7 @@ JUJU_AGENT_VERSION=2.9.34 JUJU_VERSION=2.9 OSM_BEHIND_PROXY="" OSM_DEVOPS= -OSM_STACK_NAME=osm +OSM_NAMESPACE=osm OSM_VCA_HOST= OSM_VCA_CLOUDNAME="localhost" OSM_VCA_K8S_CLOUDNAME="k8scloud" @@ -175,7 +175,7 @@ while getopts ":D:i:s:H:l:L:K:-: hP" o; do DEFAULT_IP="${OPTARG}" ;; s) - OSM_STACK_NAME="${OPTARG}" && [[ ! "${OPTARG}" =~ $RE_CHECK ]] && echo "Namespace $OPTARG is invalid. Regex used for validation is $RE_CHECK" && exit 0 + OSM_NAMESPACE="${OPTARG}" && [[ ! "${OPTARG}" =~ $RE_CHECK ]] && echo "Namespace $OPTARG is invalid. Regex used for validation is $RE_CHECK" && exit 0 ;; H) OSM_VCA_HOST="${OPTARG}" @@ -278,7 +278,7 @@ EOF juju add-credential -c $CONTROLLER_NAME $OSM_VCA_CLOUDNAME -f ~/.osm/lxd-credentials.yaml || juju update-credential lxd-cloud -c $CONTROLLER_NAME -f ~/.osm/lxd-credentials.yaml fi fi - [ -z "$CONTROLLER_NAME" ] && OSM_VCA_HOST=`sg lxd -c "juju show-controller $OSM_STACK_NAME"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'` + [ -z "$CONTROLLER_NAME" ] && OSM_VCA_HOST=`sg lxd -c "juju show-controller $OSM_NAMESPACE"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'` [ -n "$CONTROLLER_NAME" ] && OSM_VCA_HOST=`juju show-controller $CONTROLLER_NAME |grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'` [ -z "$OSM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address" fi diff --git a/installers/uninstall_osm.sh b/installers/uninstall_osm.sh index 3af413b2..eac9b80f 100755 --- a/installers/uninstall_osm.sh +++ b/installers/uninstall_osm.sh @@ -56,7 +56,7 @@ function uninstall_osm() { # uninstall OSM MONITORING uninstall_k8s_monitoring fi - remove_k8s_namespace $OSM_STACK_NAME + remove_k8s_namespace $OSM_NAMESPACE echo "Now osm docker images and volumes will be deleted" # TODO: clean-up of images should take into account if other tags were used for specific modules newgrp docker << EONG @@ -67,12 +67,12 @@ EONG sg docker -c "docker image rm ${DOCKER_REGISTRY_URL}${DOCKER_USER}/ng-ui:${OSM_DOCKER_TAG}" - OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_STACK_NAME}" + OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_NAMESPACE}" remove_volumes $OSM_NAMESPACE_VOL echo "Removing $OSM_DOCKER_WORK_DIR" sudo rm -rf $OSM_DOCKER_WORK_DIR - [ -z "$CONTROLLER_NAME" ] && sg lxd -c "juju kill-controller -t 0 -y $OSM_STACK_NAME" + [ -z "$CONTROLLER_NAME" ] && sg lxd -c "juju kill-controller -t 0 -y $OSM_NAMESPACE" remove_crontab_job @@ -147,7 +147,7 @@ OSM_VCA_SECRET= OSM_VCA_PUBKEY= OSM_VCA_CLOUDNAME="localhost" OSM_VCA_K8S_CLOUDNAME="k8scloud" -OSM_STACK_NAME=osm +OSM_NAMESPACE=osm NO_HOST_PORTS="" DOCKER_NOBUILD="" REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg" @@ -156,7 +156,7 @@ OSM_WORK_DIR="/etc/osm" OSM_DOCKER_WORK_DIR="/etc/osm/docker" OSM_K8S_WORK_DIR="${OSM_DOCKER_WORK_DIR}/osm_pods" OSM_HOST_VOL="/var/lib/osm" -OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_STACK_NAME}" +OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_NAMESPACE}" OSM_DOCKER_TAG=latest DOCKER_USER=opensourcemano PULL_IMAGES="y" @@ -250,7 +250,7 @@ while getopts ":a:b:r:n:k:u:R:D:o:O:m:N:H:S:s:t:U:P:A:l:L:K:d:p:T:f:F:-: hy" o; OSM_VCA_SECRET="${OPTARG}" ;; s) - OSM_STACK_NAME="${OPTARG}" && [[ ! "${OPTARG}" =~ $RE_CHECK ]] && echo "Namespace $OPTARG is invalid. Regex used for validation is $RE_CHECK" && exit 0 + OSM_NAMESPACE="${OPTARG}" && [[ ! "${OPTARG}" =~ $RE_CHECK ]] && echo "Namespace $OPTARG is invalid. Regex used for validation is $RE_CHECK" && exit 0 ;; t) OSM_DOCKER_TAG="${OPTARG}"