[CLAMP] AAF certificate using certinializer
[oom.git] / kubernetes / clamp / components / clamp-backend / templates / deployment.yaml
@@ -39,7 +39,7 @@ spec:
         - /app/ready.py
         args:
         - --container-name
-        - mariadb
+        - clamp-mariadb
         env:
         - name: NAMESPACE
           valueFrom:
@@ -49,6 +49,7 @@ spec:
         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
         name: {{ include "common.name" . }}-readiness
+{{ include "common.certInitializer.initContainer" . | indent 6 }}
       containers:
         # side car containers
         {{ if .Values.global.centralizedLoggingEnabled }}{{ include "common.log.sidecar" . | nindent 8 }}{{ end }}
@@ -56,8 +57,19 @@ spec:
         - name: {{ include "common.name" . }}
           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+          {{- if .Values.global.aafEnabled }}
+          command:
+          - sh
+          workingDir: "/opt/clamp/"
           args:
-            - ""
+          - -c
+          - |
+            export $(grep '^cadi_' {{ .Values.certInitializer.credsPath }}/org.onap.clamp.cred.props | xargs -0)
+            java -Djava.security.egd=file:/dev/./urandom -Xms256m -Xmx1g -jar ./app.jar
+          {{- else }}
+          args:
+          - ""
+          {{- end }}
           ports:
           - containerPort: {{ .Values.service.internalPort }}
           # disable liveness probe when breakpoints set in debugger
@@ -74,12 +86,15 @@ spec:
               port: {{ .Values.service.internalPort }}
             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
             periodSeconds: {{ .Values.readiness.periodSeconds }}
-          volumeMounts:
+          volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 10 }}
           - name: logs
             mountPath: {{ .Values.log.path }}
           - mountPath: /opt/clamp/sdc-controllers-config.json
             name: {{ include "common.fullname" . }}-config
             subPath: sdc-controllers-config.json
+          - mountPath: /opt/clamp/application.properties
+            name: {{ include "common.fullname" . }}-config
+            subPath: application.properties
           env:
           - name: MYSQL_USER
             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
@@ -87,11 +102,6 @@ spec:
             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
           - name: MYSQL_DATABASE
             value: {{ tpl .Values.db.databaseName .}}
-          - name: SPRING_APPLICATION_JSON
-            valueFrom:
-              configMapKeyRef:
-                name: {{ template "common.fullname" . }}
-                key: spring_application_json
           resources:
 {{ include "common.resources" . | indent 12 }}
         {{- if .Values.nodeSelector }}
@@ -102,13 +112,15 @@ spec:
         affinity:
 {{ toYaml .Values.affinity | indent 10 }}
         {{- end }}
-      volumes:
+      volumes: {{ include "common.certInitializer.volumes" . | nindent 8 }}
         - name: {{ include "common.fullname" . }}-config
           configMap:
             name: {{ include "common.fullname" . }}
             items:
             - key: sdc-controllers-config.json
               path: sdc-controllers-config.json
+            - key: application.properties
+              path: application.properties
         - name:  logs
           emptyDir: {}
         {{ if .Values.global.centralizedLoggingEnabled }}{{ include "common.log.volumes" . | nindent 8 }}{{ end }}