-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathpostgres.yml.j2
149 lines (147 loc) · 4.53 KB
/
postgres.yml.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: postgres-{{ postgres_version }}
{% if managed_platform %}
labels:
app-code: "{{ appcode }}"
service-phase: "{{ servicephase }}"
cost-center: "{{ costcenter }}"
{% endif %}
spec:
selector:
matchLabels:
component: postgres-{{ postgres_version }}
template:
metadata:
labels:
component: postgres-{{ postgres_version }}
{% if managed_platform %}
paas.redhat.com/appcode: {{ appcode }}
{% endif %}
spec:
containers:
- name: postgres
image: quay.io/sclorg/postgresql-{{ postgres_version }}-c9s
imagePullPolicy: IfNotPresent
env:
- name: POSTGRESQL_USER
valueFrom: {secretKeyRef: {name: postgres-secret, key: database-user}}
- name: POSTGRESQL_PASSWORD
valueFrom: {secretKeyRef: {name: postgres-secret, key: database-password}}
- name: POSTGRESQL_DATABASE
valueFrom: {secretKeyRef: {name: postgres-secret, key: database-name}}
# https://www.postgresql.org/docs/13/kernel-resources.html#LINUX-MEMORY-OVERCOMMIT
- name: PG_OOM_ADJUST_FILE
value: "/proc/self/oom_score_adj"
ports:
- containerPort: 5432
protocol: TCP
# increase shm size, default is 64M
# dashboard usage page requires around 100MB
volumeMounts:
- mountPath: /dev/shm
name: cache-volume
livenessProbe:
exec:
command:
- /usr/libexec/check-container
- --live
failureThreshold: 3
initialDelaySeconds: 120
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 10
# The readinessProbe wasn't reliable after we moved to automotive cluster
# but you can try again on MP+
# readinessProbe:
# exec:
# command:
# - /usr/libexec/check-container
resources:
requests:
memory: "{{ '2Gi' if project == 'packit--prod' else '256Mi' }}"
cpu: "30m"
limits:
# The shared_buffers & effective_cache_size values are set by the container
# based on this limit, so keep the limit reasonably high.
memory: "{{ '4Gi' if project == 'packit--prod' else '512Mi' }}"
# Not utilized most of the time, but useful during migrations and for some queries
cpu: "2"
volumeMounts:
- name: postgres-data
mountPath: /var/lib/pgsql/data
- name: postgres-config
mountPath: /opt/app-root/src/postgresql-cfg
readOnly: true
restartPolicy: Always
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: postgres-{{ postgres_version }}
- name: postgres-config
configMap:
name: postgres-config
- name: cache-volume
emptyDir:
medium: Memory
sizeLimit: 128Mi
replicas: 1
strategy:
type: Recreate
---
kind: ConfigMap
apiVersion: v1
metadata:
name: postgres-config
data:
packit.conf: |-
# The following values have been inspired by https://pgtune.leopard.in.ua
# Run psql -c 'SHOW ALL' in the pod's terminal to see all values.
# Default random_page_cost is 4.0. Use 1.1 for SSD storage.
random_page_cost = 1.1
# Default effective_io_concurrency is 1. Use hundreds for SSD storage.
effective_io_concurrency = 200
min_wal_size = 1GB
max_wal_size = 4GB
# (shared_buffers, effective_cache_size and max_connections can be set by env. vars
# https://github.com/sclorg/postgresql-container/tree/generated/13#environment-variables-and-volumes)
---
apiVersion: v1
kind: Service
metadata:
name: postgres
{% if managed_platform %}
labels:
paas.redhat.com/appcode: {{ appcode }}
{% endif %}
spec:
ports:
- name: postgres-port
port: 5432
targetPort: 5432
selector:
component: postgres-{{ postgres_version }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-{{ postgres_version }}
{% if managed_platform %}
labels:
paas.redhat.com/appcode: {{ appcode }}
annotations:
kubernetes.io/reclaimPolicy: Delete
{% endif %}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "{{ '8Gi' if deployment == 'prod' else '2Gi' }}"
{% if managed_platform %}
storageClassName: aws-ebs
{% endif %}