[PORTAL ] Non-root user DB access from WMS 70/114070/6
authorSandeep Shah <sandeeplinux1068@gmail.com>
Tue, 20 Oct 2020 21:11:21 +0000 (16:11 -0500)
committerSylvain Desbureaux <sylvain.desbureaux@orange.com>
Tue, 27 Oct 2020 07:40:12 +0000 (08:40 +0100)
Update portal-widget HELM charts to use non-
root user access to the portal mariadb
backend

Issue-ID: OOM-2601
Signed-off-by: SandeepLinux <ss048t@att.com>
Change-Id: I434ce85f1d0922d87fca35f692064a9b5e757954
Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com>
kubernetes/portal/components/portal-widget/resources/config/deliveries/properties/ONAPWIDGETMS/application.properties
kubernetes/portal/components/portal-widget/resources/config/deliveries/properties/ONAPWIDGETMS/application.yml
kubernetes/portal/components/portal-widget/templates/deployment.yaml
kubernetes/portal/components/portal-widget/templates/secret.yaml [new file with mode: 0644]
kubernetes/portal/components/portal-widget/values.yaml

index a53dd2e..f5a900e 100644 (file)
@@ -7,27 +7,26 @@ microservice.widget.location=/tmp
 \r
 ## App DB Properties\r
 spring.datasource.url=jdbc:mysql://portal-db:3306/portal\r
-spring.datasource.username=root\r
-spring.datasource.password=Aa123456\r
+spring.datasource.username=${PORTAL_DB_USER}\r
+spring.datasource.password=${PORTAL_DB_PASSWORD}\r
 spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect\r
 spring.database.driver.classname=org.mariadb.jdbc.Driver\r
 spring.jpa.show-sql=false\r
 spring.jpa.properties.hibernate.format_sql=false\r
 \r
 ## Basic Authentication Properties\r
-security.user.name=widget_user\r
-security.user.password=ENC(IjywcRnI9+nuVEh9+OFFiRWAjBT1n718)\r
+security.user.name=${WIDGET_USER}\r
+security.user.password=${WIDGET_PASSWORD}\r
 \r
 initialization.default.widgets=true\r
 initialization.widgetData.url=http://portal-app:{{.Values.global.portalPort}}/ONAPPORTAL/commonWidgets\r
 \r
 ## Account Basic Authentication Properties\r
-account.user.name=portal\r
-account.user.password=6APqvG4AU2rfLgCvMdySwQ==\r
+account.user.name=${ACC_USER}\r
+account.user.password=${ACC_PASSWORD}\r
 \r
 ## Certificate Properties\r
 #server.ssl.key-store=classpath:widget-keystore.p12\r
 #server.ssl.key-store-password=ENC(DiIYnAMab4u7rEW2yKhF9zBL00uU55q8)\r
 #server.ssl.keyStoreType=PKCS12\r
 #server.ssl.keyAlias=widget-microservice\r
-\r
index 4640a43..44d7fc4 100644 (file)
@@ -49,6 +49,40 @@ spec:
             fieldRef:
               apiVersion: v1
               fieldPath: metadata.namespace
+      - name: {{ include "common.name" . }}-portal-widget-config
+        image: "{{ .Values.global.envsubstImage }}"
+        imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+        command:
+        - sh
+        args:
+        - "-c"
+        - |
+          cd /config-input && \
+          for PFILE in `ls -1 *.*`
+          do
+            envsubst <${PFILE} >/config/${PFILE}
+            chmod 0755 /config/${PFILE}
+          done
+        env:
+          - name: PORTAL_DB_USER
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-backend-db" "key" "login") | indent 12 }}
+          - name: PORTAL_DB_PASSWORD
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-backend-db" "key" "password") | indent 12 }}
+          - name: WIDGET_USER
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-widget" "key" "login") | indent 12 }}
+          - name: WIDGET_PASSWORD
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-widget" "key" "password") | indent 12 }}
+          - name: ACC_USER
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-account" "key" "login") | indent 12 }}
+          - name: ACC_PASSWORD
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "portal-account" "key" "password") | indent 12 }}
+          - name: JASYPT_ENC_KEY
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "jasypt-enc-key" "key" "password") | indent 12 }}
+        volumeMounts:
+        - mountPath: /config-input
+          name: properties-onapwidgetms-scrubbed
+        - mountPath: /config
+          name: properties-onapwidgetms
       containers:
       - name: {{ include "common.name" . }}
         image: "{{ include "common.repository" . }}/{{ .Values.image }}"
@@ -94,6 +128,9 @@ spec:
           hostPath:
             path: /etc/localtime
         - name: properties-onapwidgetms
+          emptyDir:
+            medium: Memory
+        - name: properties-onapwidgetms-scrubbed
           configMap:
             name: {{ include "common.fullname" . }}-onapwidgetms
             defaultMode: 0755
diff --git a/kubernetes/portal/components/portal-widget/templates/secret.yaml b/kubernetes/portal/components/portal-widget/templates/secret.yaml
new file mode 100644 (file)
index 0000000..9a3f011
--- /dev/null
@@ -0,0 +1,17 @@
+{{/*
+# Copyright © 2020 Orange
+#
+# 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.secretFast" . }}
index 94da330..1367b25 100644 (file)
@@ -22,6 +22,46 @@ global:
   loggingRepository: docker.elastic.co
   loggingImage: beats/filebeat:5.5.0
   ubuntuInit: ubuntu-init:1.0.0
+  envsubstImage: dibi/envsubst
+
+################################################################
+# Secrets metaconfig
+#################################################################
+
+secrets:
+  - uid: portal-backend-db
+    type: basicAuth
+    externalSecret: '{{ tpl (default "" .Values.mariadb.config.backendDbExternalSecret) . }}'
+    login: '{{ .Values.mariadb.config.backendUserName }}'
+    password: '{{ .Values.mariadb.config.backendPassword }}'
+    passwordPolicy: required
+  - uid: portal-widget
+    type: basicAuth
+    externalSecret: '{{ tpl (default "" .Values.config.widgetCredsExternalSecret) . }}'
+    login: '{{ .Values.config.widgetUsername }}'
+    password: '{{ .Values.config.widgetPassword }}'
+    passwordPolicy: required
+  - uid: portal-account
+    type: basicAuth
+    externalSecret: '{{ tpl (default "" .Values.config.accountCredsExternalSecret) . }}'
+    login: '{{ .Values.config.accountUsername }}'
+    password: '{{ .Values.config.accountPassword }}'
+    passwordPolicy: required
+  - uid: jasypt-enc-key
+    type: password
+    externalSecret: '{{ .Values.config.jasyptEncKeyExternalSecret}}'
+    password: '{{ .Values.config.jasyptEncKey }}'
+    passwordPolicy: required
+
+config:
+  widgetUsername: widget_user
+  widgetPassword: widget_pass
+# widgetCredsExternalSecret: some secret
+  accountUsername: portal
+  accountPassword: portal
+# accountCredsExternalSecret: some secret
+  jasyptEncKey: EncryptionKey
+  # jasyptEncKeyExternalSecret: some secret
 
 #################################################################
 # Application configuration defaults.
@@ -56,6 +96,10 @@ readiness:
 mariadb:
   service:
     name: portal-db
+  config:
+    # backendDbExternalSecret: some secret
+    backendUserName: portal
+    backendPassword: portal
 
 service:
   type: ClusterIP