X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Ffull_install_osm.sh;h=79fb07724438a0a796701827c922976f8567fa78;hb=bc0d6073931b1639a905030ad356ae340c9597f8;hp=2c1925970df4d457f45cfdf25b721617397dfe1c;hpb=c973b57b1f34ecb64f248f3098ac7b79c1b8a0ae;p=osm%2Fdevops.git diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index 2c192597..79fb0772 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -34,11 +34,11 @@ function usage(){ 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" - echo -e " -C use VCA/juju CA certificate file" echo -e " -A use VCA/juju API proxy" echo -e " --pla: install the PLA module for placement support" + echo -e " --ng-sa: install Airflow and Pushgateway to get VNF and NS status (experimental)" echo -e " -m : install OSM but only rebuild or pull the specified docker images (NG-UI, NBI, LCM, RO, MON, POL, PLA, KAFKA, MONGO, PROMETHEUS, PROMETHEUS-CADVISOR, KEYSTONE-DB, NONE)" - echo -e " -o : ONLY (un)installs one of the addons (k8s_monitor)" + echo -e " -o : ONLY (un)installs one of the addons (k8s_monitor, ng-sa)" echo -e " -O : Install OSM to an OpenStack infrastructure. is required. If a is used, the clouds.yaml file should be under ~/.config/openstack/ or /etc/openstack/" echo -e " -N : Public network name required to setup OSM to OpenStack" echo -e " -f : Public SSH key to use to deploy OSM to OpenStack" @@ -67,13 +67,12 @@ function usage(){ echo -e " --pullimages: pull/run osm images from docker.io/opensourcemano" echo -e " --k8s_monitor: install the OSM kubernetes monitoring with prometheus and grafana" echo -e " --volume: create a VM volume when installing to OpenStack" -# echo -e " --reconfigure: reconfigure the modules (DO NOT change NAT rules)" -# echo -e " --update: update to the latest stable release or to the latest commit if using a specific branch" echo -e " --showopts: print chosen options and exit (only for debugging)" echo -e " --charmed: Deploy and operate OSM with Charms on k8s" echo -e " [--bundle ]: Specify with which bundle to deploy OSM with charms (--charmed option)" echo -e " [--k8s ]: Specify with which kubernetes to deploy OSM with charms (--charmed option)" echo -e " [--vca ]: Specifies the name of the controller to use - The controller must be already bootstrapped (--charmed option)" + echo -e " [--small-profile]: Do not install and configure LXD which aims to use only K8s Clouds (--charmed option)" echo -e " [--lxd ]: Takes a YAML file as a parameter with the LXD Cloud information (--charmed option)" echo -e " [--lxd-cred ]: Takes a YAML file as a parameter with the LXD Credentials information (--charmed option)" echo -e " [--microstack]: Installs microstack as a vim. (--charmed option)" @@ -139,31 +138,20 @@ function generate_secret() { [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } -function install_lxd() { - [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - # Apply sysctl production values for optimal performance - sudo cp ${OSM_DEVOPS}/installers/60-lxd-production.conf /etc/sysctl.d/60-lxd-production.conf - sudo sysctl --system - - # Install LXD snap - sudo apt-get remove --purge -y liblxc1 lxc-common lxcfs lxd lxd-client - sudo snap install lxd --channel $LXD_VERSION/stable - - # Configure LXD - sudo usermod -a -G lxd `whoami` - cat ${OSM_DEVOPS}/installers/lxd-preseed.conf | sed 's/^config: {}/config:\n core.https_address: '$DEFAULT_IP':8443/' | sg lxd -c "lxd init --preseed" - sg lxd -c "lxd waitready" - DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5; exit}') - [ -z "$DEFAULT_IF" ] && DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8; exit}') - [ -z "$DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0" - DEFAULT_MTU=$(ip addr show ${DEFAULT_IF} | perl -ne 'if (/mtu\s(\d+)/) {print $1;}') - sg lxd -c "lxc profile device set default eth0 mtu $DEFAULT_MTU" - sg lxd -c "lxc network set lxdbr0 bridge.mtu $DEFAULT_MTU" - #sudo systemctl stop lxd-bridge - #sudo systemctl --system daemon-reload - #sudo systemctl enable lxd-bridge - #sudo systemctl start lxd-bridge - [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function +function check_packages() { + NEEDED_PACKAGES="$1" + echo -e "Checking required packages: ${NEEDED_PACKAGES}" + for PACKAGE in ${NEEDED_PACKAGES} ; do + dpkg -L ${PACKAGE} + if [ $? -ne 0 ]; then + echo -e "Package ${PACKAGE} is not installed." + echo -e "Updating apt-cache ..." + sudo apt-get update + echo -e "Installing ${PACKAGE} ..." + sudo apt-get install -y ${PACKAGE} || FATAL "failed to install ${PACKAGE}" + fi + done + echo -e "Required packages are present: ${NEEDED_PACKAGES}" } function ask_user(){ @@ -200,7 +188,7 @@ function install_osmclient(){ python3 -m pip install -r /usr/lib/python3/dist-packages/osm_im/requirements.txt fi if [ -f /usr/lib/python3/dist-packages/osmclient/requirements.txt ]; then - sudo apt-get install -y libcurl4-openssl-dev libssl-dev + sudo apt-get install -y libcurl4-openssl-dev libssl-dev libmagic1 python3 -m pip install -r /usr/lib/python3/dist-packages/osmclient/requirements.txt fi [ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME=`lxc list | awk '($2=="SO-ub"){print $6}'` @@ -239,10 +227,6 @@ function generate_docker_images() { sg docker -c "docker pull wurstmeister/kafka:${KAFKA_TAG}" || FATAL "cannot get kafka docker image" fi - if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q MONGO ; then - sg docker -c "docker pull mongo" || FATAL "cannot get mongo docker image" - fi - if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q PROMETHEUS ; then sg docker -c "docker pull prom/prometheus:${PROMETHEUS_TAG}" || FATAL "cannot get prometheus docker image" fi @@ -253,6 +237,7 @@ function generate_docker_images() { if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q GRAFANA ; then sg docker -c "docker pull grafana/grafana:${GRAFANA_TAG}" || FATAL "cannot get grafana docker image" + sg docker -c "docker pull kiwigrid/k8s-sidecar:${KIWIGRID_K8S_SIDECAR_TAG}" || FATAL "cannot get kiwigrid k8s-sidecar docker image" fi if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q NBI || echo $TO_REBUILD | grep -q KEYSTONE-DB ; then @@ -326,27 +311,6 @@ function generate_k8s_manifest_files() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function #Kubernetes resources sudo cp -bR ${OSM_DEVOPS}/installers/docker/osm_pods $OSM_DOCKER_WORK_DIR - sudo rm -f $OSM_K8S_WORK_DIR/mongo.yaml - [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function -} - -function generate_prometheus_grafana_files() { - #this only works with docker swarm - [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - # Prometheus files - sudo mkdir -p $OSM_DOCKER_WORK_DIR/prometheus - sudo cp -b ${OSM_DEVOPS}/installers/docker/prometheus/prometheus.yml $OSM_DOCKER_WORK_DIR/prometheus/prometheus.yml - - # Grafana files - sudo mkdir -p $OSM_DOCKER_WORK_DIR/grafana - sudo cp -b ${OSM_DEVOPS}/installers/docker/grafana/dashboards-osm.yml $OSM_DOCKER_WORK_DIR/grafana/dashboards-osm.yml - sudo cp -b ${OSM_DEVOPS}/installers/docker/grafana/datasource-prometheus.yml $OSM_DOCKER_WORK_DIR/grafana/datasource-prometheus.yml - sudo cp -b ${OSM_DEVOPS}/installers/docker/grafana/osm-sample-dashboard.json $OSM_DOCKER_WORK_DIR/grafana/osm-sample-dashboard.json - sudo cp -b ${OSM_DEVOPS}/installers/docker/grafana/osm-system-dashboard.json $OSM_DOCKER_WORK_DIR/grafana/osm-system-dashboard.json - - # Prometheus Exporters files - sudo mkdir -p $OSM_DOCKER_WORK_DIR/prometheus_exporters - sudo cp -b ${OSM_DEVOPS}/installers/docker/prometheus_exporters/node_exporter.service $OSM_DOCKER_WORK_DIR/prometheus_exporters/node_exporter.service [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -361,6 +325,9 @@ function generate_docker_env_files() { sudo cp $OSM_DOCKER_WORK_DIR/pol.env{,~} sudo cp $OSM_DOCKER_WORK_DIR/ro-db.env{,~} sudo cp $OSM_DOCKER_WORK_DIR/ro.env{,~} + if [ -n "${INSTALL_NGSA}" ]; then + sudo cp $OSM_DOCKER_WORK_DIR/ngsa.env{,~} + fi echo "Generating docker env files" # LCM @@ -419,6 +386,23 @@ function generate_docker_env_files() { else sudo sed -i "s|OSMLCM_VCA_K8S_CLOUD.*|OSMLCM_VCA_K8S_CLOUD=${OSM_VCA_K8S_CLOUDNAME}|g" $OSM_DOCKER_WORK_DIR/lcm.env fi + if [ -n "${OSM_BEHIND_PROXY}" ]; then + if ! grep -Fq "HTTP_PROXY" $OSM_DOCKER_WORK_DIR/lcm.env; then + echo "HTTP_PROXY=${HTTP_PROXY}" | sudo tee -a $OSM_DOCKER_WORK_DIR/lcm.env + else + sudo sed -i "s|HTTP_PROXY.*|HTTP_PROXY=${HTTP_PROXY}|g" $OSM_DOCKER_WORK_DIR/lcm.env + fi + if ! grep -Fq "HTTPS_PROXY" $OSM_DOCKER_WORK_DIR/lcm.env; then + echo "HTTPS_PROXY=${HTTPS_PROXY}" | sudo tee -a $OSM_DOCKER_WORK_DIR/lcm.env + else + sudo sed -i "s|HTTPS_PROXY.*|HTTPS_PROXY=${HTTPS_PROXY}|g" $OSM_DOCKER_WORK_DIR/lcm.env + fi + if ! grep -Fq "NO_PROXY" $OSM_DOCKER_WORK_DIR/lcm.env; then + echo "NO_PROXY=${NO_PROXY}" | sudo tee -a $OSM_DOCKER_WORK_DIR/lcm.env + else + sudo sed -i "s|NO_PROXY.*|NO_PROXY=${NO_PROXY}|g" $OSM_DOCKER_WORK_DIR/lcm.env + fi + fi # RO MYSQL_ROOT_PASSWORD=$(generate_secret) @@ -458,9 +442,9 @@ function generate_docker_env_files() { fi if ! grep -Fq "OS_NOTIFIER_URI" $OSM_DOCKER_WORK_DIR/mon.env; then - echo "OS_NOTIFIER_URI=http://${DEFAULT_IP}:8662" |sudo tee -a $OSM_DOCKER_WORK_DIR/mon.env + echo "OS_NOTIFIER_URI=http://${OSM_DEFAULT_IP}:8662" |sudo tee -a $OSM_DOCKER_WORK_DIR/mon.env else - sudo sed -i "s|OS_NOTIFIER_URI.*|OS_NOTIFIER_URI=http://$DEFAULT_IP:8662|g" $OSM_DOCKER_WORK_DIR/mon.env + sudo sed -i "s|OS_NOTIFIER_URI.*|OS_NOTIFIER_URI=http://$OSM_DEFAULT_IP:8662|g" $OSM_DOCKER_WORK_DIR/mon.env fi if ! grep -Fq "OSMMON_VCA_HOST" $OSM_DOCKER_WORK_DIR/mon.env; then @@ -481,12 +465,16 @@ function generate_docker_env_files() { sudo sed -i "s|OSMMON_VCA_CACERT.*|OSMMON_VCA_CACERT=${OSM_VCA_CACERT}|g" $OSM_DOCKER_WORK_DIR/mon.env fi - # POL if [ ! -f $OSM_DOCKER_WORK_DIR/pol.env ]; then echo "OSMPOL_SQL_DATABASE_URI=mysql://root:${MYSQL_ROOT_PASSWORD}@mysql:3306/pol" | sudo tee -a $OSM_DOCKER_WORK_DIR/pol.env fi + # NG-SA + if [ -n "${INSTALL_NGSA}" ] && [ ! -f $OSM_DOCKER_WORK_DIR/ngsa.env ]; then + echo "OSMMON_DATABASE_COMMONKEY=${OSM_DATABASE_COMMONKEY}" | sudo tee -a $OSM_DOCKER_WORK_DIR/ngsa.env + fi + echo "Finished generation of docker env files" [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -502,6 +490,9 @@ function kube_secrets(){ 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 + if [ -n "${INSTALL_NGSA}" ]; then + kubectl create secret generic ngsa-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/ngsa.env + fi [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -522,13 +513,18 @@ function deploy_charmed_services() { function deploy_osm_pla_service() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - # corresponding to namespace_vol - sudo sed -i "s#path: /var/lib/osm#path: $OSM_NAMESPACE_VOL#g" $OSM_DOCKER_WORK_DIR/osm_pla/pla.yaml # corresponding to deploy_osm_services kubectl apply -n $OSM_STACK_NAME -f $OSM_DOCKER_WORK_DIR/osm_pla [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } +function install_osm_ngsa_service() { + [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function + $OSM_DEVOPS/installers/install_ngsa.sh -d ${OSM_HELM_WORK_DIR} -D ${OSM_DEVOPS} -t ${OSM_DOCKER_TAG} ${DEBUG_INSTALL} || \ + FATAL_TRACK install_osm_ngsa_service "install_ngsa.sh failed" + [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function +} + function parse_yaml() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function TAG=$1 @@ -537,19 +533,23 @@ function parse_yaml() { for module in $services; do if [ "$module" == "pla" ]; then if [ -n "$INSTALL_PLA" ]; then - echo "Updating K8s manifest file from opensourcemano\/${module}:.* to ${DOCKER_REGISTRY_URL}${DOCKER_USER}\/${module}:${TAG}" + echo "Updating K8s manifest file from opensourcemano\/pla:.* to ${DOCKER_REGISTRY_URL}${DOCKER_USER}\/pla:${TAG}" sudo sed -i "s#opensourcemano/pla:.*#${DOCKER_REGISTRY_URL}${DOCKER_USER}/pla:${TAG}#g" ${OSM_DOCKER_WORK_DIR}/osm_pla/pla.yaml fi else - echo "Updating K8s manifest file from opensourcemano\/${module}:.* to ${DOCKER_REGISTRY_URL}${DOCKER_USER}\/${module}:${TAG}" - sudo sed -i "s#opensourcemano/${module}:.*#${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module}:${TAG}#g" ${OSM_K8S_WORK_DIR}/${module}.yaml + image=${module} + if [ "$module" == "ng-prometheus" ]; then + image="prometheus" + fi + echo "Updating K8s manifest file from opensourcemano\/${image}:.* to ${DOCKER_REGISTRY_URL}${DOCKER_USER}\/${image}:${TAG}" + sudo sed -i "s#opensourcemano/${image}:.*#${DOCKER_REGISTRY_URL}${DOCKER_USER}/${image}:${TAG}#g" ${OSM_K8S_WORK_DIR}/${module}.yaml fi done [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } function update_manifest_files() { - osm_services="nbi lcm ro pol mon ng-ui keystone pla prometheus" + osm_services="nbi lcm ro pol mon ng-ui keystone pla prometheus ng-prometheus" list_of_services="" for module in $osm_services; do module_upper="${module^^}" @@ -557,20 +557,29 @@ function update_manifest_files() { list_of_services="$list_of_services $module" fi done - if [ ! "$OSM_DOCKER_TAG" == "11" ]; then + if [ ! "$OSM_DOCKER_TAG" == "13" ]; then parse_yaml $OSM_DOCKER_TAG $list_of_services fi if [ -n "$MODULE_DOCKER_TAG" ]; then parse_yaml $MODULE_DOCKER_TAG $list_of_services_to_rebuild fi + # The manifest for prometheus is prometheus.yaml or ng-prometheus.yaml, depending on the installation option + if [ -n "$INSTALL_NGSA" ]; then + sudo rm -f ${OSM_K8S_WORK_DIR}/prometheus.yaml + else + sudo rm -f ${OSM_K8S_WORK_DIR}/ng-prometheus.yaml + fi [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } function namespace_vol() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - osm_services="nbi lcm ro pol mon kafka mysql prometheus" + # List of services with a volume mounted in path /var/lib/osm + osm_services="mysql" for osm in $osm_services; do - sudo sed -i "s#path: /var/lib/osm#path: $OSM_NAMESPACE_VOL#g" $OSM_K8S_WORK_DIR/$osm.yaml + if [ -f "$OSM_K8S_WORK_DIR/$osm.yaml" ] ; then + sudo sed -i "s#path: /var/lib/osm#path: $OSM_NAMESPACE_VOL#g" $OSM_K8S_WORK_DIR/$osm.yaml + fi done [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -607,15 +616,12 @@ EOF" sudo sed -i "s|Proxy.*|Proxy \"${OSM_APT_PROXY}\"; }|" ${OSM_APT_PROXY_FILE} fi sudo apt-get update || FATAL "Configured apt proxy, but couldn't run 'apt-get update'. Check ${OSM_APT_PROXY_FILE}" - track apt_proxy_configured + track prereq apt_proxy_configured_ok [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } -function install_osm() { +function ask_proceed() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - track checkingroot - [ "$USER" == "root" ] && FATAL "You are running the installer as root. The installer is prepared to be executed as a normal user with sudo privileges." - track noroot [ -z "$ASSUME_YES" ] && ! ask_user "The installation will do the following 1. Install and configure LXD @@ -625,61 +631,144 @@ function install_osm() { 5. Install and initialize Kubernetes as pre-requirements. Do you want to proceed (Y/n)? " y && echo "Cancelled!" && exit 1 - track proceed + + [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function +} + +function check_osm_behind_proxy() { + [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function + + export OSM_BEHIND_PROXY="" + export OSM_PROXY_ENV_VARIABLES="" + [ -n "${http_proxy}" ] && OSM_BEHIND_PROXY="y" && echo "http_proxy=${http_proxy}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} http_proxy" + [ -n "${https_proxy}" ] && OSM_BEHIND_PROXY="y" && echo "https_proxy=${https_proxy}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} https_proxy" + [ -n "${HTTP_PROXY}" ] && OSM_BEHIND_PROXY="y" && echo "HTTP_PROXY=${HTTP_PROXY}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} HTTP_PROXY" + [ -n "${HTTPS_PROXY}" ] && OSM_BEHIND_PROXY="y" && echo "https_proxy=${HTTPS_PROXY}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} HTTPS_PROXY" + [ -n "${no_proxy}" ] && echo "no_proxy=${no_proxy}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} no_proxy" + [ -n "${NO_PROXY}" ] && echo "NO_PROXY=${NO_PROXY}" && OSM_PROXY_ENV_VARIABLES="${OSM_PROXY_ENV_VARIABLES} NO_PROXY" + + echo "OSM_BEHIND_PROXY=${OSM_BEHIND_PROXY}" + echo "OSM_PROXY_ENV_VARIABLES=${OSM_PROXY_ENV_VARIABLES}" + + if [ -n "${OSM_BEHIND_PROXY}" ]; then + [ -z "$ASSUME_YES" ] && ! ask_user " +The following env variables have been found for the current user: +${OSM_PROXY_ENV_VARIABLES}. + +This suggests that this machine is behind a proxy and a special configuration is required. +The installer will install Docker CE, LXD and Juju to work behind a proxy using those +env variables. + +Take into account that the installer uses apt, curl, wget, docker, lxd, juju and snap. +Depending on the program, the env variables to work behind a proxy might be different +(e.g. http_proxy vs HTTP_PROXY). + +For that reason, it is strongly recommended that at least http_proxy, https_proxy, HTTP_PROXY +and HTTPS_PROXY are defined. + +Finally, some of the programs (apt, snap) those programs are run as sudoer, requiring that +those env variables are also set for root user. If you are not sure whether those variables +are configured for the root user, you can stop the installation now. + +Do you want to proceed with the installation (Y/n)? " y && echo "Cancelled!" && exit 1 + else + echo "This machine is not behind a proxy" + fi + + [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function +} + +function find_devops_folder() { + if [ -z "$OSM_DEVOPS" ]; then + if [ -n "$TEST_INSTALLER" ]; then + echo -e "\nUsing local devops repo for OSM installation" + OSM_DEVOPS="$(dirname $(realpath $(dirname $0)))" + else + echo -e "\nCreating temporary dir for OSM installation" + OSM_DEVOPS="$(mktemp -d -q --tmpdir "installosm.XXXXXX")" + trap 'rm -rf "$OSM_DEVOPS"' EXIT + git clone https://osm.etsi.org/gerrit/osm/devops.git $OSM_DEVOPS + fi + fi +} + +function install_osm() { + [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function + + trap ctrl_c INT + + # TODO: move this under start + [ -n "$DOCKER_REGISTRY_URL" ] && parse_docker_registry_url + + check_osm_behind_proxy + track checks proxy_ok + + check_packages "git wget curl tar snapd" + + sudo snap install jq || FATAL "Could not install jq (snap package). Make sure that snap works" + + 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 + [ "$USER" == "root" ] && FATAL "You are running the installer as root. The installer is prepared to be executed as a normal user with sudo privileges." + track checks noroot_ok + + ask_proceed + track checks proceed_ok echo "Installing OSM" echo "Determining IP address of the interface with the default route" - DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5; exit}') - [ -z "$DEFAULT_IF" ] && DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8; exit}') - [ -z "$DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0" - DEFAULT_IP=`ip -o -4 a s ${DEFAULT_IF} |awk '{split($4,a,"/"); print a[1]}'` - [ -z "$DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route" + [ -z "$OSM_DEFAULT_IF" ] && OSM_DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5; exit}') + [ -z "$OSM_DEFAULT_IF" ] && OSM_DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8; exit}') + [ -z "$OSM_DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0" + OSM_DEFAULT_IP=`ip -o -4 a s ${OSM_DEFAULT_IF} |awk '{split($4,a,"/"); print a[1]; exit}'` + [ -z "$OSM_DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route" # configure apt proxy [ -n "$APT_PROXY_URL" ] && configure_apt_proxy $APT_PROXY_URL # if no host is passed in, we need to install lxd/juju, unless explicilty asked not to if [ -z "$OSM_VCA_HOST" ] && [ -z "$INSTALL_NOLXD" ] && [ -z "$LXD_CLOUD_FILE" ]; then - need_packages_lw="snapd" - echo -e "Checking required packages: $need_packages_lw" - dpkg -l $need_packages_lw &>/dev/null \ - || ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \ - || sudo apt-get update \ - || FATAL "failed to run apt-get update" - dpkg -l $need_packages_lw &>/dev/null \ - || ! echo -e "Installing $need_packages_lw requires root privileges." \ - || sudo apt-get install -y $need_packages_lw \ - || FATAL "failed to install $need_packages_lw" - install_lxd + LXD_INSTALL_OPTS="-D ${OSM_DEVOPS} -i ${OSM_DEFAULT_IF} ${DEBUG_INSTALL}" + [ -n "${OSM_BEHIND_PROXY}" ] && LXD_INSTALL_OPTS="${LXD_INSTALL_OPTS} -P" + $OSM_DEVOPS/installers/install_lxd.sh ${LXD_INSTALL_OPTS} || FATAL_TRACK lxd "install_lxd.sh failed" fi - track prereqok + track prereq prereqok_ok if [ ! -n "$INSTALL_NODOCKER" ]; then DOCKER_CE_OPTS="-D ${OSM_DEVOPS} ${DEBUG_INSTALL}" [ -n "${DOCKER_PROXY_URL}" ] && DOCKER_CE_OPTS="${DOCKER_CE_OPTS} -p ${DOCKER_PROXY_URL}" - $OSM_DEVOPS/installers/install_docker_ce.sh ${DOCKER_CE_OPTS} + [ -n "${OSM_BEHIND_PROXY}" ] && DOCKER_CE_OPTS="${DOCKER_CE_OPTS} -P" + $OSM_DEVOPS/installers/install_docker_ce.sh ${DOCKER_CE_OPTS} || FATAL_TRACK docker_ce "install_docker_ce.sh failed" fi - track docker_ce + track docker_ce docker_ce_ok echo "Creating folders for installation" [ ! -d "$OSM_DOCKER_WORK_DIR" ] && sudo mkdir -p $OSM_DOCKER_WORK_DIR [ ! -d "$OSM_DOCKER_WORK_DIR/osm_pla" -a -n "$INSTALL_PLA" ] && sudo mkdir -p $OSM_DOCKER_WORK_DIR/osm_pla sudo cp -b $OSM_DEVOPS/installers/docker/cluster-config.yaml $OSM_DOCKER_WORK_DIR/cluster-config.yaml - $OSM_DEVOPS/installers/install_kubeadm_cluster.sh -i ${DEFAULT_IP} -d ${OSM_DOCKER_WORK_DIR} -D ${OSM_DEVOPS} ${DEBUG_INSTALL} - track k8scluster + $OSM_DEVOPS/installers/install_kubeadm_cluster.sh -i ${OSM_DEFAULT_IP} -d ${OSM_DOCKER_WORK_DIR} -D ${OSM_DEVOPS} ${DEBUG_INSTALL} || \ + FATAL_TRACK k8scluster "install_kubeadm_cluster.sh failed" + track k8scluster k8scluster_ok - JUJU_OPTS="-D ${OSM_DEVOPS} -s ${OSM_STACK_NAME} -i ${DEFAULT_IP} ${DEBUG_INSTALL} ${INSTALL_NOJUJU} ${INSTALL_CACHELXDIMAGES}" + JUJU_OPTS="-D ${OSM_DEVOPS} -s ${OSM_STACK_NAME} -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}" [ -n "${CONTROLLER_NAME}" ] && JUJU_OPTS="$JUJU_OPTS -K ${CONTROLLER_NAME}" - $OSM_DEVOPS/installers/install_juju.sh ${JUJU_OPTS} + [ -n "${OSM_BEHIND_PROXY}" ] && JUJU_OPTS="${JUJU_OPTS} -P" + $OSM_DEVOPS/installers/install_juju.sh ${JUJU_OPTS} || FATAL_TRACK juju "install_juju.sh failed" set_vca_variables - track juju + track juju juju_ok if [ -z "$OSM_DATABASE_COMMONKEY" ]; then OSM_DATABASE_COMMONKEY=$(generate_secret) @@ -688,44 +777,53 @@ function install_osm() { # Deploy OSM services [ -z "$DOCKER_NOBUILD" ] && generate_docker_images - track docker_build + track docker_images docker_images_ok generate_k8s_manifest_files - track manifest_files + track osm_files manifest_files_ok generate_docker_env_files - track env_files + track osm_files env_files_ok deploy_charmed_services + track deploy_osm deploy_charmed_services_ok kube_secrets + track deploy_osm kube_secrets_ok update_manifest_files + track deploy_osm update_manifest_files_ok namespace_vol + track deploy_osm namespace_vol_ok deploy_osm_services - if [ -n "$INSTALL_PLA"]; then + track deploy_osm deploy_osm_services_k8s_ok + if [ -n "$INSTALL_PLA" ]; then # optional PLA install deploy_osm_pla_service - track deploy_osm_pla + track deploy_osm deploy_osm_pla_ok fi - track deploy_osm_services_k8s if [ -n "$INSTALL_K8S_MONITOR" ]; then # install OSM MONITORING install_k8s_monitoring - track install_k8s_monitoring + track deploy_osm install_k8s_monitoring_ok + fi + if [ -n "$INSTALL_NGSA" ]; then + # optional PLA install + install_osm_ngsa_service + track deploy_osm install_osm_ngsa_ok fi [ -z "$INSTALL_NOHOSTCLIENT" ] && install_osmclient - track osmclient + track osmclient osmclient_ok echo -e "Checking OSM health state..." $OSM_DEVOPS/installers/osm_health.sh -s ${OSM_STACK_NAME} -k || \ - echo -e "OSM is not healthy, but will probably converge to a healthy state soon." && \ + (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" && \ - track osm_unhealthy - track after_healthcheck + track healthchecks osm_unhealthy didnotconverge) + track healthchecks after_healthcheck_ok add_local_k8scluster - track add_local_k8scluster + track final_ops add_local_k8scluster_ok - wget -q -O- https://osm-download.etsi.org/ftp/osm-11.0-eleven/README2.txt &> /dev/null + wget -q -O- https://osm-download.etsi.org/ftp/osm-13.0-thirteen/README2.txt &> /dev/null track end sudo find /etc/osm [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function @@ -790,7 +888,7 @@ function install_k8s_monitoring() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function # install OSM monitoring sudo chmod +x $OSM_DEVOPS/installers/k8s/*.sh - sudo $OSM_DEVOPS/installers/k8s/install_osm_k8s_monitoring.sh + sudo $OSM_DEVOPS/installers/k8s/install_osm_k8s_monitoring.sh || FATAL_TRACK install_k8s_monitoring "k8s/install_osm_k8s_monitoring.sh failed" [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -808,6 +906,7 @@ function dump_vars(){ echo "INSTALL_K8S_MONITOR=$INSTALL_K8S_MONITOR" echo "INSTALL_LIGHTWEIGHT=$INSTALL_LIGHTWEIGHT" echo "INSTALL_LXD=$INSTALL_LXD" + echo "INSTALL_NGSA=$INSTALL_NGSA" echo "INSTALL_NODOCKER=$INSTALL_NODOCKER" echo "INSTALL_NOJUJU=$INSTALL_NOJUJU" echo "INSTALL_NOLXD=$INSTALL_NOLXD" @@ -824,6 +923,9 @@ function dump_vars(){ echo "OPENSTACK_VM_NAME"="$OPENSTACK_VM_NAME" echo "OSM_DEVOPS=$OSM_DEVOPS" echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG" + 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_VCA_HOST=$OSM_VCA_HOST" echo "OSM_VCA_PUBKEY=$OSM_VCA_PUBKEY" @@ -852,9 +954,13 @@ function parse_docker_registry_url() { [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } -LXD_VERSION=4.0 -JUJU_VERSION=2.9 -JUJU_AGENT_VERSION=2.9.17 +function ctrl_c() { + [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function + echo "** Trapped CTRL-C" + FATAL "User stopped the installation" + [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function +} + UNINSTALL="" DEVELOP="" UPDATE="" @@ -869,8 +975,10 @@ INSTALL_FROM_SOURCE="" DEBUG_INSTALL="" RELEASE="ReleaseTEN" REPOSITORY="stable" -INSTALL_VIMEMU="" +INSTALL_K8S_MONITOR="" +INSTALL_NGSA="" INSTALL_PLA="" +INSTALL_VIMEMU="" LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd" LXD_REPOSITORY_PATH="" INSTALL_LIGHTWEIGHT="y" @@ -887,7 +995,6 @@ TO_REBUILD="" INSTALL_NOLXD="" INSTALL_NODOCKER="" INSTALL_NOJUJU="" -INSTALL_K8S_MONITOR="" INSTALL_NOHOSTCLIENT="" INSTALL_CACHELXDIMAGES="" OSM_DEVOPS= @@ -902,16 +1009,18 @@ DOCKER_NOBUILD="" REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg" REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/debian" OSM_WORK_DIR="/etc/osm" -OSM_DOCKER_WORK_DIR="/etc/osm/docker" +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_DOCKER_TAG=latest DOCKER_USER=opensourcemano PULL_IMAGES="y" KAFKA_TAG=2.11-1.0.2 -PROMETHEUS_TAG=v2.4.3 -GRAFANA_TAG=latest +KIWIGRID_K8S_SIDECAR_TAG="1.15.6" +PROMETHEUS_TAG=v2.28.1 +GRAFANA_TAG=8.1.1 PROMETHEUS_NODE_EXPORTER_TAG=0.18.1 PROMETHEUS_CADVISOR_TAG=latest KEYSTONEDB_TAG=10 @@ -924,6 +1033,7 @@ RE_CHECK='^[a-z0-9]([-a-z0-9]*[a-z0-9])?$' DOCKER_REGISTRY_URL= DOCKER_PROXY_URL= MODULE_DOCKER_TAG= +OSM_INSTALLATION_TYPE="Default" 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; do case "${o}" in @@ -956,6 +1066,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; o) INSTALL_ONLY="y" [ "${OPTARG}" == "k8s_monitor" ] && INSTALL_K8S_MONITOR="y" && continue + [ "${OPTARG}" == "ng-sa" ] && INSTALL_NGSA="y" && continue ;; O) INSTALL_TO_OPENSTACK="y" @@ -1051,7 +1162,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; [ "${OPTARG}" == "nohostclient" ] && INSTALL_NOHOSTCLIENT="y" && continue [ "${OPTARG}" == "pullimages" ] && continue [ "${OPTARG}" == "k8s_monitor" ] && INSTALL_K8S_MONITOR="y" && continue - [ "${OPTARG}" == "charmed" ] && CHARMED="y" && continue + [ "${OPTARG}" == "charmed" ] && CHARMED="y" && OSM_INSTALLATION_TYPE="Charmed" && continue [ "${OPTARG}" == "bundle" ] && continue [ "${OPTARG}" == "k8s" ] && continue [ "${OPTARG}" == "lxd" ] && continue @@ -1059,11 +1170,13 @@ 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; [ "${OPTARG}" == "microstack" ] && continue [ "${OPTARG}" == "overlay" ] && continue [ "${OPTARG}" == "only-vca" ] && continue + [ "${OPTARG}" == "small-profile" ] && continue [ "${OPTARG}" == "vca" ] && continue [ "${OPTARG}" == "ha" ] && continue [ "${OPTARG}" == "tag" ] && continue [ "${OPTARG}" == "registry" ] && continue [ "${OPTARG}" == "pla" ] && INSTALL_PLA="y" && continue + [ "${OPTARG}" == "ng-sa" ] && INSTALL_NGSA="y" && continue [ "${OPTARG}" == "volume" ] && OPENSTACK_ATTACH_VOLUME="true" && continue [ "${OPTARG}" == "nocachelxdimages" ] && continue [ "${OPTARG}" == "cachelxdimages" ] && INSTALL_CACHELXDIMAGES="--cachelxdimages" && continue @@ -1098,9 +1211,11 @@ source $OSM_DEVOPS/common/all_funcs # Uninstall if "--uninstall" if [ -n "$UNINSTALL" ]; then if [ -n "$CHARMED" ]; then - ${OSM_DEVOPS}/installers/charmed_uninstall.sh -R $RELEASE -r $REPOSITORY -u $REPOSITORY_BASE -D $OSM_DEVOPS -t $DOCKER_TAG "$@" + ${OSM_DEVOPS}/installers/charmed_uninstall.sh -R $RELEASE -r $REPOSITORY -u $REPOSITORY_BASE -D $OSM_DEVOPS -t $DOCKER_TAG "$@" || \ + FATAL_TRACK charmed_uninstall "charmed_uninstall.sh failed" else - ${OSM_DEVOPS}/installers/uninstall_osm.sh "$@" + ${OSM_DEVOPS}/installers/uninstall_osm.sh "$@" || \ + FATAL_TRACK community_uninstall "uninstall_osm.sh failed" fi echo -e "\nDONE" exit 0 @@ -1108,7 +1223,13 @@ fi # Charmed installation if [ -n "$CHARMED" ]; then - ${OSM_DEVOPS}/installers/charmed_install.sh -R $RELEASE -r $REPOSITORY -u $REPOSITORY_BASE -D $OSM_DEVOPS -t $DOCKER_TAG "$@" + sudo snap install jq || FATAL "Could not install jq (snap package). Make sure that snap works" + export OSM_TRACK_INSTALLATION_ID="$(date +%s)-$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16)" + track start release $RELEASE none none docker_tag $OSM_DOCKER_TAG none none installation_type $OSM_INSTALLATION_TYPE none none + ${OSM_DEVOPS}/installers/charmed_install.sh --tag $OSM_DOCKER_TAG "$@" || \ + FATAL_TRACK charmed_install "charmed_install.sh failed" + wget -q -O- https://osm-download.etsi.org/ftp/osm-13.0-thirteen/README2.txt &> /dev/null + track end installation_type $OSM_INSTALLATION_TYPE echo -e "\nDONE" exit 0 fi @@ -1121,73 +1242,19 @@ if [ -n "$INSTALL_TO_OPENSTACK" ]; then fi # Community_installer -[ -n "$DOCKER_REGISTRY_URL" ] && parse_docker_registry_url + [ -n "$TO_REBUILD" ] && [ "$TO_REBUILD" != " NONE" ] && echo $TO_REBUILD | grep -q NONE && FATAL "Incompatible option: -m NONE cannot be used with other -m options" [ -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" - -need_packages="git wget curl tar" - -echo -e "Checking required packages: $need_packages" -dpkg -l $need_packages &>/dev/null \ - || ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \ - || sudo apt-get update \ - || FATAL "failed to run apt-get update" -dpkg -l $need_packages &>/dev/null \ - || ! echo -e "Installing $need_packages requires root privileges." \ - || sudo apt-get install -y $need_packages \ - || FATAL "failed to install $need_packages" -sudo snap install jq -if [ -z "$OSM_DEVOPS" ]; then - if [ -n "$TEST_INSTALLER" ]; then - echo -e "\nUsing local devops repo for OSM installation" - OSM_DEVOPS="$(dirname $(realpath $(dirname $0)))" - else - echo -e "\nCreating temporary dir for OSM installation" - OSM_DEVOPS="$(mktemp -d -q --tmpdir "installosm.XXXXXX")" - trap 'rm -rf "$OSM_DEVOPS"' EXIT - - git clone https://osm.etsi.org/gerrit/osm/devops.git $OSM_DEVOPS - - if [ -z "$COMMIT_ID" ]; then - echo -e "\nGuessing the current stable release" - LATEST_STABLE_DEVOPS=`git -C $OSM_DEVOPS tag -l v[0-9].* | sort -V | tail -n1` - [ -z "$LATEST_STABLE_DEVOPS" ] && echo "Could not find the current latest stable release" && exit 0 - - echo "Latest tag in devops repo: $LATEST_STABLE_DEVOPS" - COMMIT_ID="tags/$LATEST_STABLE_DEVOPS" - else - echo -e "\nDEVOPS Using commit $COMMIT_ID" - fi - git -C $OSM_DEVOPS checkout $COMMIT_ID - fi -fi - -[ "${OSM_STACK_NAME}" == "osm" ] || OSM_DOCKER_WORK_DIR="$OSM_WORK_DIR/stack/$OSM_STACK_NAME" OSM_K8S_WORK_DIR="$OSM_DOCKER_WORK_DIR/osm_pods" && OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_STACK_NAME}" [ -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 #Installation starts here -wget -q -O- https://osm-download.etsi.org/ftp/osm-11.0-eleven/README.txt &> /dev/null -OSM_TRACK_INSTALLATION_ID="$(date +%s)-$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16)" - -track start release $RELEASE none none docker_tag $OSM_DOCKER_TAG none none - +wget -q -O- https://osm-download.etsi.org/ftp/osm-13.0-thirteen/README.txt &> /dev/null +export OSM_TRACK_INSTALLATION_ID="$(date +%s)-$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16)" install_osm -echo -e "\nDONE" && exit 0 -echo -e "\nInstalling OSM from refspec: $COMMIT_ID" -if [ -n "$INSTALL_FROM_SOURCE" ] && [ -z "$ASSUME_YES" ]; then - ! ask_user "The installation will take about 75-90 minutes. Continue (Y/n)? " y && echo "Cancelled!" && exit 1 -fi - -echo -e "Checking required packages: lxd" -lxd --version &>/dev/null || FATAL "lxd not present, exiting." -[ -n "$INSTALL_LXD" ] && echo -e "\nInstalling and configuring lxd" && install_lxd - -wget -q -O- https://osm-download.etsi.org/ftp/osm-11.0-eleven/README2.txt &> /dev/null -track end echo -e "\nDONE" - +exit 0