Softwaredam can provide managed PostgreSQL. A managed postgres means that installation, uptime, backup, and recovery of the database is managed. A developer can directly use the database.
kubectl get secretsThe secret in your namespace contains all the necessary information in order for your application to access the database. It is a CNPG compatible secret, and contains host, port, dbname, username, password, and jdbc-uri.
#Pod example snippet.
...
spec:
containers:
- name: my-app
image: gitlab.com/myorg/my-app:v234
envFrom:
- secretRef:
name: <secret-name-with-postgres-refs>
...
env:
- name: DB_HOST
secretKeyRef:
name: postgres-secret # Name of your secret
key: host # key to get the right value
- name: DB_PORT
secretKeyRef:
name: postgres-secret
key: port
- name: DB_USER
valueFrom:
secretKeyRef:
name: postgres-secret
key: username
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: password
- name: DB_NAME
valueFrom:
secretKeyRef:
name: postgres-secret
key: dbname
Caution: You data will definitly be lost, if you don't know what you are doing!
It is not recommended to manually access the database, but in times of need you can deploy a pod which has access to the database.
# Attention!
# You should know what you are doing before deploying or using this pod.
# This pod can be mounted on a postgres secret which is useful for debugging purposes.
apiVersion: v1
kind: Pod
metadata:
name: dangerous-ad-hoc-psql
spec:
containers:
- name: psql
image: postgres:18.3
resources: {}
envFrom:
- secretRef:
name: <secret-name-with-postgres-refs>
command: [ "sleep", "infinity" ]
kubectl exec -it dangerous-ad-hoc-psql -- bashpsql. Examples with psql:# psql -h localhost
# \list
# \c db
# \dt