diff --git a/k8s/postgres.yaml b/k8s/postgres.yaml index cd6dcf5..936112a 100644 --- a/k8s/postgres.yaml +++ b/k8s/postgres.yaml @@ -1,3 +1,5 @@ +# The payment database should be created for you, if not here is the command: +# psql -c "create database payment;" -U postgres --- apiVersion: apps/v1 kind: StatefulSet @@ -18,7 +20,7 @@ spec: spec: containers: - name: postgres - image: "postgres:alpine" + image: postgres:15-alpine ports: - containerPort: 5432 protocol: TCP @@ -28,34 +30,44 @@ spec: secretKeyRef: name: postgres-creds key: password + - name: POSTGRES_USER + valueFrom: + configMapKeyRef: + name: postgres-config + key: postgres_user + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: postgres-config + key: postgres_db volumeMounts: - name: postgres-storage - mountPath: /var/lib/postgresql/data + mountPath: /var/lib/postgresql resources: limits: cpu: "0.50" memory: "128Mi" requests: - cpu: "0.25" + cpu: "0.25" memory: "64Mi" volumes: - name: postgres-storage persistentVolumeClaim: - claimName: postgres-data + claimName: postgres-pvc # emptyDir: {} --- apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: postgres-data + name: postgres-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi - storageClassName: "default" + # storageClassName: default --- apiVersion: v1 @@ -66,13 +78,21 @@ metadata: app: postgres spec: type: ClusterIP - ports: - - port: 5432 - targetPort: 5432 selector: app: postgres + ports: + - port: 5432 + targetPort: 5432 --- +apiVersion: v1 +kind: ConfigMap +metadata: + name: postgres-config +data: + postgres_user: postgres + postgres_db: payments +--- # This secret can also be created from the command line using environment variables # # export DATABASE_URI='postgresql://' @@ -82,10 +102,10 @@ spec: # --from-literal=password=$POSTGRES_PASSWORD # --from-literal=database_uri=$DATABASE_URI # -apiVersion: v1 kind: Secret +apiVersion: v1 metadata: name: postgres-creds data: - password: cG9zdGdyZXM= - database_uri: cG9zdGdyZXNxbCtwc3ljb3BnOi8vcG9zdGdyZXM6cG9zdGdyZXNAcG9zdGdyZXM6NTQzMi9wb3N0Z3Jlcw== \ No newline at end of file + database_uri: cG9zdGdyZXNxbCtwc3ljb3BnOi8vcG9zdGdyZXM6cG9zdGdyZXNAcG9zdGdyZXM6NTQzMi9wb3N0Z3Jlcw== + password: cG9zdGdyZXM= \ No newline at end of file