-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathpostgres.statefulset.yaml.j2
More file actions
126 lines (126 loc) · 4.81 KB
/
Copy pathpostgres.statefulset.yaml.j2
File metadata and controls
126 lines (126 loc) · 4.81 KB
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
# Postgres StatefulSet.
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: '{{ ansible_operator_meta.name }}-postgres-{{ supported_pg_version }}'
namespace: '{{ ansible_operator_meta.namespace }}'
labels:
app.kubernetes.io/name: 'postgres-{{ supported_pg_version }}'
app.kubernetes.io/instance: 'postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}'
app.kubernetes.io/component: 'database'
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
app.kubernetes.io/managed-by: 'eda-operator'
spec:
selector:
matchLabels:
app.kubernetes.io/name: 'postgres-{{ supported_pg_version }}'
app.kubernetes.io/instance: 'postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}'
app.kubernetes.io/component: 'database'
app.kubernetes.io/managed-by: 'eda-operator'
serviceName: '{{ ansible_operator_meta.name }}'
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app.kubernetes.io/name: 'postgres-{{ supported_pg_version }}'
app.kubernetes.io/instance: 'postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}'
app.kubernetes.io/component: 'database'
app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}'
app.kubernetes.io/managed-by: 'eda-operator'
spec:
securityContext:
{% if postgres_security_context_settings|length %}
{{ postgres_security_context_settings | to_nice_yaml | indent(8) }}
{% endif %}
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
{% if image_pull_secrets | length > 0 %}
imagePullSecrets:
{% for secret in image_pull_secrets %}
- name: {{ secret }}
{% endfor %}
{% endif %}
{% if combined_database.priority_class is defined %}
priorityClassName: '{{ combined_database.priority_class }}'
{% endif %}
{% if combined_database.node_selector %}
nodeSelector:
{{ combined_database.node_selector | indent(width=8) }}
{% endif %}
{% if combined_database.tolerations %}
tolerations:
{{ combined_database.tolerations | indent(width=8) }}
{% endif %}
containers:
- image: '{{ _postgres_image }}'
imagePullPolicy: '{{ image_pull_policy }}'
name: postgres
{% if combined_database.postgres_extra_args %}
args: {{ combined_database.postgres_extra_args }}
{% endif %}
readinessProbe:
exec:
command: ["bash", "-c", "pg_isready -p {{ eda_postgres_port | default('5432')}} -d $POSTGRESQL_DATABASE"]
initialDelaySeconds: 15
timeoutSeconds: 2
livenessProbe:
exec:
command: ["bash", "-c", "pg_isready -p {{ eda_postgres_port | default('5432')}} -d $POSTGRESQL_DATABASE"]
initialDelaySeconds: 45
timeoutSeconds: 2
env:
# For postgres_image based on rhel8/postgresql-13
- name: POSTGRESQL_DATABASE
valueFrom:
secretKeyRef:
name: '{{ __database_secret }}'
key: database
- name: POSTGRESQL_USER
valueFrom:
secretKeyRef:
name: '{{ __database_secret }}'
key: username
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
name: '{{ __database_secret }}'
key: password
# For postgres_image based on postgres
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
name: '{{ __database_secret }}'
key: database
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: '{{ __database_secret }}'
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: '{{ __database_secret }}'
key: password
ports:
- containerPort: {{ eda_postgres_port | default('5432')}}
name: postgres-{{ supported_pg_version }}
volumeMounts:
- name: postgres-{{ supported_pg_version }}
mountPath: '{{ combined_database.postgres_data_path | dirname }}'
subPath: '{{ combined_database.postgres_data_path | dirname | basename }}'
{% if combined_database.resource_requirements is defined %}
resources: {{ combined_database.resource_requirements }}
{% endif %}
volumeClaimTemplates:
- metadata:
name: postgres-{{ supported_pg_version }}
spec:
accessModes:
- ReadWriteOnce
{% if combined_database.postgres_storage_class is defined %}
storageClassName: '{{ combined_database.postgres_storage_class }}'
{% endif %}
resources: {{ combined_database.storage_requirements }}