X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Fcharmed_install.sh;h=77afdb4eb8c5d2087e565e0315a9f2045cc62990;hb=ea802d28207a5925ea7f79b8aa5263c70a33416e;hp=16d6d731d7383201a9fd04485d98ae39d8a8a9b1;hpb=ef349d9224f93fcc3eeb7a26f71c6a128ffbf96a;p=osm%2Fdevops.git diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index 16d6d731..77afdb4e 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -15,15 +15,20 @@ # set -eux -JUJU_AGENT_VERSION=2.8.6 +JUJU_AGENT_VERSION=2.8.8 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} MODEL_NAME=osm +OSM_BUNDLE=cs:osm-54 +OSM_HA_BUNDLE=cs:osm-ha-40 +TAG=9 + function check_arguments(){ while [ $# -gt 0 ] ; do case $1 in @@ -33,7 +38,7 @@ function check_arguments(){ --lxd) LXD_CLOUD="$2" ;; --lxd-cred) LXD_CREDENTIALS="$2" ;; --microstack) MICROSTACK=y ;; - --ha) BUNDLE="cs:osm-ha" ;; + --ha) BUNDLE=$OSM_HA_BUNDLE ;; --tag) TAG="$2" ;; --registry) REGISTRY_INFO="$2" ;; esac @@ -46,11 +51,18 @@ function check_arguments(){ function install_snaps(){ if [ ! -v KUBECFG ]; then sudo snap install microk8s --classic --channel=${MICROK8S_VERSION}/stable + sudo 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" | tee ${KUBECONFIG} else KUBECTL="kubectl" sudo snap install kubectl --classic @@ -240,7 +252,7 @@ function deploy_charmed_osm(){ if [ -v BUNDLE ]; then juju deploy -m $MODEL_NAME $BUNDLE --overlay ~/.osm/vca-overlay.yaml $images_overlay else - juju deploy -m $MODEL_NAME cs:osm-53 --overlay ~/.osm/vca-overlay.yaml $images_overlay + juju deploy -m $MODEL_NAME $OSM_BUNDLE --overlay ~/.osm/vca-overlay.yaml $images_overlay fi echo "Waiting for deployment to finish..." @@ -303,18 +315,16 @@ function check_osm_deployed() { function create_overlay() { sudo snap install jq - sudo apt install python3-pip -y - python3 -m pip install yq - PATH=$PATH:$HOME/.local/bin # make yq command available + sudo snap install yq local HOME=/home/$USER - local vca_user=$(cat $HOME/.local/share/juju/accounts.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME].user') - local vca_password=$(cat $HOME/.local/share/juju/accounts.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME].password') - local vca_host=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["api-endpoints"][0]' --raw-output | cut -d ":" -f 1) - local vca_port=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["api-endpoints"][0]' --raw-output | cut -d ":" -f 2) + local vca_user=$(cat $HOME/.local/share/juju/accounts.yaml | yq e .controllers.$CONTROLLER_NAME.user - ) + local vca_password=$(cat $HOME/.local/share/juju/accounts.yaml | yq e .controllers.$CONTROLLER_NAME.password - ) + local vca_host=$(cat $HOME/.local/share/juju/controllers.yaml | yq e .controllers.$CONTROLLER_NAME.api-endpoints[0] - | cut -d ":" -f 1) + local vca_port=$(cat $HOME/.local/share/juju/controllers.yaml | yq e .controllers.$CONTROLLER_NAME.api-endpoints[0] - | cut -d ":" -f 2) local vca_pubkey=\"$(cat $HOME/.local/share/juju/ssh/juju_id_rsa.pub)\" local vca_cloud="lxd-cloud" # Get the VCA Certificate - local vca_cacert=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["ca-cert"]' --raw-output | base64 | tr -d \\n) + local vca_cacert=$(cat $HOME/.local/share/juju/controllers.yaml | yq e .controllers.$CONTROLLER_NAME.ca-cert - | base64 | tr -d \\n) # Calculate the default route of this machine local DEFAULT_IF=`ip route list match 0.0.0.0 | awk '{print $5}'` @@ -382,7 +392,7 @@ applications: image: ${REGISTRY_URL}opensourcemano/pol:$TAG ${REGISTRY_CREDENTIALS} pla: options: - image: ${REGISTRY_URL}opensourcemano/pla:$TAG ${REGISTRY_CREDENTIALS} + image: ${REGISTRY_URL}opensourcemano/pla:8 ${REGISTRY_CREDENTIALS} ng-ui: resources: image: /tmp/ng_ui_registry.yaml @@ -393,11 +403,44 @@ 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() { + osm --all-projects vim-create \ + --name _system-osm-vim \ + --account_type dummy \ + --auth_url http://dummy \ + --user osm --password osm --tenant osm \ + --description "dummy" \ + --config '{management_network_name: mgmt}' + tmpfile=$(mktemp --tmpdir=${HOME}) + cp ${KUBECONFIG} ${tmpfile} + osm --all-projects k8scluster-add \ + --creds ${tmpfile} \ + --vim _system-osm-vim \ + --k8s-nets '{"net1": null}' \ + --version '1.19' \ + --description "OSM Internal Cluster" \ + _system-osm-k8s + rm -f ${tmpfile} +} function install_microstack() { sudo snap install microstack --classic --beta @@ -437,11 +480,13 @@ install_snaps bootstrap_k8s_lxd deploy_charmed_osm install_osmclient +OSM_HOSTNAME=$(juju config nbi site_url | sed "s/http.*\?:\/\///"):443 +add_local_k8scluster + if [ -v MICROSTACK ]; then install_microstack fi -OSM_HOSTNAME=$(juju config nbi site_url | sed "s/http.*\?:\/\///"):443 echo "Your installation is now complete, follow these steps for configuring the osmclient:" echo