X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Fcharmed_install.sh;h=16d6d731d7383201a9fd04485d98ae39d8a8a9b1;hb=ef349d9224f93fcc3eeb7a26f71c6a128ffbf96a;hp=b56ed168f7698444ec33cdc7afa82609a26b6190;hpb=f2782c56cca33615b9879b4615bb2a9e3a9f7cba;p=osm%2Fdevops.git diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index b56ed168..16d6d731 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -15,11 +15,15 @@ # set -eux +JUJU_AGENT_VERSION=2.8.6 K8S_CLOUD_NAME="k8s-cloud" KUBECTL="microk8s.kubectl" +MICROK8S_VERSION=1.19 IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml PATH=/snap/bin:${PATH} +MODEL_NAME=osm + function check_arguments(){ while [ $# -gt 0 ] ; do case $1 in @@ -41,7 +45,7 @@ function check_arguments(){ function install_snaps(){ if [ ! -v KUBECFG ]; then - sudo snap install microk8s --classic + sudo snap install microk8s --classic --channel=${MICROK8S_VERSION}/stable sudo usermod -a -G microk8s `whoami` mkdir -p ~/.kube sudo chown -f -R `whoami` ~/.kube @@ -91,7 +95,7 @@ EOF cat $KUBECFG | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS [ -v BOOTSTRAP_NEEDED ] && juju bootstrap $K8S_CLOUD_NAME $CONTROLLER_NAME \ --config controller-service-type=loadbalancer \ - --agent-version=2.8.1 + --agent-version=$JUJU_AGENT_VERSION else sg ${KUBEGRP} -c "echo ${DEFAULT_IP}-${DEFAULT_IP} | microk8s.enable metallb" sg ${KUBEGRP} -c "microk8s.enable ingress" @@ -115,7 +119,7 @@ EOF [ ! -v BOOTSTRAP_NEEDED ] && sg ${KUBEGRP} -c "microk8s.config" | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS [ -v BOOTSTRAP_NEEDED ] && sg ${KUBEGRP} -c \ - "juju bootstrap microk8s $CONTROLLER_NAME --config controller-service-type=loadbalancer --agent-version=2.8.1" \ + "juju bootstrap microk8s $CONTROLLER_NAME --config controller-service-type=loadbalancer --agent-version=$JUJU_AGENT_VERSION" \ && K8S_CLOUD_NAME=microk8s fi @@ -222,9 +226,9 @@ function deploy_charmed_osm(){ create_overlay echo "Creating OSM model" if [ -v KUBECFG ]; then - juju add-model osm $K8S_CLOUD_NAME + juju add-model $MODEL_NAME $K8S_CLOUD_NAME else - sg ${KUBEGRP} -c "juju add-model osm $K8S_CLOUD_NAME" + sg ${KUBEGRP} -c "juju add-model $MODEL_NAME $K8S_CLOUD_NAME" fi echo "Deploying OSM with charms" images_overlay="" @@ -234,9 +238,9 @@ function deploy_charmed_osm(){ [ -v TAG ] && generate_images_overlay && images_overlay="--overlay $IMAGES_OVERLAY_FILE" if [ -v BUNDLE ]; then - juju deploy $BUNDLE --overlay ~/.osm/vca-overlay.yaml $images_overlay + juju deploy -m $MODEL_NAME $BUNDLE --overlay ~/.osm/vca-overlay.yaml $images_overlay else - juju deploy cs:osm --overlay ~/.osm/vca-overlay.yaml $images_overlay + juju deploy -m $MODEL_NAME cs:osm-53 --overlay ~/.osm/vca-overlay.yaml $images_overlay fi echo "Waiting for deployment to finish..." @@ -254,46 +258,32 @@ function deploy_charmed_osm(){ fi # Expose OSM services - # Expose Grafana - juju config grafana-k8s juju-external-hostname=grafana.${API_SERVER}.xip.io - juju expose grafana-k8s - wait_for_port grafana-k8s 0 - # Expose NBI - juju config nbi-k8s juju-external-hostname=nbi.${API_SERVER}.xip.io - juju expose nbi-k8s - wait_for_port nbi-k8s 1 + juju config -m $MODEL_NAME nbi site_url=https://nbi.${API_SERVER}.xip.io + juju config -m $MODEL_NAME ng-ui site_url=https://ui.${API_SERVER}.xip.io - # Expose NG UI - juju config ng-ui juju-external-hostname=ui.${API_SERVER}.xip.io - juju expose ng-ui - wait_for_port ng-ui 2 + # Expose Grafana + juju config -m $MODEL_NAME grafana-k8s juju-external-hostname=grafana.${API_SERVER}.xip.io + juju expose -m $MODEL_NAME grafana-k8s + wait_for_port grafana-k8s 0 # Expose Prometheus - juju config prometheus-k8s juju-external-hostname=prometheus.${API_SERVER}.xip.io - juju expose prometheus-k8s - wait_for_port prometheus-k8s 3 - - # Expose UI - juju config ui-k8s juju-external-hostname=osm.${API_SERVER}.xip.io - juju expose ui-k8s - wait_for_port ui-k8s 4 + juju config -m $MODEL_NAME prometheus-k8s juju-external-hostname=prometheus.${API_SERVER}.xip.io + juju expose -m $MODEL_NAME prometheus-k8s + wait_for_port prometheus-k8s 1 # Apply annotations - sg ${KUBEGRP} -c "${KUBECTL} annotate ingresses.networking nginx.ingress.kubernetes.io/backend-protocol=HTTPS -n osm -l juju-app=nbi-k8s" - sg ${KUBEGRP} -c "${KUBECTL} annotate ingresses.networking nginx.ingress.kubernetes.io/proxy-body-size=0 -n osm -l juju-app=nbi-k8s" sg ${KUBEGRP} -c "${KUBECTL} annotate ingresses.networking nginx.ingress.kubernetes.io/proxy-body-size=0 -n osm -l juju-app=ng-ui" - sg ${KUBEGRP} -c "${KUBECTL} annotate ingresses.networking nginx.ingress.kubernetes.io/proxy-body-size=0 -n osm -l juju-app=ui-k8s" } function check_osm_deployed() { TIME_TO_WAIT=600 start_time="$(date -u +%s)" - total_service_count=15 + total_service_count=14 previous_count=0 while true do - service_count=$(juju status | grep kubernetes | grep active | wc -l) + service_count=$(juju status -m $MODEL_NAME | grep kubernetes | grep active | wc -l) echo "$service_count / $total_service_count services active" if [ $service_count -eq $total_service_count ]; then break @@ -354,6 +344,12 @@ EOF } function generate_images_overlay(){ + cat << EOF > /tmp/nbi_registry.yaml +registrypath: ${REGISTRY_URL}opensourcemano/nbi:$TAG +EOF + cat << EOF > /tmp/ng_ui_registry.yaml +registrypath: ${REGISTRY_URL}opensourcemano/ng-ui:$TAG +EOF if [ ! -z "$REGISTRY_USERNAME" ] ; then REGISTRY_CREDENTIALS=$(cat <> /tmp/nbi_registry.yaml + echo password: $REGISTRY_PASSWORD >> /tmp/nbi_registry.yaml + echo username: $REGISTRY_USERNAME >> /tmp/ng_ui_registry.yaml + echo password: $REGISTRY_PASSWORD >> /tmp/ng_ui_registry.yaml fi cat << EOF > /tmp/images-overlay.yaml @@ -374,21 +374,18 @@ applications: ro-k8s: options: image: ${REGISTRY_URL}opensourcemano/ro:$TAG ${REGISTRY_CREDENTIALS} - nbi-k8s: - options: - image: ${REGISTRY_URL}opensourcemano/nbi:$TAG ${REGISTRY_CREDENTIALS} + nbi: + resources: + image: /tmp/nbi_registry.yaml pol-k8s: options: image: ${REGISTRY_URL}opensourcemano/pol:$TAG ${REGISTRY_CREDENTIALS} - ui-k8s: - options: - image: ${REGISTRY_URL}opensourcemano/light-ui:$TAG ${REGISTRY_CREDENTIALS} pla: options: image: ${REGISTRY_URL}opensourcemano/pla:$TAG ${REGISTRY_CREDENTIALS} ng-ui: - options: - image: ${REGISTRY_URL}opensourcemano/ng-ui:$TAG ${REGISTRY_CREDENTIALS} + resources: + image: /tmp/ng_ui_registry.yaml keystone: options: image: ${REGISTRY_URL}opensourcemano/keystone:$TAG ${REGISTRY_CREDENTIALS} @@ -414,7 +411,7 @@ function install_microstack() { ubuntu1604 ssh-keygen -t rsa -N "" -f ~/.ssh/microstack microstack.openstack keypair create --public-key ~/.ssh/microstack.pub microstack - export OSM_HOSTNAME=`juju status --format json | jq -rc '.applications."nbi-k8s".address'` + export OSM_HOSTNAME=`juju status --format json | jq -rc '.applications."nbi".address'` osm vim-create --name microstack-site \ --user admin \ --password keystone \ @@ -444,7 +441,7 @@ if [ -v MICROSTACK ]; then install_microstack fi -OSM_HOSTNAME=$(juju config nbi-k8s juju-external-hostname):443 +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