From cbd761d8f7935f985c90bc5717fe668598a069bb Mon Sep 17 00:00:00 2001
From: "Igor Zimovets (EPAM)" <igor_zimovets@epam.com>
Date: Fri, 11 Mar 2022 14:33:45 +0000
Subject: [PATCH] GONRG-4455: update helm charts

---
 .../templates/partition-secret-on-prem.yaml        | 14 ++++++++++++++
 .../configmap/templates/partition-variables.yml    |  9 +++++++--
 devops/gcp/configmap/values.yaml                   | 10 +++++++++-
 devops/gcp/deploy/templates/partition-deploy.yml   |  4 ++++
 devops/gcp/deploy/templates/service-account.yml    |  7 +++++++
 devops/gcp/deploy/values.yaml                      |  1 +
 6 files changed, 42 insertions(+), 3 deletions(-)
 create mode 100644 devops/gcp/configmap/templates/partition-secret-on-prem.yaml
 create mode 100644 devops/gcp/deploy/templates/service-account.yml

diff --git a/devops/gcp/configmap/templates/partition-secret-on-prem.yaml b/devops/gcp/configmap/templates/partition-secret-on-prem.yaml
new file mode 100644
index 000000000..ff2bcde69
--- /dev/null
+++ b/devops/gcp/configmap/templates/partition-secret-on-prem.yaml
@@ -0,0 +1,14 @@
+{{ if .Values.conf.on_prem_enabled }}
+apiVersion: v1
+kind: Secret
+metadata:
+  name:  "{{ .Values.conf.secret }}"
+  namespace: "{{ .Release.Namespace }}"
+  labels:
+    app: "{{ .Values.conf.app_name }}"
+type: Opaque
+data:
+  OSM_POSTGRES_PASSWORD: "{{ .Values.secret.osm_postgres_password }}"
+  OSM_POSTGRES_URL: "{{ .Values.secret.osm_postgres_url }}"
+  OSM_POSTGRES_USERNAME: "{{ .Values.secret.osm_postgres_username }}"
+{{ end }}
diff --git a/devops/gcp/configmap/templates/partition-variables.yml b/devops/gcp/configmap/templates/partition-variables.yml
index e76b8c0f5..3d2d9ee6a 100644
--- a/devops/gcp/configmap/templates/partition-variables.yml
+++ b/devops/gcp/configmap/templates/partition-variables.yml
@@ -6,9 +6,14 @@ metadata:
   name: "{{ .Values.conf.configmap }}"
   namespace: "{{ .Release.Namespace }}"
 data:
+  LOG_LEVEL: "{{ .Values.data.log_level }}"
+  SPRING_PROFILES_ACTIVE: "{{ .Values.data.spring_profiles_active }}"
+  {{- if .Values.conf.on_prem_enabled }}
+  PARTITION_PROPERTY_KIND: "{{ .Values.data.partition_property_kind }}"
+  PARTITION_NAMESPACE: "{{ .Values.data.partition_namespace }}"
+  {{- else }}
   GOOGLE_CLOUD_PROJECT: "{{ .Values.data.google_cloud_project }}"
   PARTITION_ADMIN_ACCOUNTS: "{{ .Values.data.partition_admin_accounts }}"
   GOOGLE_AUDIENCES: "{{ .Values.data.google_audiences }}"
-  LOG_LEVEL: "{{ .Values.data.log_level }}"
   SERVICE_ACCOUNT_TAIL: "{{ .Values.data.service_account_tail }}"
-  SPRING_PROFILES_ACTIVE: "{{ .Values.data.spring_profiles_active }}"
+  {{- end }}
diff --git a/devops/gcp/configmap/values.yaml b/devops/gcp/configmap/values.yaml
index 61d4a23e0..f73727afc 100644
--- a/devops/gcp/configmap/values.yaml
+++ b/devops/gcp/configmap/values.yaml
@@ -4,9 +4,17 @@ data:
   google_audiences: ""
   log_level: "INFO"
   service_account_tail: ".iam.gserviceaccount.com"
+  partition_property_kind: ""
+  partition_namespace: ""
   spring_profiles_active: "gcp"
-  
+
+secret:
+  osm_postgres_password: ""
+  osm_postgres_url: ""
+  osm_postgres_username: ""
 
 conf:
   configmap: "partition-config"
+  secret: "partition-secret"
   app_name: "partition"
+  on_prem_enabled: false
diff --git a/devops/gcp/deploy/templates/partition-deploy.yml b/devops/gcp/deploy/templates/partition-deploy.yml
index 11b90ef67..c30fb06d1 100644
--- a/devops/gcp/deploy/templates/partition-deploy.yml
+++ b/devops/gcp/deploy/templates/partition-deploy.yml
@@ -25,6 +25,10 @@ spec:
           envFrom:
           - configMapRef:
               name: "{{ .Values.conf.configmap }}"
+          {{- if .Values.conf.on_prem_enabled }}
+          - secretRef:
+              name: "{{ .Values.conf.secret }}"
+          {{- end }}
           securityContext:
             allowPrivilegeEscalation: false
             runAsUser: 0
diff --git a/devops/gcp/deploy/templates/service-account.yml b/devops/gcp/deploy/templates/service-account.yml
new file mode 100644
index 000000000..3fede170c
--- /dev/null
+++ b/devops/gcp/deploy/templates/service-account.yml
@@ -0,0 +1,7 @@
+{{- if .Values.conf.on_prem_enabled }}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: "{{ .Values.data.serviceAccountName }}"
+  namespace: "{{ .Release.Namespace }}"
+{{- end }}
diff --git a/devops/gcp/deploy/values.yaml b/devops/gcp/deploy/values.yaml
index 091a20db8..9f75d6d0d 100644
--- a/devops/gcp/deploy/values.yaml
+++ b/devops/gcp/deploy/values.yaml
@@ -13,6 +13,7 @@ data:
 
 conf:
   configmap: "partition-config"
+  secret: "partition-secret"
   app_name: "partition"
   on_prem_enabled: false
 
-- 
GitLab