From fced87279881385c5bb6f467fc00f529186ece3c Mon Sep 17 00:00:00 2001
From: Nico Poegel <nico_benjamin.poegel@student.reutlingen-university.de>
Date: Tue, 14 Feb 2023 12:48:01 +0100
Subject: [PATCH] added secrets for myaktion-db

---
 ...oyment.yaml => myaktion-db-deployment.yaml} | 18 +++++++++---------
 .../deployment/myaktion-deployment.yaml        | 10 ++++++++++
 ...-db-storage.yml => myaktion-db-storage.yml} |  6 +++---
 .../templates/secret/myaktion-db-secret.yml    |  8 ++++++++
 ...rofile.yml => myaktion-service-profile.yml} |  2 +-
 5 files changed, 31 insertions(+), 13 deletions(-)
 rename helm-msa/templates/deployment/{myaktion-postgres-db-deployment.yaml => myaktion-db-deployment.yaml} (66%)
 rename helm-msa/templates/persistent_volume/{myaktion-postgres-db-storage.yml => myaktion-db-storage.yml} (79%)
 create mode 100644 helm-msa/templates/secret/myaktion-db-secret.yml
 rename helm-msa/templates/service_profile/{server-test-service-profile.yml => myaktion-service-profile.yml} (90%)

diff --git a/helm-msa/templates/deployment/myaktion-postgres-db-deployment.yaml b/helm-msa/templates/deployment/myaktion-db-deployment.yaml
similarity index 66%
rename from helm-msa/templates/deployment/myaktion-postgres-db-deployment.yaml
rename to helm-msa/templates/deployment/myaktion-db-deployment.yaml
index e9f698f..c191506 100644
--- a/helm-msa/templates/deployment/myaktion-postgres-db-deployment.yaml
+++ b/helm-msa/templates/deployment/myaktion-db-deployment.yaml
@@ -1,21 +1,21 @@
 apiVersion: apps/v1
 kind: Deployment
 metadata:
-  name: myaktion-postgres-db
+  name: myaktion-db
 spec:
   replicas: 1
   selector:
     matchLabels:
-      app: myaktion-postgres-db
+      app: myaktion-db
   template:
     metadata:
       annotations:
         linkerd.io/inject: enabled
       labels:
-        app: myaktion-postgres-db
+        app: myaktion-db
     spec:
       containers:
-      - name: myaktion-postgres-db
+      - name: myaktion-db
         image: postgres:14.5
         imagePullPolicy: IfNotPresent
         ports:
@@ -24,17 +24,17 @@ spec:
         - name: POSTGRES_USER
           valueFrom:
             secretKeyRef:
-              name: user-db-secret
+              name: myaktion-db-secret
               key: DATABASE_USER
         - name: POSTGRES_PASSWORD
           valueFrom:
             secretKeyRef:
-              name: user-db-secret
+              name: usmyaktioner-db-secret
               key: DATABASE_PASSWORD
         volumeMounts:
         - mountPath: /var/lib/postgresql/data
-          name: myaktion-postgres-db-pv-claim
+          name: myaktion-db-pv-claim
       volumes:
-      - name: myaktion-postgres-db-pv-claim
+      - name: myaktion-db-pv-claim
         persistentVolumeClaim:
-          claimName: myaktion-postgres-db-pv-claim
\ No newline at end of file
+          claimName: myaktion-db-pv-claim
\ No newline at end of file
diff --git a/helm-msa/templates/deployment/myaktion-deployment.yaml b/helm-msa/templates/deployment/myaktion-deployment.yaml
index 4af5908..6d1bf3b 100644
--- a/helm-msa/templates/deployment/myaktion-deployment.yaml
+++ b/helm-msa/templates/deployment/myaktion-deployment.yaml
@@ -27,3 +27,13 @@ spec:
           value: "http://myaktion-monitor-service/donations"
         - name: SPRING_REDIS_HOST
           value: "redis-service"
+        - name: SPRING_DATASOURCE_USERNAME
+          valueFrom:
+            secretKeyRef:
+              name: user-db-secret
+              key: DATABASE_USER
+        - name: SPRING_DATASOURCE_PASSWORD
+          valueFrom:
+            secretKeyRef:
+              name: user-db-secret
+              key: DATABASE_PASSWORD
diff --git a/helm-msa/templates/persistent_volume/myaktion-postgres-db-storage.yml b/helm-msa/templates/persistent_volume/myaktion-db-storage.yml
similarity index 79%
rename from helm-msa/templates/persistent_volume/myaktion-postgres-db-storage.yml
rename to helm-msa/templates/persistent_volume/myaktion-db-storage.yml
index 77dcd99..dde606e 100644
--- a/helm-msa/templates/persistent_volume/myaktion-postgres-db-storage.yml
+++ b/helm-msa/templates/persistent_volume/myaktion-db-storage.yml
@@ -1,7 +1,7 @@
 kind: PersistentVolume
 apiVersion: v1
 metadata:
-  name: myaktion-postgres-db-pv
+  name: myaktion-db-pv
   labels:
     type: local
 spec:
@@ -17,8 +17,8 @@ apiVersion: v1
 kind: PersistentVolumeClaim
 metadata:
   labels:
-    app: myaktion-postgres-db
-  name: myaktion-postgres-db-pv-claim
+    app: myaktion-db
+  name: myaktion-db-pv-claim
 spec:
   storageClassName: standard
   accessModes:
diff --git a/helm-msa/templates/secret/myaktion-db-secret.yml b/helm-msa/templates/secret/myaktion-db-secret.yml
new file mode 100644
index 0000000..a3cce28
--- /dev/null
+++ b/helm-msa/templates/secret/myaktion-db-secret.yml
@@ -0,0 +1,8 @@
+apiVersion: v1
+kind: Secret
+type: Opaque
+metadata:
+  name: myaktion-db-secret
+data:
+  DATABASE_USER: dXNlcjE=
+  DATABASE_PASSWORD: cGFzc3dvcmQx
\ No newline at end of file
diff --git a/helm-msa/templates/service_profile/server-test-service-profile.yml b/helm-msa/templates/service_profile/myaktion-service-profile.yml
similarity index 90%
rename from helm-msa/templates/service_profile/server-test-service-profile.yml
rename to helm-msa/templates/service_profile/myaktion-service-profile.yml
index 5dfc7b7..8c5eeac 100644
--- a/helm-msa/templates/service_profile/server-test-service-profile.yml
+++ b/helm-msa/templates/service_profile/myaktion-service-profile.yml
@@ -2,7 +2,7 @@ apiVersion: linkerd.io/v1alpha2
 kind: ServiceProfile
 metadata:
   creationTimestamp: null
-  name: server-test-service-profile
+  name: myaktion-service-profile
   namespace: default
 spec:
   routes:
-- 
GitLab