Feature 11032: Integration of OSM Helm Chart with different databases
Change-Id: I9ec6fc5f6ae42be8c506bff54302c3c1771bee7e
Signed-off-by: Luis Vega <lvega@whitestack.com>
diff --git a/installers/helm/osm/templates/_helpers.tpl b/installers/helm/osm/templates/_helpers.tpl
index 337073f..6599361 100644
--- a/installers/helm/osm/templates/_helpers.tpl
+++ b/installers/helm/osm/templates/_helpers.tpl
@@ -109,3 +109,16 @@
{{ 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 f076ad7..02a859a 100644
--- a/installers/helm/osm/templates/keystone/keystone-configmap.yaml
+++ b/installers/helm/osm/templates/keystone/keystone-configmap.yaml
@@ -22,5 +22,5 @@
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 e8b798e..ba7e05d 100644
--- a/installers/helm/osm/templates/keystone/keystone-deployment.yaml
+++ b/installers/helm/osm/templates/keystone/keystone-deployment.yaml
@@ -72,8 +72,8 @@
- 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 5cbc1cf..38f4d8e 100644
--- a/installers/helm/osm/templates/lcm/lcm-configmap.yaml
+++ b/installers/helm/osm/templates/lcm/lcm-configmap.yaml
@@ -23,12 +23,10 @@
{{- 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 b714f50..b28c286 100644
--- a/installers/helm/osm/templates/lcm/lcm-deployment.yaml
+++ b/installers/helm/osm/templates/lcm/lcm-deployment.yaml
@@ -47,7 +47,7 @@
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 @@
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 c6e506e..27b3b85 100644
--- a/installers/helm/osm/templates/mon/mon-configmap.yaml
+++ b/installers/helm/osm/templates/mon/mon-configmap.yaml
@@ -22,7 +22,6 @@
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 4fcbd58..4473ffa 100644
--- a/installers/helm/osm/templates/mon/mon-deployment.yaml
+++ b/installers/helm/osm/templates/mon/mon-deployment.yaml
@@ -47,7 +47,7 @@
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 @@
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 58c6ff3..ef24704 100644
--- a/installers/helm/osm/templates/nbi/nbi-configmap.yaml
+++ b/installers/helm/osm/templates/nbi/nbi-configmap.yaml
@@ -22,12 +22,10 @@
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 1fe1e6d..27b1d19 100644
--- a/installers/helm/osm/templates/nbi/nbi-deployment.yaml
+++ b/installers/helm/osm/templates/nbi/nbi-deployment.yaml
@@ -47,7 +47,7 @@
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 @@
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 741d542..83c666d 100644
--- a/installers/helm/osm/templates/osm-secret.yaml
+++ b/installers/helm/osm/templates/osm-secret.yaml
@@ -26,3 +26,4 @@
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 ee557b7..be346a0 100644
--- a/installers/helm/osm/templates/pla/pla-configmap.yaml
+++ b/installers/helm/osm/templates/pla/pla-configmap.yaml
@@ -23,7 +23,6 @@
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 d1a1f53..cb8d85b 100644
--- a/installers/helm/osm/templates/pla/pla-deployment.yaml
+++ b/installers/helm/osm/templates/pla/pla-deployment.yaml
@@ -48,7 +48,7 @@
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 @@
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 80dd856..8d899bc 100644
--- a/installers/helm/osm/templates/pol/pol-configmap.yaml
+++ b/installers/helm/osm/templates/pol/pol-configmap.yaml
@@ -23,7 +23,6 @@
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 a8b97c8..313b4a6 100644
--- a/installers/helm/osm/templates/pol/pol-deployment.yaml
+++ b/installers/helm/osm/templates/pol/pol-deployment.yaml
@@ -48,7 +48,7 @@
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 @@
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 ca59835..378761d 100644
--- a/installers/helm/osm/templates/ro/ro-configmap.yaml
+++ b/installers/helm/osm/templates/ro/ro-configmap.yaml
@@ -22,12 +22,10 @@
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 6ae8f8a..902b5fd 100644
--- a/installers/helm/osm/templates/ro/ro-deployment.yaml
+++ b/installers/helm/osm/templates/ro/ro-deployment.yaml
@@ -47,7 +47,7 @@
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 @@
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 13d8d42..519f472 100644
--- a/installers/helm/osm/values.yaml
+++ b/installers/helm/osm/values.yaml
@@ -42,6 +42,18 @@
# 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: