[MODELING] Refactor Modeling environment variables
[oom.git] / kubernetes / modeling / charts / modeling-etsicatalog / templates / deployment.yaml
index 08d5e13..52d675a 100644 (file)
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-apiVersion: extensions/v1beta1
+apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: {{ include "common.fullname" . }}
@@ -20,33 +20,47 @@ metadata:
   labels:
     app: {{ include "common.name" . }}
     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
-    release: {{ .Release.Name }}
+    release: {{ include "common.release" . }}
     heritage: {{ .Release.Service }}
 spec:
+  selector:
+    matchLabels:
+      app: {{ include "common.name" . }}
   replicas: {{ .Values.replicaCount }}
   template:
     metadata:
       labels:
         app: {{ include "common.name" . }}
-        release: {{ .Release.Name }}
+        release: {{ include "common.release" . }}
       annotations:
         sidecar.istio.io/inject: "{{.Values.istioSidecar}}"
     spec:
       initContainers:
       - command:
-        - /root/ready.py
+        - /app/ready.py
         args:
-        - --container-name
-        - modeling-mariadb
+        - -j
+        - "{{ include "common.release" . }}-{{ include "common.name" . }}-config-job"
         env:
         - name: NAMESPACE
           valueFrom:
             fieldRef:
               apiVersion: v1
               fieldPath: metadata.namespace
-        image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
+        image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
-        name: {{ include "common.name" . }}-readiness
+        name: {{ include "common.name" . }}-job-readiness
+      {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for.msb ) | indent 6 | trim }}
+      - command:
+        - /bin/sh
+        - -c
+        - chown -R 1000:1000 /service/modeling/etsicatalog/static
+        image: "{{ include "common.repository" . }}/{{ .Values.initImage }}"
+        imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+        name: {{ include "common.name" . }}-init
+        volumeMounts:
+        - name: {{ include "common.fullname" . }}-etsicatalog
+          mountPath: /service/modeling/etsicatalog/static
       containers:
         - name: {{ include "common.name" . }}
           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
@@ -68,14 +82,20 @@ spec:
             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
             periodSeconds: {{ .Values.readiness.periodSeconds }}
           env:
-            - name: MSB_ADDR
-              value: "{{ .Values.global.config.msbServiceName }}:{{ .Values.global.config.msbPort }}"
-            - name: MYSQL_ADDR
-              value: "{{ .Values.global.config.dbServiceName }}:{{ .Values.global.config.dbPort }}"
-            - name: MYSQL_AUTH
-              value: "{{ .Values.global.config.dbUser }}:{{ .Values.global.config.mariadbRootPassword }}"
-            - name: REDIS_ADDR
-              value: "{{ .Values.global.config.redisServiceName }}:{{ .Values.global.config.redisPort }}"
+          - name: MSB_ADDR
+            value: "{{ .Values.config.msbProtocol }}://{{ .Values.config.msbServiceName }}:{{ .Values.config.msbPort }}"
+          - name: SSL_ENABLED
+            value: "{{ .Values.config.ssl_enabled }}"
+          - name: MSB_ENABLED
+            value: "{{ .Values.config.msb_enabled }}"
+          - name: DB_IP
+            value: "{{ include "common.mariadbService" . }}"
+          - name: DB_PORT
+            value: "{{ include "common.mariadbPort" . }}"
+          - name: DB_USER
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-db-secret" "key" "login") | indent 12 }}
+          - name: DB_PASSWD
+            {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-db-secret" "key" "password") | indent 12 }}
           volumeMounts:
           - name: {{ include "common.fullname" . }}-etsicatalog
             mountPath: /service/modeling/etsicatalog/static
@@ -130,7 +150,7 @@ spec:
 
         - name: {{ include "common.fullname" . }}-filebeat-conf
           configMap:
-            name: {{ .Release.Name }}-modeling-filebeat-configmap
+            name: {{ include "common.release" . }}-modeling-filebeat-configmap
         - name: {{ include "common.fullname" . }}-data-filebeat
           emptyDir: {}
       imagePullSecrets: