Skip to content

Instantly share code, notes, and snippets.

@filipevarjao
Last active September 21, 2024 19:19
Show Gist options
  • Save filipevarjao/ed3dfefd086d6f178c4f9efeb8275082 to your computer and use it in GitHub Desktop.
Save filipevarjao/ed3dfefd086d6f178c4f9efeb8275082 to your computer and use it in GitHub Desktop.
version: "3"
services:
db:
image: "postgres"
container_name: "postgres_db"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=db
ports:
- "54320:5432"
volumes:
- ./postgres-data:/var/lib/postgresql/data
-------------------------------------------
apiVersion: v1
kind: Pod
metadata:
name: postgres
spec:
containers:
- name: container-postgres
image: postgres
ports:
- containerPort: 5432
env:
- name: POSTGRES_USER
value: "postgres"
- name: POSTGRES_PASSWORD
value: "postgres"
- name: POSTGRES_DB
value: "db"
-----------------------------------
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: stateful-postgres
spec:
serviceName: "db"
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: container-postgres
image: postgres
ports:
- containerPort: 5432
env:
- name: POSTGRES_USER
value: "postgres"
- name: POSTGRES_PASSWORD
value: "postgres"
- name: POSTGRES_DB
value: "db"
volumeMounts:
- name: volume-postgres
mountPath: /var/lib/postgresql/data
volumes:
- name: volume-postgres
persistentVolumeClaim:
claimName: config-postgres
---------------------------------------------------
apiVersion: v1
kind: Service
metadata:
name: db
spec:
ports:
- port: 5432
name: postgres
clusterIP: None
selector:
app: postgres
---------------------------------------------------
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: config-postgres
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment