From 5d19ac25a6d26ef853399a46f6c2d190b5c2b803 Mon Sep 17 00:00:00 2001 From: aticig Date: Fri, 6 May 2022 13:46:22 +0300 Subject: [PATCH] Make LXD installation optional in Charmed Installer By default lxd cloud is defined, with this change optionally lxd cloud is not added by passing --small-profile parameter in charmed installer. Change-Id: I8f3b1816c9f2f43ee6bb84c15b2ce0eda99d691b Signed-off-by: aticig --- installers/charmed_install.sh | 75 ++++++++++++++++++---------------- installers/full_install_osm.sh | 2 + installers/install_osm.sh | 1 + 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index 7e73dbdd..6d7e2643 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -51,6 +51,7 @@ function check_arguments(){ --overlay) OVERLAY="$2" ;; --k8s) KUBECFG="$2" ;; --vca) CONTROLLER="$2" ;; + --small-profile) INSTALL_NOLXD=y;; --lxd) LXD_CLOUD="$2" ;; --lxd-cred) LXD_CREDENTIALS="$2" ;; --microstack) MICROSTACK=y ;; @@ -157,30 +158,31 @@ EOF fi track bootstrap_k8s bootstrap_k8s_ok - if [ -v LXD_CLOUD ]; then - if [ ! -v LXD_CREDENTIALS ]; then - echo "The installer needs the LXD server certificate if the LXD is external" - FATAL_TRACK bootstrap_lxd "No LXD certificate supplied" - fi - else - LXDENDPOINT=$DEFAULT_IP - LXD_CLOUD=~/.osm/lxd-cloud.yaml - LXD_CREDENTIALS=~/.osm/lxd-credentials.yaml - # Apply sysctl production values for optimal performance - sudo cp /usr/share/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 /usr/share/osm-devops/installers/lxd-preseed.conf | sed 's/^config: {}/config:\n core.https_address: '$LXDENDPOINT':8443/' | sg lxd -c "lxd init --preseed" - sg lxd -c "lxd waitready" - 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" - - cat << EOF > $LXD_CLOUD + if [ ! -v INSTALL_NOLXD ]; then + if [ -v LXD_CLOUD ]; then + if [ ! -v LXD_CREDENTIALS ]; then + echo "The installer needs the LXD server certificate if the LXD is external" + FATAL_TRACK bootstrap_lxd "No LXD certificate supplied" + fi + else + LXDENDPOINT=$DEFAULT_IP + LXD_CLOUD=~/.osm/lxd-cloud.yaml + LXD_CREDENTIALS=~/.osm/lxd-credentials.yaml + # Apply sysctl production values for optimal performance + sudo cp /usr/share/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 /usr/share/osm-devops/installers/lxd-preseed.conf | sed 's/^config: {}/config:\n core.https_address: '$LXDENDPOINT':8443/' | sg lxd -c "lxd init --preseed" + sg lxd -c "lxd waitready" + 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" + + cat << EOF > $LXD_CLOUD clouds: lxd-cloud: type: lxd @@ -189,12 +191,12 @@ clouds: config: ssl-hostname-verification: false EOF - openssl req -nodes -new -x509 -keyout ~/.osm/client.key -out ~/.osm/client.crt -days 365 -subj "/C=FR/ST=Nice/L=Nice/O=ETSI/OU=OSM/CN=osm.etsi.org" - local server_cert=`cat /var/snap/lxd/common/lxd/server.crt | sed 's/^/ /'` - local client_cert=`cat ~/.osm/client.crt | sed 's/^/ /'` - local client_key=`cat ~/.osm/client.key | sed 's/^/ /'` + openssl req -nodes -new -x509 -keyout ~/.osm/client.key -out ~/.osm/client.crt -days 365 -subj "/C=FR/ST=Nice/L=Nice/O=ETSI/OU=OSM/CN=osm.etsi.org" + local server_cert=`cat /var/snap/lxd/common/lxd/server.crt | sed 's/^/ /'` + local client_cert=`cat ~/.osm/client.crt | sed 's/^/ /'` + local client_key=`cat ~/.osm/client.key | sed 's/^/ /'` - cat << EOF > $LXD_CREDENTIALS + cat << EOF > $LXD_CREDENTIALS credentials: lxd-cloud: lxd-cloud: @@ -206,14 +208,15 @@ $client_cert client-key: | $client_key EOF - lxc config trust add local: ~/.osm/client.crt + lxc config trust add local: ~/.osm/client.crt + fi + + juju add-cloud -c $CONTROLLER_NAME lxd-cloud $LXD_CLOUD --force + juju add-credential -c $CONTROLLER_NAME lxd-cloud -f $LXD_CREDENTIALS + sg lxd -c "lxd waitready" + juju controller-config features=[k8s-operators] + track bootstrap_lxd bootstrap_lxd_ok fi - - juju add-cloud -c $CONTROLLER_NAME lxd-cloud $LXD_CLOUD --force - juju add-credential -c $CONTROLLER_NAME lxd-cloud -f $LXD_CREDENTIALS - sg lxd -c "lxd waitready" - juju controller-config features=[k8s-operators] - track bootstrap_lxd bootstrap_lxd_ok } function deploy_charmed_osm(){ diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index f8bb2aeb..ce0f2140 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -74,6 +74,7 @@ function usage(){ 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)" @@ -1081,6 +1082,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}" == "microstack" ] && continue [ "${OPTARG}" == "overlay" ] && continue [ "${OPTARG}" == "only-vca" ] && continue + [ "${OPTARG}" == "small-profile" ] && continue [ "${OPTARG}" == "vca" ] && continue [ "${OPTARG}" == "ha" ] && continue [ "${OPTARG}" == "tag" ] && continue diff --git a/installers/install_osm.sh b/installers/install_osm.sh index 8863297b..3a2c3b4a 100755 --- a/installers/install_osm.sh +++ b/installers/install_osm.sh @@ -75,6 +75,7 @@ function usage(){ 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 " [--lxd ]: Takes a YAML file as a parameter with the LXD Cloud information (--charmed option)" + echo -e " [--small-profile]: Do not install and configure LXD which aims to use only K8s Clouds (--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)" echo -e " [--overlay]: Add an overlay to override some defaults of the default bundle (--charmed option)" -- 2.17.1