[SO] Service mesh compatibility
[oom.git] / kubernetes / so / templates / deployment.yaml
index 83452cc..99a5eff 100755 (executable)
@@ -1,3 +1,4 @@
+{{/*
 # Copyright © 2018 AT&T USA
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,6 +12,7 @@
 # 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.
+*/}}
 apiVersion: apps/v1
 kind: Deployment
 metadata:
@@ -37,38 +39,30 @@ spec:
         app: {{ include "common.name" . }}
         release: {{ include "common.release" . }}
     spec:
-      initContainers: {{ include "so.certificate.container_importer" . | nindent 6 }}
-      - name: {{ include "common.name" . }}-readiness
-        command:
-        - /app/ready.py
-        args:
-        - --job-name
-        - {{ include "common.release" . }}-so-mariadb-config-job
-        env:
-        - name: NAMESPACE
-          valueFrom:
-            fieldRef:
-              apiVersion: v1
-              fieldPath: metadata.namespace
-        image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
-        imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
-        name: {{ include "common.name" . }}-readiness
+      initContainers:
+      {{ include "so.certificate.container_importer" . | indent 6 | trim }}
+      {{ include "common.readinessCheck.waitFor" . | indent 6 | trim }}
       containers:
       - name: {{ include "common.name" . }}
-        image: {{ include "common.repository" . }}/{{ .Values.image }}
-        resources:
-{{ include "common.resources" . | indent 12 }}
+        image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
+        resources: {{ include "common.resources" . | nindent 12 }}
+        {{- if .Values.global.aafEnabled }}
+        command:
+        - sh
+        args:
+        - -c
+        - |
+          export $(cat {{ .Values.soHelpers.certInitializer.credsPath }}/mycreds.prop | xargs -0)
+          {{- if .Values.global.security.aaf.enabled }}
+          export KEYSTORE_PASSWORD="${cadi_keystore_password_p12}"
+          {{- end }}
+          /app/start-app.sh
+        {{- end }}
         env:
         - name: DB_HOST
-          valueFrom:
-            secretKeyRef:
-              name: {{ include "common.release" . }}-so-db-secrets
-              key: mariadb.readwrite.host
+          value: {{ include "common.mariadbService" . }}
         - name: DB_PORT
-          valueFrom:
-            secretKeyRef:
-              name: {{ include "common.release" . }}-so-db-secrets
-              key: mariadb.readwrite.port
+          value: {{ include "common.mariadbPort" . | quote }}
         - name: DB_USERNAME
           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-user-creds" "key" "login") | indent 10 }}
         - name: DB_PASSWORD
@@ -77,53 +71,27 @@ spec:
           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-admin-creds" "key" "login") | indent 10 }}
         - name: DB_ADMIN_PASSWORD
           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-admin-creds" "key" "password") | indent 10 }}
-         {{- if eq .Values.global.security.aaf.enabled true }}
-        - name: TRUSTSTORE
-          value: /app/org.onap.so.trust.jks
-        - name: TRUSTSTORE_PASSWORD
-          valueFrom:
-            secretKeyRef:
-              name: {{ .Release.Name}}-so-client-certs-secret
-              key: trustStorePassword
-        - name: KEYSTORE
-          value: /app/org.onap.so.jks
-        - name: KEYSTORE_PASSWORD
-          valueFrom:
-            secretKeyRef:
-              name: {{ .Release.Name}}-so-client-certs-secret
-              key: keyStorePassword
-        {{- end }}
+        {{ include "so.certificates.env" . | indent 8 | trim }}
         envFrom:
         - configMapRef:
             name: {{ include "common.fullname" . }}-configmap
         imagePullPolicy:  {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
-        volumeMounts: {{ include "so.certificate.volume-mounts" . | nindent 8 }}
+        volumeMounts: {{ include "so.certificate.volumeMount" . | nindent 8 }}
         - name: logs
           mountPath: /app/logs
         - name: config
           mountPath: /app/config
           readOnly: true
         - name: {{ include "common.fullname" . }}-logs
-          mountPath: /var/log/onap
-{{ include "helpers.livenessProbe" .| indent 8 }}
+          mountPath: {{ .Values.log.path }}
+{{ include "so.helpers.livenessProbe" .| indent 8 }}
         ports:
         - containerPort: {{ index .Values.containerPort }}
-          name: {{ .Values.service.portName }}
+          name: {{ .Values.service.portName }}{{ if (include "common.needTLS" .) }}s{{ end }}
           protocol: TCP
       # Filebeat sidecar container
-      - name: {{ include "common.name" . }}-filebeat-onap
-        image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
-        imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
-        volumeMounts:
-        - name: {{ include "common.fullname" . }}-filebeat-conf
-          mountPath: /usr/share/filebeat/filebeat.yml
-          subPath: filebeat.yml
-        - name: {{ include "common.fullname" . }}-data-filebeat
-          mountPath: /usr/share/filebeat/data
-        - name: logs
-          mountPath: /var/log/onap/so
-        - name: {{ include "common.fullname" . }}-logs
-          mountPath: /var/log/onap
+      {{ include "common.log.sidecar" . | nindent 6 }}
+      serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
       volumes: {{ include "so.certificate.volumes" . | nindent 6 }}
       - name: logs
         emptyDir: {}
@@ -133,11 +101,7 @@ spec:
       - name: {{ include "common.fullname" . }}-log-conf
         configMap:
           name: {{ include "common.fullname" . }}-log
-      - name: {{ include "common.fullname" . }}-filebeat-conf
-        configMap:
-          name: {{ .Release.Name }}-so-filebeat-configmap
-      - name: {{ include "common.fullname" . }}-data-filebeat
-        emptyDir: {}
+      {{ include "common.log.volumes" . | nindent 6 }}
       - name:  {{ include "common.fullname" . }}-logs
         emptyDir: {}
       imagePullSecrets: