From 107010b30e65738adf87f1e4faf16f3b55987b6b Mon Sep 17 00:00:00 2001 From: David Garcia Date: Fri, 15 Jan 2021 12:58:59 +0100 Subject: [PATCH] Several fixes to the charmed installer - fix bug 1394: update images defining a default TAG (=9) - fix bug 1401: add --advertise-address option to kube-apiserver in microk8s - fix bug 1405 - fix bug 1406: pin the version of the osmclient snap. Add the logic to install/refresh the snap to the proper version. Add channel preference (stable -> candidate -> beta -> edge), so the installers tries first with stable, but if it does not exist, then tries with candidate, etc. Change-Id: I02edaaeed81e3b06ed328e81ecab2bf71d42c628 Signed-off-by: David Garcia (cherry picked from commit b50dabe0ff0ba74ec6fa9566fc1e509e6866c1e4) --- installers/charmed_install.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index 4e86d6a8..543adac8 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -19,6 +19,7 @@ JUJU_AGENT_VERSION=2.8.6 K8S_CLOUD_NAME="k8s-cloud" KUBECTL="microk8s.kubectl" MICROK8S_VERSION=1.19 +OSMCLIENT_VERSION=9.0 IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml PATH=/snap/bin:${PATH} @@ -26,6 +27,7 @@ MODEL_NAME=osm OSM_BUNDLE=cs:osm-54 OSM_HA_BUNDLE=cs:osm-ha-40 +TAG=9 function check_arguments(){ while [ $# -gt 0 ] ; do @@ -49,13 +51,18 @@ function check_arguments(){ function install_snaps(){ if [ ! -v KUBECFG ]; then sudo snap install microk8s --classic --channel=${MICROK8S_VERSION}/stable + cat /var/snap/microk8s/current/args/kube-apiserver | grep advertise-address || ( + echo "--advertise-address $DEFAULT_IP" | sudo tee -a /var/snap/microk8s/current/args/kube-apiserver + microk8s.stop + microk8s.start + ) sudo usermod -a -G microk8s `whoami` mkdir -p ~/.kube sudo chown -f -R `whoami` ~/.kube KUBEGRP="microk8s" sg ${KUBEGRP} -c "microk8s status --wait-ready" KUBECONFIG=~/.osm/microk8s-config.yaml - sg ${KUBEGRP} -c "microk8s config" > ${KUBECONFIG} + sg ${KUBEGRP} -c "microk8s config" | tee ${KUBECONFIG} else KUBECTL="kubectl" sudo snap install kubectl --classic @@ -396,9 +403,23 @@ EOF mv /tmp/images-overlay.yaml $IMAGES_OVERLAY_FILE } +function refresh_osmclient_snap() { + osmclient_snap_install_refresh refresh +} + +function install_osm_client_snap() { + osmclient_snap_install_refresh install +} + +function osmclient_snap_install_refresh() { + channel_preference="stable candidate beta edge" + for channel in $channel_preference; do + echo "Trying to install osmclient from channel $OSMCLIENT_VERSION/$channel" + sudo snap $1 osmclient --channel $OSMCLIENT_VERSION/$channel 2> /dev/null && echo osmclient snap installed && break + done +} function install_osmclient() { - sudo snap install osmclient - sudo snap alias osmclient.osm osm + snap info osmclient | grep -E ^installed: && refresh_osmclient_snap || install_osm_client_snap } function add_local_k8scluster() { -- 2.25.1