update postgres config
This commit is contained in:
parent
1fd3700c4c
commit
92f46ec75b
4 changed files with 174 additions and 143 deletions
|
|
@ -27,24 +27,61 @@ metadata:
|
|||
namespace: darkdork-dev
|
||||
data:
|
||||
postgresql.conf: |
|
||||
# DB Version: 17
|
||||
# OS Type: linux
|
||||
# DB Type: web
|
||||
# Total Memory (RAM): 8 GB
|
||||
# Connections num: 20
|
||||
# Data Storage: ssd
|
||||
|
||||
# connections settings
|
||||
listen_addresses = '*'
|
||||
max_connections = 20
|
||||
|
||||
# memory settings
|
||||
shared_buffers = 2GB
|
||||
effective_cache_size = 6GB
|
||||
maintenance_work_mem = 512MB
|
||||
checkpoint_completion_target = 0.9
|
||||
wal_buffers = 16MB
|
||||
default_statistics_target = 100
|
||||
random_page_cost = 1.1
|
||||
effective_io_concurrency = 200
|
||||
effective_cache_size = 3GB
|
||||
work_mem = 74898kB
|
||||
maintenance_work_mem = 512MB
|
||||
temp_buffers = 32MB
|
||||
huge_pages = off
|
||||
|
||||
# wal settings
|
||||
wal_buffers = 16MB
|
||||
min_wal_size = 1GB
|
||||
max_wal_size = 4GB
|
||||
---
|
||||
|
||||
# checkpoint settings
|
||||
checkpoint_completion_target = 0.9
|
||||
checkpoint_timeout = 15min
|
||||
checkpoint_flush_after = 0
|
||||
|
||||
# query planner settings
|
||||
default_statistics_target = 100
|
||||
random_page_cost = 1.1
|
||||
seq_page_cost = 1.0
|
||||
cpu_tuple_cost = 0.01
|
||||
cpu_index_tuple_cost = 0.005
|
||||
cpu_operator_cost = 0.0025
|
||||
effective_io_concurrency = 200
|
||||
|
||||
# write performance optimizations
|
||||
synchronous_commit = off
|
||||
commit_delay = 10000
|
||||
commit_siblings = 5
|
||||
|
||||
# bg writer settings
|
||||
bgwriter_delay = 50ms
|
||||
bgwriter_lru_maxpages = 1000
|
||||
bgwriter_lru_multiplier = 10.0
|
||||
|
||||
# paralel query settings
|
||||
max_worker_processes = 8
|
||||
max_parallel_workers = 8
|
||||
max_parallel_workers_per_gather = 2
|
||||
max_parallel_maintenance_workers = 2
|
||||
|
||||
# misc settings
|
||||
max_prepared_transactions = 0
|
||||
|
||||
# log settings
|
||||
# log_destination = 'stderr'
|
||||
# logging_collector = on
|
||||
# log_directory = 'pg_log'
|
||||
# log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
|
||||
# log_min_duration_statement = 1000
|
||||
# log_lock_waits = on
|
||||
# log_checkpoints = on
|
||||
15
manifests/postgres/pvc.yaml
Normal file
15
manifests/postgres/pvc.yaml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: postgres-pvc
|
||||
namespace: darkdork-dev
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
volumeName: pvc-43c3a05b-5556-4d7c-83e3-ee6436f1a48e
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
storageClassName: longhorn-ssd
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
|
|
@ -1,3 +1,18 @@
|
|||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres-headless
|
||||
namespace: darkdork-dev
|
||||
spec:
|
||||
clusterIP: None
|
||||
selector:
|
||||
app: postgres
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
name: postgres
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
|
|
@ -5,28 +20,10 @@ metadata:
|
|||
name: postgres
|
||||
namespace: darkdork-dev
|
||||
spec:
|
||||
selector:
|
||||
app: postgres
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
protocol: TCP
|
||||
clusterIP: None
|
||||
selector:
|
||||
app: postgres
|
||||
---
|
||||
# regular (non-headless) service for application access
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres-svc
|
||||
namespace: darkdork-dev
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
selector:
|
||||
app: postgres
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
name: postgres
|
||||
name: postgres
|
||||
type: ClusterIP
|
||||
---
|
||||
|
|
@ -7,12 +7,11 @@ metadata:
|
|||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
serviceName: postgres-headless
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: postgres
|
||||
updateStrategy:
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
|
|
@ -20,112 +19,95 @@ spec:
|
|||
spec:
|
||||
terminationGracePeriodSeconds: 30
|
||||
imagePullSecrets:
|
||||
- name: registry-credentials
|
||||
- name: registry-credentials
|
||||
securityContext:
|
||||
fsGroup: 1000
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
preferredDuringSchedulingIgnoredDuringExecution:
|
||||
- weight: 100
|
||||
podAffinityTerm:
|
||||
labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- postgres
|
||||
topologyKey: kubernetes.io/hostname
|
||||
containers:
|
||||
- name: postgres
|
||||
image: postgres:17-alpine
|
||||
imagePullPolicy: Always
|
||||
# securityContext:
|
||||
# runAsUser: 1001
|
||||
# runAsGroup: 1001
|
||||
# allowPrivilegeEscalation: false
|
||||
volumeMounts:
|
||||
- name: postgres-data-statefulset
|
||||
mountPath: /var/lib/postgresql/data
|
||||
subPath: pgdata # Using subPath to avoid permission issues
|
||||
- name: postgres-init-volume
|
||||
mountPath: /docker-entrypoint-initdb.d
|
||||
- name: postgres-config-volume
|
||||
mountPath: /etc/postgresql/postgresql.conf
|
||||
subPath: postgresql.conf
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
env:
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres
|
||||
key: postgres-password
|
||||
- name: DB_PASS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres
|
||||
key: postgres-password
|
||||
- name: PGDATA
|
||||
value: /var/lib/postgresql/data/pgdata
|
||||
- name: POSTGRES_INITDB_ARGS
|
||||
value: "-c config_file=/etc/postgresql/postgresql.conf"
|
||||
resources:
|
||||
requests:
|
||||
memory: "256Mi"
|
||||
cpu: "100m"
|
||||
limits:
|
||||
memory: "8Gi"
|
||||
cpu: "3000m"
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- pg_isready
|
||||
- -U
|
||||
- postgres
|
||||
- -d
|
||||
- pleroma
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 6
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- pg_isready
|
||||
- -U
|
||||
- postgres
|
||||
- -d
|
||||
- pleroma
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 3
|
||||
startupProbe:
|
||||
exec:
|
||||
command:
|
||||
- pg_isready
|
||||
- -U
|
||||
- postgres
|
||||
- -d
|
||||
- pleroma
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 12
|
||||
volumes:
|
||||
- name: postgres
|
||||
image: postgres:17-alpine
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
name: postgres
|
||||
resources:
|
||||
requests:
|
||||
memory: "3Gi"
|
||||
cpu: "1000m"
|
||||
limits:
|
||||
memory: "4Gi"
|
||||
cpu: "2000m"
|
||||
env:
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres
|
||||
key: postgres-password
|
||||
- name: DB_PASS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres
|
||||
key: postgres-password
|
||||
- name: PGDATA
|
||||
value: /var/lib/postgresql/data/pgdata
|
||||
volumeMounts:
|
||||
- name: postgres-storage
|
||||
mountPath: /var/lib/postgresql/data
|
||||
subPath: pgdata # Using subPath to avoid permission issues
|
||||
- name: dshm
|
||||
mountPath: /dev/shm
|
||||
- name: postgres-init-volume
|
||||
configMap:
|
||||
name: postgres-init
|
||||
defaultMode: 0755
|
||||
mountPath: /docker-entrypoint-initdb.d
|
||||
- name: postgres-config-volume
|
||||
configMap:
|
||||
name: postgres-config
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: postgres-data-statefulset
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
storageClassName: longhorn-ssd
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
mountPath: /etc/postgresql/postgresql.conf
|
||||
subPath: postgresql.conf
|
||||
command:
|
||||
- docker-entrypoint.sh
|
||||
- -c
|
||||
- config_file=/etc/postgresql/postgresql.conf
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- pg_isready
|
||||
- -U
|
||||
- postgres
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- pg_isready
|
||||
- -U
|
||||
- postgres
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 3
|
||||
startupProbe:
|
||||
exec:
|
||||
command:
|
||||
- pg_isready
|
||||
- -U
|
||||
- postgres
|
||||
- -d
|
||||
- pleroma
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 12
|
||||
volumes:
|
||||
- name: dshm
|
||||
emptyDir:
|
||||
medium: Memory
|
||||
sizeLimit: 2Gi
|
||||
- name: postgres-init-volume
|
||||
configMap:
|
||||
name: postgres-init
|
||||
defaultMode: 0755
|
||||
- name: postgres-config-volume
|
||||
configMap:
|
||||
name: postgres-config
|
||||
- name: postgres-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: postgres-pvc
|
||||
Loading…
Add table
Add a link
Reference in a new issue