revised postgres db doc

This commit is contained in:
Clemens 2024-02-27 11:32:17 +01:00
parent 26ca2acb6b
commit 4f071f14c8

View file

@ -278,17 +278,78 @@ spec:
If your application needs a database, we often use postgres: If your application needs a database, we often use postgres:
```clojure ```clojure
(deftest should-generate-deployment (cut/generate-deployment {:postgres-image "postgres:16"})
(is (= [{:image "postgres:16" ```
:name "postgresql"
yields:
```clojure
{:apiVersion "apps/v1",
:kind "Deployment",
...
:spec
{:selector {:matchLabels {:app "postgresql"}},
:strategy {:type "Recreate"},
:template
{:metadata {:labels {:app "postgresql"}},
:spec
{:containers
[{:image "postgres:16",
:name "postgresql",
:env :env
[{:name "POSTGRES_USER" ...} [{:name "POSTGRES_USER", :valueFrom {:secretKeyRef {:name "postgres-secret", :key "postgres-user"}}}
{:name "POSTGRES_PASSWORD" ...} {:name "POSTGRES_PASSWORD", :valueFrom {:secretKeyRef {:name "postgres-secret", :key "postgres-password"}}}
{:name "POSTGRES_DB" ...}] {:name "POSTGRES_DB", :valueFrom {:configMapKeyRef {:name "postgres-config", :key "postgres-db"}}}],
:volumeMounts [{:name "postgre-data-volume" ...}]}] :ports [{:containerPort 5432, :name "postgresql"}],
(get-in (cut/generate-deployment :volumeMounts
{:postgres-image "postgres:16"}) [...],
[:spec :template :spec :containers])))) :volumes
[...]}}}}
```
which can be rendered to:
```yaml
apiVersion: apps/v1
kind: Deployment
...
spec:
selector:
matchLabels:
app: postgresql
strategy:
type: Recreate
template:
metadata:
labels:
app: postgresql
spec:
containers:
- image: postgres:16
name: postgresql
env:
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: postgres-secret
key: postgres-user
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: postgres-password
- name: POSTGRES_DB
valueFrom:
configMapKeyRef:
name: postgres-config
key: postgres-db
ports:
- containerPort: 5432
name: postgresql
volumeMounts:
...
volumes:
...
``` ```
We optimized our db installation to run between 2Gb anf 16Gb Ram usage. We optimized our db installation to run between 2Gb anf 16Gb Ram usage.