Improve annotations for exposing OSM services in charmed installer 72/9672/2
authorDavid Garcia <david.garcia@canonical.com>
Wed, 2 Sep 2020 09:40:12 +0000 (11:40 +0200)
committerbeierlm <mark.beierl@canonical.com>
Wed, 2 Sep 2020 16:43:44 +0000 (18:43 +0200)
Change-Id: Iffde16ff5f92aa3a99f2fb8e1ff22c8b9eb61caf
Signed-off-by: David Garcia <david.garcia@canonical.com>
installers/charmed_install.sh

index c1c46e4..8900270 100755 (executable)
@@ -210,25 +210,30 @@ function deploy_charmed_osm(){
         API_SERVER="$(echo $hostport | sed -e 's,:.*,,g')"
     fi
 
+    # Expose OSM services
+    # Expose NBI
     juju config nbi-k8s juju-external-hostname=nbi.${API_SERVER}.xip.io
     juju expose nbi-k8s
 
-    wait_for_port nbi-k8s 0
-    sg ${KUBEGRP} -c "${KUBECTL} get ingress -n osm -o json | jq '.items[0].metadata.annotations += {\"nginx.ingress.kubernetes.io/backend-protocol\": \"HTTPS\"}' | ${KUBECTL} --validate=false replace -f -"
-    sg ${KUBEGRP} -c "${KUBECTL} get ingress -n osm -o json | jq '.items[0].metadata.annotations += {\"nginx.ingress.kubernetes.io/proxy-body-size\": \"0\"}' | ${KUBECTL} replace -f -"
-
+    # Expose NG UI
     juju config ng-ui juju-external-hostname=ui.${API_SERVER}.xip.io
     juju expose ng-ui
 
-    wait_for_port ng-ui 1
-    sg ${KUBEGRP} -c "${KUBECTL} get ingress -n osm -o json | jq '.items[2].metadata.annotations += {\"nginx.ingress.kubernetes.io/proxy-body-size\": \"0\"}' | ${KUBECTL} --validate=false replace -f -"
-
+    # Expose UI
     juju config ui-k8s juju-external-hostname=osm.${API_SERVER}.xip.io
     juju expose ui-k8s
 
+    # Wait for ingress resources to be applied
+    wait_for_port nbi-k8s 0
+    wait_for_port ng-ui 1
     wait_for_port ui-k8s 2
-    sg ${KUBEGRP} -c "${KUBECTL} get ingress -n osm -o json | jq '.items[1].metadata.annotations += {\"nginx.ingress.kubernetes.io/proxy-body-size\": \"0\"}' | ${KUBECTL} --validate=false replace -f -"
-}
+
+    # Apply annotations
+    sg ${KUBEGRP} -c "${KUBECTL} annotate ingress nginx.ingress.kubernetes.io/backend-protocol=HTTPS -n osm -l juju-app=nbi-k8s"
+    sg ${KUBEGRP} -c "${KUBECTL} annotate ingress nginx.ingress.kubernetes.io/proxy-body-size=0 -n osm -l juju-app=nbi-k8s"
+    sg ${KUBEGRP} -c "${KUBECTL} annotate ingress nginx.ingress.kubernetes.io/proxy-body-size=0 -n osm -l juju-app=ng-ui"
+    sg ${KUBEGRP} -c "${KUBECTL} annotate ingress nginx.ingress.kubernetes.io/proxy-body-size=0 -n osm -l juju-app=ui-k8s"
+
 
 function check_osm_deployed() {
     TIME_TO_WAIT=600