[DMAAP] Don't hardcode mariadb-galera password 19/101419/5
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Fri, 7 Feb 2020 21:54:20 +0000 (22:54 +0100)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Fri, 28 Feb 2020 17:57:08 +0000 (17:57 +0000)
Let's use common secret template to generate user credentials for
DMAAP data router DB DB and depend on mariadb-galera to generate
secure enough root password.

Issue-ID: OOM-2287
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Change-Id: I82d22a2db2dc9fba655f99f837be689f4a32a871

kubernetes/dmaap/components/dmaap-dr-prov/resources/config/provserver.properties
kubernetes/dmaap/components/dmaap-dr-prov/templates/deployment.yaml
kubernetes/dmaap/components/dmaap-dr-prov/templates/secret.yaml [new file with mode: 0644]
kubernetes/dmaap/components/dmaap-dr-prov/values.yaml

index 34662ae..b672311 100644 (file)
@@ -7,9 +7,9 @@
 # * Licensed under the Apache License, Version 2.0 (the "License");
 # * you may not use this file except in compliance with the License.
 # * You may obtain a copy of the License at
-# * 
+# *
 #  *      http://www.apache.org/licenses/LICENSE-2.0
-# * 
+# *
 #  * Unless required by applicable law or agreed to in writing, software
 # * distributed under the License is distributed on an "AS IS" BASIS,
 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -40,9 +40,9 @@ org.onap.dmaap.datarouter.provserver.isaddressauthenabled = false
 
 # Database access
 org.onap.dmaap.datarouter.db.driver   = org.mariadb.jdbc.Driver
-org.onap.dmaap.datarouter.db.url      = jdbc:mariadb://{{.Values.config.dmaapDrDb.mariadbServiceName}}:{{.Values.config.dmaapDrDb.mariadbServicePort}}/datarouter
-org.onap.dmaap.datarouter.db.login    = datarouter
-org.onap.dmaap.datarouter.db.password = datarouter
+org.onap.dmaap.datarouter.db.url      = jdbc:mariadb://{{.Values.config.dmaapDrDb.mariadbServiceName}}:{{.Values.config.dmaapDrDb.mariadbServicePort}}/{{.Values.mariadb.config.mysqlDatabase}}
+org.onap.dmaap.datarouter.db.login    = ${DB_USERNAME}
+org.onap.dmaap.datarouter.db.password = ${DB_PASSWORD}
 
 # PROV - DEFAULT ENABLED TLS PROTOCOLS
 org.onap.dmaap.datarouter.provserver.https.include.protocols = TLSv1.1|TLSv1.2
@@ -55,4 +55,3 @@ org.onap.dmaap.datarouter.provserver.aaf.sub.type         = org.onap.dmaap-dr.su
 org.onap.dmaap.datarouter.provserver.aaf.instance         = legacy
 org.onap.dmaap.datarouter.provserver.aaf.action.publish   = publish
 org.onap.dmaap.datarouter.provserver.aaf.action.subscribe = subscribe
-
index d6257bb..104fcdc 100644 (file)
@@ -120,6 +120,11 @@ spec:
               port: {{ .Values.config.dmaapDrProv.internalPort }}
             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
             periodSeconds: {{ .Values.readiness.periodSeconds }}
+          env:
+          - name: DB_USERNAME
+            {{- include "common.secret.envFromSecret" (dict "global" . "uid" "dmaap-dr-db-user-secret" "key" "login") | indent 12 }}
+          - name: DB_PASSWORD
+            {{- include "common.secret.envFromSecret" (dict "global" . "uid" "dmaap-dr-db-user-secret" "key" "password") | indent 12 }}
           volumeMounts:
           {{- if .Values.global.aafEnabled }}
           - mountPath: {{ .Values.persistence.aafCredsPath }}
diff --git a/kubernetes/dmaap/components/dmaap-dr-prov/templates/secret.yaml b/kubernetes/dmaap/components/dmaap-dr-prov/templates/secret.yaml
new file mode 100644 (file)
index 0000000..dee311c
--- /dev/null
@@ -0,0 +1,15 @@
+# Copyright © 2020 Samsung Electronics
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+{{ include "common.secret" . }}
index 4dcd7c3..6165568 100644 (file)
@@ -19,6 +19,17 @@ global:
   nodePortPrefix: 302
   loggingDirectory: /opt/app/datartr/logs
 
+#################################################################
+# Secrets metaconfig
+#################################################################
+secrets:
+  - uid: dmaap-dr-db-user-secret
+    name: '{{ include "common.release" . }}-dmaap-dr-db-user-secret'
+    type: basicAuth
+    externalSecret: '{{ tpl (default "" .Values.config.dmaapDrDb.userCredentialsExternalSecret) . }}'
+    login: '{{ .Values.config.dmaapDrDb.userName }}'
+    password: '{{ .Values.config.dmaapDrDb.userPassword }}'
+
 #################################################################
 # Application configuration defaults.
 #################################################################
@@ -88,6 +99,9 @@ config:
     mariadbServiceName: dmaap-dr-db-svc
     mariadbServicePort: 3306
     mariadbContName: dmaap-dr-db
+    userName: datarouter
+#    userPassword: password
+#    userCredentialsExternalSecret: some secret
 
 # mariadb-galera configuration
 mariadb:
@@ -95,9 +109,7 @@ mariadb:
   nameOverride: dmaap-dr-db
   replicaCount: 2
   config:
-    mariadbRootPassword: datarouter
-    userName: datarouter
-    userPassword: datarouter
+    userCredentialsExternalSecret: '{{ include "common.release" . }}-dmaap-dr-db-user-secret'
     mysqlDatabase: datarouter
   service:
     name: dmaap-dr-db-svc
@@ -136,4 +148,4 @@ resources:
     requests:
       cpu: 1000m
       memory: 2Gi
-  unlimited: {}
\ No newline at end of file
+  unlimited: {}