[GENERAL] Use readiness container v3.0.1
[oom.git] / kubernetes / cds / charts / cds-blueprints-processor / templates / deployment.yaml
index 749e9a4..6ffb59a 100755 (executable)
@@ -1,4 +1,5 @@
 # Copyright (c) 2019 IBM, Bell Canada
+# Copyright (c) 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.
@@ -12,7 +13,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" . }}
@@ -23,6 +24,9 @@ metadata:
     release: {{ include "common.release" . }}
     heritage: {{ .Release.Service }}
 spec:
+  selector:
+    matchLabels:
+      app: {{ include "common.name" . }}
   replicas: {{ .Values.replicaCount }}
   strategy:
     type: RollingUpdate
@@ -44,7 +48,31 @@ spec:
     spec:
       initContainers:
       - command:
-        - /root/ready.py
+        - sh
+        args:
+        - -c
+        - "cd /config-input && for PFILE in `ls -1 .`; do envsubst '${CDS_DB_USERNAME},${CDS_DB_PASSWORD},${SDNC_DB_USERNAME},${SDNC_DB_PASSWORD}' <${PFILE} >/config/${PFILE}; done"
+        env:
+        - name: CDS_DB_USERNAME
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cds-db-user-creds" "key" "login") | indent 10}}
+        - name: CDS_DB_PASSWORD
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cds-db-user-creds" "key" "password") | indent 10}}
+        - name: SDNC_DB_USERNAME
+          value: root
+        - name: SDNC_DB_PASSWORD
+          {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdnc-db-root-pass" "key" "password") | indent 10}}
+        volumeMounts:
+        - mountPath: /config-input/application.properties
+          name: {{ include "common.fullname" . }}-config
+          subPath: application.properties
+        - mountPath: /config
+          name: processed-config
+        image: "{{ .Values.global.envsubstImage }}"
+        imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+        name: {{ include "common.name" . }}-update-config
+
+      - command:
+        - /app/ready.py
         args:
         - --container-name
         - cds-db
@@ -58,9 +86,20 @@ spec:
             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: fix-permission
+        command:
+        - chown
+        - -R
+        - 1000:1000
+        - /opt/app/onap/blueprints/deploy
+        image: busybox:latest
+        imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+        volumeMounts:
+        - mountPath: {{ .Values.persistence.deployedBlueprint }}
+          name: {{ include "common.fullname" . }}-blueprints
       containers:
         - name: {{ include "common.name" . }}
           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
@@ -114,8 +153,11 @@ spec:
             name: localtime
             readOnly: true
           - mountPath: {{ .Values.config.appConfigDir }}/application.properties
-            name: {{ include "common.fullname" . }}-config
+            name: processed-config
             subPath: application.properties
+          - mountPath: {{ .Values.config.appConfigDir }}/error-messages_en.properties
+            name: {{ include "common.fullname" . }}-config
+            subPath: error-messages_en.properties
           - mountPath: {{ .Values.config.appConfigDir }}/logback.xml
             name: {{ include "common.fullname" . }}-config
             subPath: logback.xml
@@ -149,6 +191,8 @@ spec:
             items:
             - key: application.properties
               path: application.properties
+            - key: error-messages_en.properties
+              path: error-messages_en.properties
             - key: logback.xml
               path: logback.xml
             - key: hazelcast.yaml
@@ -158,5 +202,8 @@ spec:
         - name: {{ include "common.fullname" . }}-blueprints
           persistentVolumeClaim:
             claimName: {{ include "common.release" . }}-cds-blueprints
+        - name: processed-config
+          emptyDir:
+            medium: Memory
       imagePullSecrets:
       - name: "{{ include "common.namespace" . }}-docker-registry-key"