From: Luis Date: Thu, 21 Mar 2024 19:39:22 +0000 (+0000) Subject: Feature 11032: Integration of OSM Helm Chart with different databases X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=c5176c699ac8195e6cb9b7c040ab0e70f054721e;p=osm%2Fdevops.git Feature 11032: Integration of OSM Helm Chart with different databases Change-Id: I9ec6fc5f6ae42be8c506bff54302c3c1771bee7e Signed-off-by: Luis Vega --- diff --git a/installers/helm/osm/templates/_helpers.tpl b/installers/helm/osm/templates/_helpers.tpl index 337073fe..6599361f 100644 --- a/installers/helm/osm/templates/_helpers.tpl +++ b/installers/helm/osm/templates/_helpers.tpl @@ -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 }} diff --git a/installers/helm/osm/templates/keystone/keystone-configmap.yaml b/installers/helm/osm/templates/keystone/keystone-configmap.yaml index f076ad7f..02a859a6 100644 --- a/installers/helm/osm/templates/keystone/keystone-configmap.yaml +++ b/installers/helm/osm/templates/keystone/keystone-configmap.yaml @@ -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 diff --git a/installers/helm/osm/templates/keystone/keystone-deployment.yaml b/installers/helm/osm/templates/keystone/keystone-deployment.yaml index e8b798e3..ba7e05d3 100644 --- a/installers/helm/osm/templates/keystone/keystone-deployment.yaml +++ b/installers/helm/osm/templates/keystone/keystone-deployment.yaml @@ -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: diff --git a/installers/helm/osm/templates/lcm/lcm-configmap.yaml b/installers/helm/osm/templates/lcm/lcm-configmap.yaml index 5cbc1cf1..38f4d8ed 100644 --- a/installers/helm/osm/templates/lcm/lcm-configmap.yaml +++ b/installers/helm/osm/templates/lcm/lcm-configmap.yaml @@ -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 }}" diff --git a/installers/helm/osm/templates/lcm/lcm-deployment.yaml b/installers/helm/osm/templates/lcm/lcm-deployment.yaml index b714f505..b28c2863 100644 --- a/installers/helm/osm/templates/lcm/lcm-deployment.yaml +++ b/installers/helm/osm/templates/lcm/lcm-deployment.yaml @@ -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: diff --git a/installers/helm/osm/templates/mon/mon-configmap.yaml b/installers/helm/osm/templates/mon/mon-configmap.yaml index c6e506e5..27b3b859 100644 --- a/installers/helm/osm/templates/mon/mon-configmap.yaml +++ b/installers/helm/osm/templates/mon/mon-configmap.yaml @@ -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" }} diff --git a/installers/helm/osm/templates/mon/mon-deployment.yaml b/installers/helm/osm/templates/mon/mon-deployment.yaml index 4fcbd587..4473ffaf 100644 --- a/installers/helm/osm/templates/mon/mon-deployment.yaml +++ b/installers/helm/osm/templates/mon/mon-deployment.yaml @@ -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 }} diff --git a/installers/helm/osm/templates/nbi/nbi-configmap.yaml b/installers/helm/osm/templates/nbi/nbi-configmap.yaml index 58c6ff37..ef24704e 100644 --- a/installers/helm/osm/templates/nbi/nbi-configmap.yaml +++ b/installers/helm/osm/templates/nbi/nbi-configmap.yaml @@ -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 }} diff --git a/installers/helm/osm/templates/nbi/nbi-deployment.yaml b/installers/helm/osm/templates/nbi/nbi-deployment.yaml index 1fe1e6d4..27b1d191 100644 --- a/installers/helm/osm/templates/nbi/nbi-deployment.yaml +++ b/installers/helm/osm/templates/nbi/nbi-deployment.yaml @@ -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: diff --git a/installers/helm/osm/templates/osm-secret.yaml b/installers/helm/osm/templates/osm-secret.yaml index 741d5421..83c666d6 100644 --- a/installers/helm/osm/templates/osm-secret.yaml +++ b/installers/helm/osm/templates/osm-secret.yaml @@ -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 diff --git a/installers/helm/osm/templates/pla/pla-configmap.yaml b/installers/helm/osm/templates/pla/pla-configmap.yaml index ee557b72..be346a07 100644 --- a/installers/helm/osm/templates/pla/pla-configmap.yaml +++ b/installers/helm/osm/templates/pla/pla-configmap.yaml @@ -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" }} diff --git a/installers/helm/osm/templates/pla/pla-deployment.yaml b/installers/helm/osm/templates/pla/pla-deployment.yaml index d1a1f53a..cb8d85bf 100644 --- a/installers/helm/osm/templates/pla/pla-deployment.yaml +++ b/installers/helm/osm/templates/pla/pla-deployment.yaml @@ -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 }} diff --git a/installers/helm/osm/templates/pol/pol-configmap.yaml b/installers/helm/osm/templates/pol/pol-configmap.yaml index 80dd8565..8d899bcf 100644 --- a/installers/helm/osm/templates/pol/pol-configmap.yaml +++ b/installers/helm/osm/templates/pol/pol-configmap.yaml @@ -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" }} diff --git a/installers/helm/osm/templates/pol/pol-deployment.yaml b/installers/helm/osm/templates/pol/pol-deployment.yaml index a8b97c8a..313b4a67 100644 --- a/installers/helm/osm/templates/pol/pol-deployment.yaml +++ b/installers/helm/osm/templates/pol/pol-deployment.yaml @@ -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: diff --git a/installers/helm/osm/templates/ro/ro-configmap.yaml b/installers/helm/osm/templates/ro/ro-configmap.yaml index ca59835b..378761db 100644 --- a/installers/helm/osm/templates/ro/ro-configmap.yaml +++ b/installers/helm/osm/templates/ro/ro-configmap.yaml @@ -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 }} diff --git a/installers/helm/osm/templates/ro/ro-deployment.yaml b/installers/helm/osm/templates/ro/ro-deployment.yaml index 6ae8f8af..902b5fdd 100644 --- a/installers/helm/osm/templates/ro/ro-deployment.yaml +++ b/installers/helm/osm/templates/ro/ro-deployment.yaml @@ -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: diff --git a/installers/helm/osm/values.yaml b/installers/helm/osm/values.yaml index 13d8d426..519f4725 100644 --- a/installers/helm/osm/values.yaml +++ b/installers/helm/osm/values.yaml @@ -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: