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
|
namespace: darkdork-dev
|
||||||
data:
|
data:
|
||||||
postgresql.conf: |
|
postgresql.conf: |
|
||||||
# DB Version: 17
|
# connections settings
|
||||||
# OS Type: linux
|
listen_addresses = '*'
|
||||||
# DB Type: web
|
|
||||||
# Total Memory (RAM): 8 GB
|
|
||||||
# Connections num: 20
|
|
||||||
# Data Storage: ssd
|
|
||||||
|
|
||||||
max_connections = 20
|
max_connections = 20
|
||||||
|
|
||||||
|
# memory settings
|
||||||
shared_buffers = 2GB
|
shared_buffers = 2GB
|
||||||
effective_cache_size = 6GB
|
effective_cache_size = 3GB
|
||||||
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
|
|
||||||
work_mem = 74898kB
|
work_mem = 74898kB
|
||||||
|
maintenance_work_mem = 512MB
|
||||||
|
temp_buffers = 32MB
|
||||||
huge_pages = off
|
huge_pages = off
|
||||||
|
|
||||||
|
# wal settings
|
||||||
|
wal_buffers = 16MB
|
||||||
min_wal_size = 1GB
|
min_wal_size = 1GB
|
||||||
max_wal_size = 4GB
|
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
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
|
|
@ -5,28 +20,10 @@ metadata:
|
||||||
name: postgres
|
name: postgres
|
||||||
namespace: darkdork-dev
|
namespace: darkdork-dev
|
||||||
spec:
|
spec:
|
||||||
|
selector:
|
||||||
|
app: postgres
|
||||||
ports:
|
ports:
|
||||||
- port: 5432
|
- port: 5432
|
||||||
targetPort: 5432
|
targetPort: 5432
|
||||||
protocol: TCP
|
name: postgres
|
||||||
clusterIP: None
|
type: ClusterIP
|
||||||
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
|
|
||||||
type: ClusterIP
|
|
||||||
---
|
|
||||||
|
|
@ -7,12 +7,11 @@ metadata:
|
||||||
labels:
|
labels:
|
||||||
app: postgres
|
app: postgres
|
||||||
spec:
|
spec:
|
||||||
|
serviceName: postgres-headless
|
||||||
replicas: 1
|
replicas: 1
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: postgres
|
app: postgres
|
||||||
updateStrategy:
|
|
||||||
type: RollingUpdate
|
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
|
|
@ -20,112 +19,95 @@ spec:
|
||||||
spec:
|
spec:
|
||||||
terminationGracePeriodSeconds: 30
|
terminationGracePeriodSeconds: 30
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: registry-credentials
|
- name: registry-credentials
|
||||||
securityContext:
|
securityContext:
|
||||||
fsGroup: 1000
|
fsGroup: 1000
|
||||||
affinity:
|
|
||||||
podAntiAffinity:
|
|
||||||
preferredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
- weight: 100
|
|
||||||
podAffinityTerm:
|
|
||||||
labelSelector:
|
|
||||||
matchExpressions:
|
|
||||||
- key: app
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- postgres
|
|
||||||
topologyKey: kubernetes.io/hostname
|
|
||||||
containers:
|
containers:
|
||||||
- name: postgres
|
- name: postgres
|
||||||
image: postgres:17-alpine
|
image: postgres:17-alpine
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: IfNotPresent
|
||||||
# securityContext:
|
ports:
|
||||||
# runAsUser: 1001
|
- containerPort: 5432
|
||||||
# runAsGroup: 1001
|
name: postgres
|
||||||
# allowPrivilegeEscalation: false
|
resources:
|
||||||
volumeMounts:
|
requests:
|
||||||
- name: postgres-data-statefulset
|
memory: "3Gi"
|
||||||
mountPath: /var/lib/postgresql/data
|
cpu: "1000m"
|
||||||
subPath: pgdata # Using subPath to avoid permission issues
|
limits:
|
||||||
- name: postgres-init-volume
|
memory: "4Gi"
|
||||||
mountPath: /docker-entrypoint-initdb.d
|
cpu: "2000m"
|
||||||
- name: postgres-config-volume
|
env:
|
||||||
mountPath: /etc/postgresql/postgresql.conf
|
- name: POSTGRES_PASSWORD
|
||||||
subPath: postgresql.conf
|
valueFrom:
|
||||||
ports:
|
secretKeyRef:
|
||||||
- containerPort: 5432
|
name: postgres
|
||||||
env:
|
key: postgres-password
|
||||||
- name: POSTGRES_PASSWORD
|
- name: DB_PASS
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: postgres
|
name: postgres
|
||||||
key: postgres-password
|
key: postgres-password
|
||||||
- name: DB_PASS
|
- name: PGDATA
|
||||||
valueFrom:
|
value: /var/lib/postgresql/data/pgdata
|
||||||
secretKeyRef:
|
volumeMounts:
|
||||||
name: postgres
|
- name: postgres-storage
|
||||||
key: postgres-password
|
mountPath: /var/lib/postgresql/data
|
||||||
- name: PGDATA
|
subPath: pgdata # Using subPath to avoid permission issues
|
||||||
value: /var/lib/postgresql/data/pgdata
|
- name: dshm
|
||||||
- name: POSTGRES_INITDB_ARGS
|
mountPath: /dev/shm
|
||||||
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-init-volume
|
- name: postgres-init-volume
|
||||||
configMap:
|
mountPath: /docker-entrypoint-initdb.d
|
||||||
name: postgres-init
|
|
||||||
defaultMode: 0755
|
|
||||||
- name: postgres-config-volume
|
- name: postgres-config-volume
|
||||||
configMap:
|
mountPath: /etc/postgresql/postgresql.conf
|
||||||
name: postgres-config
|
subPath: postgresql.conf
|
||||||
volumeClaimTemplates:
|
command:
|
||||||
- metadata:
|
- docker-entrypoint.sh
|
||||||
name: postgres-data-statefulset
|
- -c
|
||||||
spec:
|
- config_file=/etc/postgresql/postgresql.conf
|
||||||
accessModes: ["ReadWriteOnce"]
|
livenessProbe:
|
||||||
storageClassName: longhorn-ssd
|
exec:
|
||||||
resources:
|
command:
|
||||||
requests:
|
- pg_isready
|
||||||
storage: 10Gi
|
- -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