-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperator.yaml
More file actions
211 lines (211 loc) · 6.71 KB
/
operator.yaml
File metadata and controls
211 lines (211 loc) · 6.71 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# postgres-restore-operator install manifest
# CRDs are not included — generate them with: cargo run --bin gen-crds
---
apiVersion: v1
kind: Namespace
metadata:
name: pgro-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: postgres-restore-operator
namespace: pgro-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: postgres-restore-operator
rules:
# CRD access
- apiGroups: ["pgro.bes.au"]
resources:
- postgresphysicalreplicas
- postgresphysicalreplicas/status
- postgresphysicalrestores
- postgresphysicalrestores/status
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
# Secrets (kopia credentials, analytics credentials)
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
# Services (stable service per replica)
- apiGroups: [""]
resources: ["services"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
# PVCs (restore data volumes)
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
# Jobs (restore jobs)
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
# Deployments (postgres instances)
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
# Pods (reading Job pod termination messages, self-annotation, orphan cleanup)
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "patch", "delete"]
# Pod port-forward (overlay FDW reconciliation)
- apiGroups: [""]
resources: ["pods/portforward"]
verbs: ["create"]
# Events (events.k8s.io/v1)
- apiGroups: ["events.k8s.io"]
resources: ["events"]
verbs: ["create", "patch"]
# CNPG Clusters (overlay database)
- apiGroups: ["postgresql.cnpg.io"]
resources: ["clusters"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
# CNPG Image Catalogs (PG version discovery)
- apiGroups: ["postgresql.cnpg.io"]
resources: ["clusterimagecatalogs", "imagecatalogs"]
verbs: ["get", "list"]
# Leader election
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: postgres-restore-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: postgres-restore-operator
subjects:
- kind: ServiceAccount
name: postgres-restore-operator
namespace: pgro-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: postgres-restore-operator-config
namespace: pgro-system
rules:
- apiGroups: [""]
resources: ["configmaps"]
resourceNames: ["postgres-restore-operator-config"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: postgres-restore-operator-config
namespace: pgro-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: postgres-restore-operator-config
subjects:
- kind: ServiceAccount
name: postgres-restore-operator
namespace: pgro-system
---
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-restore-operator-config
namespace: pgro-system
data: {}
---
apiVersion: v1
kind: Service
metadata:
name: postgres-restore-operator
namespace: pgro-system
labels:
app.kubernetes.io/name: postgres-restore-operator
app.kubernetes.io/component: controller
annotations:
prometheus.io/port: "8080"
prometheus.io/scheme: http
prometheus.io/scrape: "true"
spec:
ports:
- name: http
port: 8080
targetPort: http
selector:
app.kubernetes.io/name: postgres-restore-operator
app.kubernetes.io/component: controller
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-restore-operator
namespace: pgro-system
labels:
app.kubernetes.io/name: postgres-restore-operator
app.kubernetes.io/component: controller
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: postgres-restore-operator
app.kubernetes.io/component: controller
template:
metadata:
labels:
app.kubernetes.io/name: postgres-restore-operator
app.kubernetes.io/component: controller
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
spec:
serviceAccountName: postgres-restore-operator
securityContext:
runAsNonRoot: true
runAsUser: 65534
runAsGroup: 65534
fsGroup: 65534
containers:
- name: controller
image: ghcr.io/beyondessential/postgres-restore-operator:latest
env:
# - name: RUST_LOG
# value: "info,tower_http=debug"
- name: METRICS_ADDR
value: "[::]:8080"
- name: OPERATOR_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: OPERATOR_SERVICE_NAME
value: postgres-restore-operator
ports:
- name: http
containerPort: 8080
protocol: TCP
readinessProbe:
httpGet:
path: /readyz
port: http
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
httpGet:
path: /livez
port: http
initialDelaySeconds: 15
periodSeconds: 20
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 500m
memory: 256Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]