Skip to content

Commit

Permalink
small change to postgres so that we can deploy to openshift
Browse files Browse the repository at this point in the history
  • Loading branch information
Carzgil committed Apr 30, 2024
1 parent 140220c commit b4a9582
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions k8s/postgres.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,7 +20,7 @@ spec:
spec:
containers:
- name: postgres
image: "postgres:alpine"
image: postgres:15-alpine
ports:
- containerPort: 5432
protocol: TCP
Expand All @@ -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
Expand All @@ -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://<place-url-to-database-here>'
Expand All @@ -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==
database_uri: cG9zdGdyZXNxbCtwc3ljb3BnOi8vcG9zdGdyZXM6cG9zdGdyZXNAcG9zdGdyZXM6NTQzMi9wb3N0Z3Jlcw==
password: cG9zdGdyZXM=

0 comments on commit b4a9582

Please sign in to comment.