New option -c in full_install_osm to allow different K8s cluster engines 59/14159/2
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 22 Jan 2024 12:30:59 +0000 (13:30 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 22 Jan 2024 14:18:23 +0000 (15:18 +0100)
Change-Id: Iec530a35acf33fa8b3da788e97a98a10cf3f8be9
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
installers/full_install_osm.sh

index 68474a0..d0e7317 100755 (executable)
@@ -30,6 +30,7 @@ function usage(){
     echo -e "                     -b tags/v1.1.0     (a specific tag)"
     echo -e "                     ..."
     echo -e "     -a <apt proxy url>: use this apt proxy url when downloading apt packages (air-gapped installation)"
+    echo -e "     -c <kubernetes engine>: use a specific kubernetes engine (options: kubeadm, k3s, microk8s), default is kubeadm"
     echo -e "     -s <namespace>  namespace when installed using k8s, default is osm"
     echo -e "     -H <VCA host>   use specific juju host controller IP"
     echo -e "     -S <VCA secret> use VCA/juju secret key"
@@ -483,7 +484,7 @@ function install_osm() {
 
     track prereq prereqok_ok
 
-    if [ -n "$INSTALL_DOCKER" ]; then
+    if [ -n "$INSTALL_DOCKER" ] || [ "${K8S_CLUSTER_ENGINE}" == "kubeadm" ]; 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"
@@ -492,9 +493,11 @@ function install_osm() {
 
     track docker_ce docker_ce_ok
 
-    $OSM_DEVOPS/installers/install_kubeadm_cluster.sh -i ${OSM_DEFAULT_IP} -d ${OSM_WORK_DIR} -D ${OSM_DEVOPS} ${DEBUG_INSTALL} || \
-    FATAL_TRACK k8scluster "install_kubeadm_cluster.sh failed"
-    track k8scluster k8scluster_ok
+    if [ "${K8S_CLUSTER_ENGINE}" == "kubeadm" ]; then
+        $OSM_DEVOPS/installers/install_kubeadm_cluster.sh -i ${OSM_DEFAULT_IP} -d ${OSM_WORK_DIR} -D ${OSM_DEVOPS} ${DEBUG_INSTALL} || \
+        FATAL_TRACK k8scluster "install_kubeadm_cluster.sh failed"
+        track k8scluster k8scluster_ok
+    fi
 
     if [ -n "${INSTALL_JUJU}" ]; then
         JUJU_OPTS="-D ${OSM_DEVOPS} -s ${OSM_NAMESPACE} -i ${OSM_DEFAULT_IP} ${DEBUG_INSTALL} ${INSTALL_CACHELXDIMAGES}"
@@ -624,6 +627,7 @@ function install_k8s_monitoring() {
 function dump_vars(){
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
     echo "APT_PROXY_URL=$APT_PROXY_URL"
+    echo "K8S_CLUSTER_ENGINE=$K8S_CLUSTER_ENGINE"
     echo "DEVELOP=$DEVELOP"
     echo "DEBUG_INSTALL=$DEBUG_INSTALL"
     echo "DOCKER_NOBUILD=$DOCKER_NOBUILD"
@@ -697,6 +701,7 @@ SHOWOPTS=""
 COMMIT_ID=""
 ASSUME_YES=""
 APT_PROXY_URL=""
+K8S_CLUSTER_ENGINE="kubeadm"
 INSTALL_FROM_SOURCE=""
 DEBUG_INSTALL=""
 RELEASE="ReleaseTEN"
@@ -758,7 +763,7 @@ 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
+while getopts ":a:b:c: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
         a)
             APT_PROXY_URL=${OPTARG}
@@ -767,6 +772,14 @@ 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;
             COMMIT_ID=${OPTARG}
             PULL_IMAGES=""
             ;;
+        c)
+            K8S_CLUSTER_ENGINE=${OPTARG}
+            [ "${K8S_CLUSTER_ENGINE}" == "kubeadm" ] && continue
+            [ "${K8S_CLUSTER_ENGINE}" == "k3s" ] && continue
+            [ "${K8S_CLUSTER_ENGINE}" == "microk8s" ] && continue
+            echo -e "Invalid argument for -c : ' ${K8S_CLUSTER_ENGINE}'\n" >&2
+            usage && exit 1
+            ;;
         r)
             REPOSITORY="${OPTARG}"
             REPO_ARGS+=(-r "$REPOSITORY")
@@ -961,34 +974,32 @@ echo $os_release
 os_info="${os_distro}_${os_release}"
 os_info="${os_info// /_}"
 
-# Charmed installation
 if [ -n "$CHARMED" ]; then
+    # Charmed installation
     sudo snap install jq || FATAL "Could not install jq (snap package). Make sure that snap works"
     ${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-15.0-fifteen/README2.txt &> /dev/null
     echo -e "\nDONE"
     exit 0
-fi
-
-# Installation to Openstack
-if [ -n "$INSTALL_TO_OPENSTACK" ]; then
+elif [ -n "$INSTALL_TO_OPENSTACK" ]; then
+    # Installation to Openstack
     install_to_openstack $OPENSTACK_OPENRC_FILE_OR_CLOUD $OPENSTACK_PUBLIC_NET_NAME $OPENSTACK_ATTACH_VOLUME
     echo -e "\nDONE"
     exit 0
+else
+    # Community_installer
+    # Check incompatible options
+    [ -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"
+    # Special cases go first
+    # if develop, we force master
+    [ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master"
+    [ -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
+    # This is where installation starts
+    install_osm
+    echo -e "\nDONE"
+    exit 0
 fi
-
-# Community_installer
-# Check incompatible options
-[ -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"
-# Special cases go first
-# if develop, we force master
-[ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master"
-[ -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
-# This is where installation starts
-install_osm
-echo -e "\nDONE"
-exit 0