From daef17772d996e7da7f90b2b1b925b17dec876cf Mon Sep 17 00:00:00 2001
From: saiakhil46 <saiakhil46@gmail.com>
Date: Wed, 30 Nov 2022 17:37:18 +0530
Subject: [PATCH] added config.json file in certificatesign and updated
 templates

---
 kubernetes/ansible/roles/helm-deploy/tasks/main.yml |  8 ++++++++
 .../sunbird-RC/certificatesign/configs/config.json  | 11 +++++++++++
 .../certificatesign/templates/configmap.yaml        | 13 +++++++++++++
 .../certificatesign/templates/deployment.yaml       |  7 +++++++
 4 files changed, 39 insertions(+)
 create mode 100644 kubernetes/helm_charts/sunbird-RC/certificatesign/configs/config.json

diff --git a/kubernetes/ansible/roles/helm-deploy/tasks/main.yml b/kubernetes/ansible/roles/helm-deploy/tasks/main.yml
index a57c847b9..8f4881089 100644
--- a/kubernetes/ansible/roles/helm-deploy/tasks/main.yml
+++ b/kubernetes/ansible/roles/helm-deploy/tasks/main.yml
@@ -22,6 +22,14 @@
     - "{{ chart_path }}/schemas/*.json"
   when: release_name == "registry"
 
+- name: template config json
+  template:
+    src: "{{ item }}"
+    dest: "{{ item }}"
+  with_fileglob:
+    - "{{ chart_path }}/configs/*.json"
+  when: release_name == "certificatesign"
+
 - name: Load role to decrypt private keys, copy to private keys helm chart
   include_role:
     name: mount-keys
diff --git a/kubernetes/helm_charts/sunbird-RC/certificatesign/configs/config.json b/kubernetes/helm_charts/sunbird-RC/certificatesign/configs/config.json
new file mode 100644
index 000000000..0909ace25
--- /dev/null
+++ b/kubernetes/helm_charts/sunbird-RC/certificatesign/configs/config.json
@@ -0,0 +1,11 @@
+{
+  "issuers": {
+    "default": {
+      "publicKey": {{ CERTIFICATE_PUBLIC_KEY | default("") }},
+      "privateKey": {{ CERTIFICATE_PRIVATE_KEY | default("") }},
+      "signatureType": "RSA",
+      "verificationMethod": "did:india",
+      "$comment": "The above are test keys and it needs to be replaced before going to production"
+    }
+  }
+}
\ No newline at end of file
diff --git a/kubernetes/helm_charts/sunbird-RC/certificatesign/templates/configmap.yaml b/kubernetes/helm_charts/sunbird-RC/certificatesign/templates/configmap.yaml
index 05b928173..587c7e9df 100644
--- a/kubernetes/helm_charts/sunbird-RC/certificatesign/templates/configmap.yaml
+++ b/kubernetes/helm_charts/sunbird-RC/certificatesign/templates/configmap.yaml
@@ -9,3 +9,16 @@ metadata:
   creationTimestamp: null
   name: {{ .Chart.Name }}-config
   namespace: {{ .Values.namespace }}
+
+---
+
+{{- $configs := .Files.Glob "configs/*" }}
+{{ if $configs }}
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ .Chart.Name }}-conf
+  namespace: {{ .Values.namespace }}
+data:
+{{ (.Files.Glob "configs/*").AsConfig | indent 2 }}
+{{ end }}
\ No newline at end of file
diff --git a/kubernetes/helm_charts/sunbird-RC/certificatesign/templates/deployment.yaml b/kubernetes/helm_charts/sunbird-RC/certificatesign/templates/deployment.yaml
index 7fa927020..c271409ef 100644
--- a/kubernetes/helm_charts/sunbird-RC/certificatesign/templates/deployment.yaml
+++ b/kubernetes/helm_charts/sunbird-RC/certificatesign/templates/deployment.yaml
@@ -34,6 +34,13 @@ spec:
 {{ toYaml .Values.resources | indent 10 }}
         ports:
         - containerPort: {{ .Values.network.port }}
+        volumeMounts:
+        - name: {{ .Chart.Name }}-conf
+          mountPath: /etc/signer
+      volumes:
+      - name: {{ .Chart.Name }}-conf
+        configMap:
+          name: {{ .Chart.Name }}-conf
         
 
 ---
-- 
GitLab