87fb1d6221
adds a new database named banking to the PostgreSQL initialization script and modifies the mount path for PostgreSQL data to improve compatibility with volume management practices.
107 lines
3.0 KiB
YAML
107 lines
3.0 KiB
YAML
kind: ConfigMap
|
|
apiVersion: v1
|
|
metadata:
|
|
name: shared-postgres
|
|
data:
|
|
DB_HOST: "postgres-postgresql"
|
|
DB_PORT: "5432"
|
|
DB_USER: "postgres"
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: postgres-init
|
|
data:
|
|
initdb.sh: |-
|
|
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
|
CREATE DATABASE schemas WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE accounting WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE banking WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE authz WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE company WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE consumer WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE employee WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE invoice WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE notification WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE salary WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE supplier WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE supplier_invoice WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE tax WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE time WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE dancefinder WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE hifi WITH OWNER postgres ENCODING utf8;
|
|
CREATE DATABASE sloth WITH OWNER postgres ENCODING utf8;
|
|
EOSQL
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: postgres
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: postgres
|
|
replicas: 1
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: postgres
|
|
spec:
|
|
containers:
|
|
- name: postgres
|
|
image: postgres:18.1-alpine@sha256:eca6fb2d91fda290eb8cfb8ba53dd0dcbf3508a08011e30adb039ea7c8e1e9f2
|
|
args:
|
|
- -c
|
|
- shared_buffers=384MB
|
|
- -c
|
|
- max_connections=300
|
|
imagePullPolicy: "IfNotPresent"
|
|
resources:
|
|
requests:
|
|
memory: 400Mi
|
|
limits:
|
|
memory: 600Mi
|
|
ports:
|
|
- containerPort: 5432
|
|
env:
|
|
- name: POSTGRES_DB
|
|
value: postgres
|
|
- name: POSTGRES_USER
|
|
value: postgres
|
|
- name: POSTGRES_PASSWORD
|
|
value: postgres
|
|
- name: LANG
|
|
value: sv_SE.utf8
|
|
- name: POSTGRES_INITDB_ARGS
|
|
value: --locale-provider=icu --icu-locale=sv-SE
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: /var/lib/postgresql
|
|
- mountPath: /docker-entrypoint-initdb.d/initdb.sh
|
|
name: initdb
|
|
subPath: initdb.sh
|
|
volumes:
|
|
- name: data
|
|
hostPath:
|
|
path: /data/postgres
|
|
- name: initdb
|
|
configMap:
|
|
name: postgres-init
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: postgres
|
|
labels:
|
|
app.kubernetes.io/name: postgres
|
|
spec:
|
|
ports:
|
|
- port: 5432
|
|
nodePort: 5432
|
|
selector:
|
|
app.kubernetes.io/name: postgres
|
|
type: NodePort
|