Feature 10593 Air-gapped installation. OSM behind proxy 93/12693/14
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 15 Nov 2022 13:11:56 +0000 (14:11 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 22 Nov 2022 08:32:16 +0000 (09:32 +0100)
Change-Id: Iac74e39fb00a396de1a6a971c35962a6688dad06
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
installers/full_install_osm.sh
installers/install_docker_ce.sh
installers/install_juju.sh
installers/install_kubeadm_cluster.sh
installers/install_lxd.sh

index 50b2c03..d74cf00 100755 (executable)
@@ -38,7 +38,7 @@ function usage(){
     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 <MODULE>:    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 <ADDON>:     ONLY (un)installs one of the addons (k8s_monitor)"
+    echo -e "     -o <ADDON>:     ONLY (un)installs one of the addons (k8s_monitor, ng-sa)"
     echo -e "     -O <openrc file path/cloud name>: Install OSM to an OpenStack infrastructure. <openrc file/cloud name> is required. If a <cloud name> is used, the clouds.yaml file should be under ~/.config/openstack/ or /etc/openstack/"
     echo -e "     -N <openstack public network name/ID>: Public network name required to setup OSM to OpenStack"
     echo -e "     -f <path to SSH public key>: Public SSH key to use to deploy OSM to OpenStack"
@@ -386,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)
@@ -603,16 +620,9 @@ EOF"
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
-function install_osm() {
+function ask_proceed() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
 
-    trap ctrl_c INT
-    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
-
     [ -z "$ASSUME_YES" ] && ! ask_user "The installation will do the following
     1. Install and configure LXD
     2. Install juju
@@ -621,6 +631,94 @@ function install_osm() {
     5. Install and initialize Kubernetes
     as pre-requirements.
     Do you want to proceed (Y/n)? " y && echo "Cancelled!" && exit 1
+
+    [ -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"
@@ -638,6 +736,7 @@ function install_osm() {
     # 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
         LXD_INSTALL_OPTS="-D ${OSM_DEVOPS} -i ${DEFAULT_IP} ${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
 
@@ -646,6 +745,7 @@ function install_osm() {
     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}"
+        [ -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
 
@@ -665,6 +765,7 @@ function install_osm() {
     [ -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}"
+    [ -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 juju_ok
@@ -874,9 +975,10 @@ INSTALL_FROM_SOURCE=""
 DEBUG_INSTALL=""
 RELEASE="ReleaseTEN"
 REPOSITORY="stable"
-INSTALL_VIMEMU=""
-INSTALL_PLA=""
+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"
@@ -893,7 +995,6 @@ TO_REBUILD=""
 INSTALL_NOLXD=""
 INSTALL_NODOCKER=""
 INSTALL_NOJUJU=""
-INSTALL_K8S_MONITOR=""
 INSTALL_NOHOSTCLIENT=""
 INSTALL_CACHELXDIMAGES=""
 OSM_DEVOPS=
@@ -965,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"
@@ -1139,44 +1241,14 @@ 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"
-
-check_packages "git wget curl tar snapd"
-
-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
index 9d6387f..90035df 100755 (executable)
@@ -64,6 +64,25 @@ function install_docker_ce() {
 }
 EOF"
         fi
+    fi
+    if [ -n "${OSM_BEHIND_PROXY}" ] ; then
+        if ! [ -f /etc/systemd/system/docker.service.d/http-proxy.conf ] ; then
+            sudo mkdir -p /etc/systemd/system/docker.service.d
+            cat << EOF | sudo tee -a /etc/systemd/system/docker.service.d/http-proxy.conf
+[Service]
+EOF
+        fi
+        [ -n "${HTTP_PROXY}" ] && sudo bash -c "cat <<EOF >> /etc/systemd/system/docker.service.d/http-proxy.conf
+Environment=\"HTTP_PROXY=${HTTP_PROXY}\"
+EOF"
+        [ -n "${HTTPS_PROXY}" ] && sudo bash -c "cat <<EOF >> /etc/systemd/system/docker.service.d/http-proxy.conf
+Environment=\"HTTPS_PROXY=${HTTPS_PROXY}\"
+EOF"
+        [ -n "${NO_PROXY}" ] && sudo bash -c "cat <<EOF >> /etc/systemd/system/docker.service.d/http-proxy.conf
+Environment=\"NO_PROXY=${NO_PROXY}\"
+EOF"
+    fi
+    if [ -n "${DOCKER_PROXY_URL}" ] || [ -n "${OSM_BEHIND_PROXY}" ] ; then
         #sudo systemctl enable docker
         sudo systemctl daemon-reload
         #sudo systemctl restart docker
@@ -77,7 +96,10 @@ EOF"
     return 0
 }
 
-while getopts ":D:p:-: " o; do
+OSM_BEHIND_PROXY=""
+DOCKER_PROXY_URL=""
+
+while getopts ":D:p:-: P" o; do
     case "${o}" in
         D)
             OSM_DEVOPS="${OPTARG}"
@@ -85,6 +107,9 @@ while getopts ":D:p:-: " o; do
         p)
             DOCKER_PROXY_URL="${OPTARG}"
             ;;
+        P)
+            OSM_BEHIND_PROXY="y"
+            ;;
         -)
             [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue
             echo -e "Invalid option: '--$OPTARG'\n" >&2
@@ -108,6 +133,7 @@ source $OSM_DEVOPS/common/logging
 
 echo "DEBUG_INSTALL=$DEBUG_INSTALL"
 echo "DOCKER_PROXY_URL=$DOCKER_PROXY_URL"
+echo "OSM_BEHIND_PROXY=$OSM_BEHIND_PROXY"
 echo "USER=$USER"
 
 install_docker_ce
index c9f0efe..dd9eb3b 100755 (executable)
@@ -55,9 +55,28 @@ function juju_createcontroller_k8s(){
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
     cat $HOME/.kube/config | juju add-k8s $OSM_VCA_K8S_CLOUDNAME --client \
     || FATAL "Failed to add K8s endpoint and credential for client in cloud $OSM_VCA_K8S_CLOUDNAME"
+
+    JUJU_BOOTSTRAP_OPTS=""
+    if [ -n "${OSM_BEHIND_PROXY}" ] ; then
+        K8S_SVC_CLUSTER_IP=$(kubectl get svc/kubernetes -o jsonpath='{.spec.clusterIP}')
+        NO_PROXY="${NO_PROXY},${K8S_SVC_CLUSTER_IP},.svc,.cluster.local"
+        mkdir -p /tmp/.osm
+        JUJU_MODEL_CONFIG_FILE=/tmp/.osm/model-config.yaml
+        cat << EOF > $JUJU_MODEL_CONFIG_FILE
+apt-http-proxy: ${HTTP_PROXY}
+apt-https-proxy: ${HTTPS_PROXY}
+juju-http-proxy: ${HTTP_PROXY}
+juju-https-proxy: ${HTTPS_PROXY}
+juju-no-proxy: ${NO_PROXY}
+snap-http-proxy: ${HTTP_PROXY}
+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  \
             --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"
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
@@ -94,6 +113,19 @@ EOF
     juju add-credential -c $OSM_STACK_NAME $OSM_VCA_CLOUDNAME -f $LXD_CREDENTIALS
     sg lxd -c "lxd waitready"
     juju controller-config features=[k8s-operators]
+    if [ -n "${OSM_BEHIND_PROXY}" ] ; then
+        if [ -n "${HTTP_PROXY}" ]; then
+            juju model-default lxd-cloud apt-http-proxy="$HTTP_PROXY"
+            juju model-default lxd-cloud juju-http-proxy="$HTTP_PROXY"
+            juju model-default lxd-cloud snap-http-proxy="$HTTP_PROXY"
+        fi
+        if [ -n "${HTTPS_PROXY}" ]; then
+            juju model-default lxd-cloud apt-https-proxy="$HTTPS_PROXY"
+            juju model-default lxd-cloud juju-https-proxy="$HTTPS_PROXY"
+            juju model-default lxd-cloud snap-https-proxy="$HTTPS_PROXY"
+        fi
+        [ -n "${NO_PROXY}" ] && juju model-default lxd-cloud juju-no-proxy="$NO_PROXY"
+    fi
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
@@ -126,6 +158,7 @@ INSTALL_CACHELXDIMAGES=""
 INSTALL_NOJUJU=""
 JUJU_AGENT_VERSION=2.9.34
 JUJU_VERSION=2.9
+OSM_BEHIND_PROXY=""
 OSM_DEVOPS=
 OSM_STACK_NAME=osm
 OSM_VCA_HOST=
@@ -133,7 +166,7 @@ OSM_VCA_CLOUDNAME="localhost"
 OSM_VCA_K8S_CLOUDNAME="k8scloud"
 RE_CHECK='^[a-z0-9]([-a-z0-9]*[a-z0-9])?$'
 
-while getopts ":D:i:s:H:l:L:K:-: h" o; do
+while getopts ":D:i:s:H:l:L:K:-: hP" o; do
     case "${o}" in
         D)
             OSM_DEVOPS="${OPTARG}"
@@ -156,6 +189,9 @@ while getopts ":D:i:s:H:l:L:K:-: h" o; do
         K)
             CONTROLLER_NAME="${OPTARG}"
             ;;
+        P)
+            OSM_BEHIND_PROXY="y"
+            ;;
         -)
             [ "${OPTARG}" == "help" ] && usage && exit 0
             [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="--debug" && continue
@@ -186,6 +222,7 @@ source $OSM_DEVOPS/common/track
 
 echo "DEBUG_INSTALL=$DEBUG_INSTALL"
 echo "DEFAULT_IP=$DEFAULT_IP"
+echo "OSM_BEHIND_PROXY=$OSM_BEHIND_PROXY"
 echo "OSM_DEVOPS=$OSM_DEVOPS"
 echo "HOME=$HOME"
 
index 6f3aa87..9c0fa2f 100755 (executable)
@@ -31,7 +31,7 @@ function install_kube() {
     echo "Installing Kubernetes Packages ..."
     sudo apt-get install -y kubelet=${K8S_VERSION} kubeadm=${K8S_VERSION} kubectl=${K8S_VERSION}
     cat << EOF | sudo tee -a /etc/default/kubelet
-    KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs"
+KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs"
 EOF
     sudo apt-mark hold kubelet kubeadm kubectl
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
index a499eae..ed50135 100755 (executable)
@@ -63,15 +63,24 @@ function install_lxd() {
     # sudo systemctl --system daemon-reload
     # sudo systemctl enable lxd-bridge
     # sudo systemctl start lxd-bridge
+
+    # Configure LXD to work behind a proxy
+    if [ -n "${OSM_BEHIND_PROXY}" ] ; then
+        [ -n "${HTTP_PROXY}" ] && sg lxd -c "lxc config set core.proxy_http $HTTP_PROXY"
+        [ -n "${HTTPS_PROXY}" ] && sg lxd -c "lxc config set core.proxy_https $HTTPS_PROXY"
+        [ -n "${NO_PROXY}" ] && sg lxd -c "lxc config set core.proxy_ignore_hosts $NO_PROXY"
+    fi
+
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
 DEBUG_INSTALL=""
 LXD_VERSION=5.0
 OSM_DEVOPS=
+OSM_BEHIND_PROXY=""
 
 # main
-while getopts ":D:d:i:-: h" o; do
+while getopts ":D:d:i:-: hP" o; do
     case "${o}" in
         i)
             DEFAULT_IP="${OPTARG}"
@@ -82,6 +91,9 @@ while getopts ":D:d:i:-: h" o; do
         D)
             OSM_DEVOPS="${OPTARG}"
             ;;
+        P)
+            OSM_BEHIND_PROXY="y"
+            ;;
         -)
             [ "${OPTARG}" == "help" ] && usage && exit 0
             [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue
@@ -110,6 +122,7 @@ source $OSM_DEVOPS/common/track
 
 echo "DEBUG_INSTALL=$DEBUG_INSTALL"
 echo "DEFAULT_IP=$DEFAULT_IP"
+echo "OSM_BEHIND_PROXY=$OSM_BEHIND_PROXY"
 echo "OSM_DEVOPS=$OSM_DEVOPS"
 
 [ -z "$INSTALL_NOJUJU" ] && install_lxd