From a1376012fbf0a42f18d327a10cefa9a462c9fedd Mon Sep 17 00:00:00 2001 From: David Garcia Date: Mon, 19 Oct 2020 15:42:42 +0200 Subject: [PATCH] Use mongodb charm in k8s installer - Update JUJU_AGENT_VERSION to 2.8.6 - Use mongodb charm and update needed osm pod specs to point at it Change-Id: I7c03ae7de6611fcacef35716646ff08bfc1ff988 Signed-off-by: David Garcia --- installers/charmed_install.sh | 5 +++-- installers/docker/osm_pla/pla.yaml | 2 ++ installers/docker/osm_pods/lcm.yaml | 6 +++--- installers/docker/osm_pods/mon.yaml | 4 +++- installers/docker/osm_pods/nbi.yaml | 6 +++--- installers/docker/osm_pods/pol.yaml | 4 +++- installers/full_install_osm.sh | 18 ++++++++++++++++-- 7 files changed, 33 insertions(+), 12 deletions(-) diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index b56ed168..9d41e3ee 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -15,6 +15,7 @@ # set -eux +JUJU_AGENT_VERSION=2.8.6 K8S_CLOUD_NAME="k8s-cloud" KUBECTL="microk8s.kubectl" IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml @@ -91,7 +92,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 +116,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 diff --git a/installers/docker/osm_pla/pla.yaml b/installers/docker/osm_pla/pla.yaml index c5bdd502..dfd00abc 100644 --- a/installers/docker/osm_pla/pla.yaml +++ b/installers/docker/osm_pla/pla.yaml @@ -41,6 +41,8 @@ spec: value: mongo - name: OSMPLA_MESSAGE_HOST value: kafka + - name: OSMPLA_DATABASE_URI + value: mongodb://mongodb-k8s:27017/?replicaSet=rs0 volumeMounts: - name: osm-packages mountPath: /app/storage diff --git a/installers/docker/osm_pods/lcm.yaml b/installers/docker/osm_pods/lcm.yaml index 6858f2a8..e2c27bdf 100644 --- a/installers/docker/osm_pods/lcm.yaml +++ b/installers/docker/osm_pods/lcm.yaml @@ -33,15 +33,15 @@ spec: initContainers: - name: kafka-ro-mongo-test image: alpine:latest - command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 ro 9090 && nc -zvw1 mongo 27017 ); do sleep 3; done; exit 0"] + command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 ro 9090 && nc -zvw1 mongodb-k8s 27017 ); do sleep 3; done; exit 0"] containers: - name: lcm image: opensourcemano/lcm:8 env: - name: OSMLCM_RO_HOST value: ro - - name: OSMLCM_DATABASE_HOST - value: mongo + - name: OSMLCM_DATABASE_URI + value: mongodb://mongodb-k8s:27017/?replicaSet=rs0 - name: OSMLCM_MESSAGE_HOST value: kafka envFrom: diff --git a/installers/docker/osm_pods/mon.yaml b/installers/docker/osm_pods/mon.yaml index 988054f3..490889f5 100644 --- a/installers/docker/osm_pods/mon.yaml +++ b/installers/docker/osm_pods/mon.yaml @@ -47,7 +47,7 @@ spec: initContainers: - name: kafka-mongo-test image: alpine:latest - command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongo 27017); do sleep 3; done; exit 0"] + command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongodb-k8s 27017); do sleep 3; done; exit 0"] containers: - name: mon image: opensourcemano/mon:8 @@ -59,6 +59,8 @@ spec: value: kafka - name: OSMMON_MESSAGE_PORT value: "9092" + - name: OSMMON_DATABASE_URI + value: mongodb://mongodb-k8s:27017/?replicaSet=rs0 envFrom: - secretRef: name: mon-secret diff --git a/installers/docker/osm_pods/nbi.yaml b/installers/docker/osm_pods/nbi.yaml index ea6014ec..7fc6595f 100644 --- a/installers/docker/osm_pods/nbi.yaml +++ b/installers/docker/osm_pods/nbi.yaml @@ -47,7 +47,7 @@ spec: initContainers: - name: kafka-mongo-test image: alpine:latest - command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongo 27017); do sleep 3; done; exit 0"] + command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongodb-k8s 27017); do sleep 3; done; exit 0"] containers: - name: nbi image: opensourcemano/nbi:8 @@ -55,8 +55,8 @@ spec: - containerPort: 9999 protocol: TCP env: - - name: OSMNBI_DATABASE_HOST - value: mongo + - name: OSMNBI_DATABASE_URI + value: mongodb://mongodb-k8s:27017/?replicaSet=rs0 - name: OSMNBI_MESSAGE_HOST value: kafka envFrom: diff --git a/installers/docker/osm_pods/pol.yaml b/installers/docker/osm_pods/pol.yaml index 438ae1ff..063a976a 100644 --- a/installers/docker/osm_pods/pol.yaml +++ b/installers/docker/osm_pods/pol.yaml @@ -33,7 +33,7 @@ spec: initContainers: - name: kafka-mongo-test image: alpine:latest - command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongo 27017); do sleep 3; done; exit 0"] + command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongodb-k8s 27017); do sleep 3; done; exit 0"] containers: - name: pol image: opensourcemano/pol:8 @@ -42,6 +42,8 @@ spec: value: kafka - name: OSMPOL_MESSAGE_PORT value: "9092" + - name: OSMPOL_DATABASE_URI + value: mongodb://mongodb-k8s:27017/?replicaSet=rs0 envFrom: - secretRef: name: pol-secret diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index be02fa53..f8c02ca0 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -647,6 +647,7 @@ function generate_docker_compose_files() { function generate_k8s_manifest_files() { #Kubernetes resources $WORKDIR_SUDO cp -bR ${OSM_DEVOPS}/installers/docker/osm_pods $OSM_DOCKER_WORK_DIR + $WORKDIR_SUDO rm -f $OSM_K8S_WORK_DIR/mongo.yaml if [ -n "$NGUI" ]; then $WORKDIR_SUDO rm -f $OSM_K8S_WORK_DIR/light-ui.yaml else @@ -913,6 +914,18 @@ function deploy_osm_services() { kubectl apply -n $OSM_STACK_NAME -f $OSM_K8S_WORK_DIR } +#deploy charmed services +function deploy_charmed_services() { + juju add-model $OSM_STACK_NAME $OSM_VCA_K8S_CLOUDNAME + # deploy mongodb charm + namespace=$OSM_STACK_NAME + juju deploy cs:~charmed-osm/mongodb-k8s \ + --config enable-sidecar=true \ + --config replica-set=rs0 \ + --config namespace=$namespace \ + -m $namespace +} + function deploy_osm_pla_service() { # corresponding to namespace_vol $WORKDIR_SUDO sed -i "s#path: /var/lib/osm#path: $OSM_NAMESPACE_VOL#g" $OSM_DOCKER_WORK_DIR/osm_pla/pla.yaml @@ -967,7 +980,7 @@ function parse_yaml() { } function namespace_vol() { - osm_services="nbi lcm ro pol mon kafka mongo mysql prometheus" + osm_services="nbi lcm ro pol mon kafka mysql prometheus" for osm in $osm_services; do $WORKDIR_SUDO sed -i "s#path: /var/lib/osm#path: $OSM_NAMESPACE_VOL#g" $OSM_K8S_WORK_DIR/$osm.yaml done @@ -1304,6 +1317,7 @@ EOF track env_files if [ -n "$KUBERNETES" ]; then + deploy_charmed_services kube_secrets [ ! $OSM_DOCKER_TAG == "8" ] && parse_yaml $OSM_DOCKER_TAG namespace_vol @@ -1492,7 +1506,7 @@ function track(){ wget -q -O /dev/null $url } -JUJU_AGENT_VERSION=2.8.1 +JUJU_AGENT_VERSION=2.8.6 UNINSTALL="" DEVELOP="" UPDATE="" -- 2.25.1