Feature 11007: replace charmed mongodb with bitnami helm chart
[osm/devops.git] / installers / install_mongodb.sh
1 #!/bin/bash
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15
16 set +eux
17
18 # Helm chart 13.9.4 correspondes to Mongo DB 6.0.5
19 MONGODB_HELM_VERSION=13.9.4
20
21
22 # Install MongoDB helm chart
23 function install_mongodb() {
24 [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
25 # copy mongodb-values.yaml to the destination folder
26 sudo mkdir -p ${OSM_HELM_WORK_DIR}
27 sudo cp ${OSM_DEVOPS}/installers/helm/values/mongodb-values.yaml ${OSM_HELM_WORK_DIR}
28 # update mongodb-values.yaml to use the right tag
29
30 helm repo add bitnami https://charts.bitnami.com/bitnami
31 helm repo update
32 helm upgrade mongodb-k8s bitnami/mongodb -n osm --create-namespace --install -f ${OSM_HELM_WORK_DIR}/mongodb-values.yaml --version ${MONGODB_HELM_VERSION} --timeout 10m || FATAL_TRACK mongodb "Failed installing mongodb helm chart"
33 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
34 }
35
36 # main
37
38 DOCKER_REGISTRY_URL=
39 DOCKER_USER="opensourcemano"
40 OSM_DEVOPS="/usr/share/osm-devops"
41 OSM_DOCKER_TAG="testing-daily"
42 OSM_HELM_WORK_DIR="/etc/osm/helm"
43
44 while getopts ":D:d:t:r:U:-: " o; do
45 case "${o}" in
46 D)
47 OSM_DEVOPS="${OPTARG}"
48 ;;
49 d)
50 OSM_HELM_WORK_DIR="${OPTARG}"
51 ;;
52 t)
53 OSM_DOCKER_TAG="${OPTARG}"
54 ;;
55 r)
56 DOCKER_REGISTRY_URL="${OPTARG}"
57 ;;
58 U)
59 DOCKER_USER="${OPTARG}"
60 ;;
61 -)
62 [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue
63 echo -e "Invalid option: '--$OPTARG'\n" >&2
64 exit 1
65 ;;
66 :)
67 echo "Option -$OPTARG requires an argument" >&2
68 exit 1
69 ;;
70 \?)
71 echo -e "Invalid option: '-$OPTARG'\n" >&2
72 exit 1
73 ;;
74 *)
75 exit 1
76 ;;
77 esac
78 done
79
80 source $OSM_DEVOPS/common/logging
81 source $OSM_DEVOPS/common/track
82
83 echo "DEBUG_INSTALL=$DEBUG_INSTALL"
84 echo "OSM_DEVOPS=$OSM_DEVOPS"
85 echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG"
86 echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR"
87
88 install_mongodb