Feature 11032: Integration of OSM Helm Chart with different databases 71/14271/12
authorLuis <lvega@whitestack.com>
Thu, 21 Mar 2024 19:39:22 +0000 (19:39 +0000)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 5 Jul 2024 06:14:56 +0000 (08:14 +0200)
Change-Id: I9ec6fc5f6ae42be8c506bff54302c3c1771bee7e
Signed-off-by: Luis Vega <lvega@whitestack.com>
17 files changed:
installers/helm/osm/templates/_helpers.tpl
installers/helm/osm/templates/keystone/keystone-configmap.yaml
installers/helm/osm/templates/keystone/keystone-deployment.yaml
installers/helm/osm/templates/lcm/lcm-configmap.yaml
installers/helm/osm/templates/lcm/lcm-deployment.yaml
installers/helm/osm/templates/mon/mon-configmap.yaml
installers/helm/osm/templates/mon/mon-deployment.yaml
installers/helm/osm/templates/nbi/nbi-configmap.yaml
installers/helm/osm/templates/nbi/nbi-deployment.yaml
installers/helm/osm/templates/osm-secret.yaml
installers/helm/osm/templates/pla/pla-configmap.yaml
installers/helm/osm/templates/pla/pla-deployment.yaml
installers/helm/osm/templates/pol/pol-configmap.yaml
installers/helm/osm/templates/pol/pol-deployment.yaml
installers/helm/osm/templates/ro/ro-configmap.yaml
installers/helm/osm/templates/ro/ro-deployment.yaml
installers/helm/osm/values.yaml

index 337073f..6599361 100644 (file)
@@ -109,3 +109,16 @@ Create the name of the images to be used
 {{ define "osm.keystone.image" -}}
 {{ printf "%s:%s" (.Values.keystone.image.repository | default (printf "%s/keystone" (.Values.global.image.repositoryBase))) (.Values.keystone.image.tag | default .Values.global.image.tag) }}
 {{- end }}
+
+{{/*
+Return the MongoDB URI based on whether authentication is enabled.
+*/}}
+{{- define "osm.databaseUri" -}}
+  {{- if .Values.global.db.mongo.auth.enabled }}
+    {{- $secret := (lookup "v1" "Secret" .Release.Namespace .Values.global.db.mongo.auth.secretName ) }}
+    {{- $password := (index $secret.data .Values.global.db.mongo.auth.secretKeyRootPassword ) | b64dec }}
+    {{ printf "mongodb://root:%s@%s:27017/?replicaSet=rs0" $password .Values.global.db.mongo.mongoService | b64enc | quote }}
+  {{- else }}
+    {{ printf "mongodb://%s:27017/?replicaSet=rs0" .Values.global.db.mongo.mongoService | b64enc | quote }}
+  {{- end }}
+{{- end }}
index f076ad7..02a859a 100644 (file)
@@ -22,5 +22,5 @@ metadata:
   labels:
     {{- include "osm.labels" . | nindent 4 }}
 data:
-  DB_HOST: "mysql"
+  DB_HOST: "{{ .Values.global.db.mysql.mysqlService }}"
 {{- end }}
\ No newline at end of file
index e8b798e..ba7e05d 100644 (file)
@@ -72,8 +72,8 @@ spec:
             - name: ROOT_DB_PASSWORD
               valueFrom:
                 secretKeyRef:
-                  name: mysql
-                  key: mysql-root-password
+                  name: {{  .Values.global.db.mysql.mysqlSecretName }}
+                  key: {{ .Values.global.db.mysql.mysqlSecretKey }}
             - name: KEYSTONE_DB_PASSWORD
               valueFrom:
                 secretKeyRef:
index 5cbc1cf..38f4d8e 100644 (file)
@@ -23,12 +23,10 @@ metadata:
     {{- include "osm.labels" . | nindent 4 }}
 data:
   OSMLCM_RO_HOST: "ro"
-  OSMLCM_DATABASE_URI: "mongodb://mongodb-k8s:27017/?replicaSet=rs0"
   OSMLCM_MESSAGE_HOST: "kafka"
   OSMLCM_STORAGE_DRIVER: "mongo"
   OSMLCM_STORAGE_PATH: "/app/storage"
   OSMLCM_STORAGE_COLLECTION: "files"
-  OSMLCM_STORAGE_URI: "mongodb://mongodb-k8s:27017/?replicaSet=rs0"
   OSMLCM_GLOBAL_LOGLEVEL: {{ .Values.lcm.logLevel | default .Values.global.logLevel | default "INFO" }}
   OSMLCM_MAINPOSTRENDERERPATH: "{{ .Values.lcm.mainPostRenderer.path }}{{ .Values.lcm.mainPostRenderer.scriptName }}"
   OSMLCM_PODLABELSPOSTRENDERERPATH: "{{ .Values.lcm.podLabelsPostRenderer.path }}{{ .Values.lcm.podLabelsPostRenderer.scriptName }}"
index b714f50..b28c286 100644 (file)
@@ -47,7 +47,7 @@ spec:
       initContainers:
         - name: kafka-ro-mongo-test
           image: alpine:latest
-          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 ro 9090 && nc -zvw1 mongodb-k8s 27017); do sleep 3; done; exit 0"]
+          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 ro 9090 && nc -zvw1 {{ .Values.global.db.mongo.mongoService }} 27017); do sleep 3; done; exit 0"]
       containers:
         - name: lcm
           securityContext:
@@ -99,6 +99,16 @@ spec:
                 secretKeyRef:
                   name: {{ include "osm.fullname" . }}-secret
                   key: OSM_DATABASE_COMMONKEY
+            - name: OSMLCM_DATABASE_URI
+              valueFrom:
+                secretKeyRef:
+                  name: {{ include "osm.fullname" . }}-secret
+                  key: OSM_DATABASE_URI
+            - name: OSMLCM_STORAGE_URI
+              valueFrom:
+                secretKeyRef:
+                  name: {{ include "osm.fullname" . }}-secret
+                  key: OSM_DATABASE_URI
             {{- end }}
           {{- end }}
           volumeMounts:
index c6e506e..27b3b85 100644 (file)
@@ -22,7 +22,6 @@ metadata:
   labels:
     {{- include "osm.labels" . | nindent 4 }}
 data:
-  OSMMON_DATABASE_URI: "mongodb://mongodb-k8s:27017/?replicaSet=rs0"
   OSMMON_MESSAGE_HOST: "kafka"
   OSMMON_MESSAGE_PORT: "9092"
   OSMMON_GLOBAL_LOG_LEVEL: {{ .Values.mon.logLevel | default .Values.global.logLevel | default "INFO" }}
index 4fcbd58..4473ffa 100644 (file)
@@ -47,7 +47,7 @@ spec:
       initContainers:
         - name: kafka-mongo-test
           image: alpine:latest
-          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongodb-k8s 27017); do sleep 3; done; exit 0"]
+          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 {{ .Values.global.db.mongo.mongoService }} 27017); do sleep 3; done; exit 0"]
       containers:
         - name: mon
           securityContext:
@@ -106,6 +106,11 @@ spec:
                 secretKeyRef:
                   name: {{ include "osm.fullname" . }}-secret
                   key: OSM_DATABASE_COMMONKEY
+            - name: OSMMON_DATABASE_URI
+              valueFrom:
+                secretKeyRef:
+                  name: {{ include "osm.fullname" . }}-secret
+                  key: OSM_DATABASE_URI
             {{- end }}
           {{- end }}
       {{- with .Values.global.nodeSelector }}
index 58c6ff3..ef24704 100644 (file)
@@ -22,12 +22,10 @@ metadata:
   labels:
     {{- include "osm.labels" . | nindent 4 }}
 data:
-  OSMNBI_DATABASE_URI: "mongodb://mongodb-k8s:27017/?replicaSet=rs0"
   OSMNBI_MESSAGE_HOST: "kafka"
   OSMNBI_STORAGE_DRIVER: "mongo"
   OSMNBI_STORAGE_PATH: "/app/storage"
   OSMNBI_STORAGE_COLLECTION: "files"
-  OSMNBI_STORAGE_URI: "mongodb://mongodb-k8s:27017/?replicaSet=rs0"
   OSMNBI_LOG_LEVEL: {{ .Values.nbi.logLevel | default .Values.global.logLevel | default "INFO" }}
   OSMNBI_USER_MANAGEMENT: "True"
 {{- end }}
index 1fe1e6d..27b1d19 100644 (file)
@@ -47,7 +47,7 @@ spec:
       initContainers:
         - name: kafka-mongo-test
           image: alpine:latest
-          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongodb-k8s 27017); do sleep 3; done; exit 0"]
+          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 {{ .Values.global.db.mongo.mongoService }} 27017); do sleep 3; done; exit 0"]
       containers:
         - name: nbi
           securityContext:
@@ -83,6 +83,16 @@ spec:
                 secretKeyRef:
                   name: {{ include "osm.fullname" . }}-secret
                   key: OSM_DATABASE_COMMONKEY
+            - name: OSMNBI_DATABASE_URI
+              valueFrom:
+                secretKeyRef:
+                  name: {{ include "osm.fullname" . }}-secret
+                  key: OSM_DATABASE_URI
+            - name: OSMNBI_STORAGE_URI
+              valueFrom:
+                secretKeyRef:
+                  name: {{ include "osm.fullname" . }}-secret
+                  key: OSM_DATABASE_URI
           {{- end }}
       {{- with .Values.global.nodeSelector }}
       nodeSelector:
index 741d542..83c666d 100644 (file)
@@ -26,3 +26,4 @@ data:
   OSM_MYSQL_ROOT_PASSWORD: {{ randAlphaNum 32 | b64enc | quote }}
   OSM_KEYSTONE_DB_PASSWORD: {{ randAlphaNum 32 | b64enc | quote }}
   OSM_SERVICE_PASSWORD: {{ randAlphaNum 32 | b64enc | quote }}
+  OSM_DATABASE_URI: {{ include "osm.databaseUri" . }}
\ No newline at end of file
index ee557b7..be346a0 100644 (file)
@@ -23,7 +23,6 @@ metadata:
   labels:
     {{- include "osm.labels" . | nindent 4 }}
 data:
-  OSMPLA_DATABASE_URI: "mongodb://mongodb-k8s:27017/?replicaSet=rs0"
   OSMPLA_DATABASE_HOST: "mongo"
   OSMPLA_MESSAGE_HOST: "kafka"
   OSMPLA_GLOBAL_LOG_LEVEL: {{ .Values.pla.logLevel | default .Values.global.logLevel | default "INFO" }}
index d1a1f53..cb8d85b 100644 (file)
@@ -48,7 +48,7 @@ spec:
       initContainers:
         - name: kafka-mongo-test
           image: alpine:latest
-          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongodb-k8s 27017); do sleep 3; done; exit 0"]
+          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 {{ .Values.global.db.mongo.mongoService }} 27017); do sleep 3; done; exit 0"]
       containers:
         - name: pla
           securityContext:
@@ -66,6 +66,12 @@ spec:
           envFrom:
             - configMapRef:
                 name: {{ include "osm.fullname" . }}-pla-configmap
+          env:
+          - name: OSMPLA_DATABASE_URI
+            valueFrom:
+              secretKeyRef:
+                name: {{ include "osm.fullname" . }}-secret
+                key: OSM_DATABASE_URI
       {{- with .Values.global.nodeSelector }}
       nodeSelector:
         {{- toYaml . | nindent 8 }}
index 80dd856..8d899bc 100644 (file)
@@ -23,7 +23,6 @@ metadata:
   labels:
     {{- include "osm.labels" . | nindent 4 }}
 data:
-  OSMPOL_DATABASE_URI: "mongodb://mongodb-k8s:27017/?replicaSet=rs0"
   OSMPOL_MESSAGE_HOST: "kafka"
   OSMPOL_MESSAGE_PORT: "9092"
   OSMPOL_GLOBAL_LOG_LEVEL: {{ .Values.pol.logLevel | default .Values.global.logLevel | default "INFO" }}
index a8b97c8..313b4a6 100644 (file)
@@ -48,7 +48,7 @@ spec:
       initContainers:
         - name: kafka-mongo-test
           image: alpine:latest
-          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongodb-k8s 27017); do sleep 3; done; exit 0"]
+          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 {{ .Values.global.db.mongo.mongoService }} 27017); do sleep 3; done; exit 0"]
       containers:
         - name: pol
           securityContext:
@@ -79,6 +79,11 @@ spec:
                 secretKeyRef:
                   name: {{ include "osm.fullname" . }}-secret
                   key: OSM_DATABASE_COMMONKEY
+            - name: OSMPOL_DATABASE_URI
+              valueFrom:
+                secretKeyRef:
+                  name: {{ include "osm.fullname" . }}-secret
+                  key: OSM_DATABASE_URI
           {{- end }}
       {{- with .Values.global.nodeSelector }}
       nodeSelector:
index ca59835..378761d 100644 (file)
@@ -22,12 +22,10 @@ metadata:
   labels:
     {{- include "osm.labels" . | nindent 4 }}
 data:
-  OSMRO_DATABASE_URI: "mongodb://mongodb-k8s:27017/?replicaSet=rs0"
   OSMRO_MESSAGE_HOST: "kafka"
   OSMRO_STORAGE_DRIVER: "mongo"
   OSMRO_STORAGE_PATH: "/app/storage"
   OSMRO_STORAGE_COLLECTION: "files"
-  OSMRO_STORAGE_URI: "mongodb://mongodb-k8s:27017/?replicaSet=rs0"
   OSMRO_LOG_LEVEL: {{ .Values.ro.logLevel | default .Values.global.logLevel | default "INFO" }}
   OSMRO_PERIOD_REFRESH_ACTIVE: "-1"
 {{- end }}
index 6ae8f8a..902b5fd 100644 (file)
@@ -47,7 +47,7 @@ spec:
       initContainers:
         - name: kafka-mongo-test
           image: alpine:latest
-          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongodb-k8s 27017); do sleep 3; done; exit 0"]
+          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 {{ .Values.global.db.mongo.mongoService }} 27017); do sleep 3; done; exit 0"]
       containers:
         - name: ro
           securityContext:
@@ -78,6 +78,16 @@ spec:
                 secretKeyRef:
                   name: {{ include "osm.fullname" . }}-secret
                   key: OSM_DATABASE_COMMONKEY
+            - name: OSMRO_DATABASE_URI
+              valueFrom:
+                secretKeyRef:
+                  name: {{ include "osm.fullname" . }}-secret
+                  key: OSM_DATABASE_URI
+            - name: OSMRO_STORAGE_URI
+              valueFrom:
+                secretKeyRef:
+                  name: {{ include "osm.fullname" . }}-secret
+                  key: OSM_DATABASE_URI
           {{- end }}
       {{- with .Values.global.nodeSelector }}
       nodeSelector:
index 13d8d42..519f472 100644 (file)
@@ -42,6 +42,18 @@ global:
     # If not set and create is true, a name is generated using the fullname template
     name: ""
 
+  db:
+    mysql:
+      mysqlSecretName: mysql
+      mysqlSecretKey: mysql-root-password
+      mysqlService: mysql
+    mongo:
+      mongoService: mongodb-k8s
+      auth:
+        enabled: false
+        # secretName: mongodb-k8s
+        # secretKeyRootPassword: mongodb-root-password
+
   podAnnotations: {}
 
   podSecurityContext: