Skip to content

Commit 94898c5

Browse files
committed
Add a readiness probe for the pgAdmin pod
This will ensure that the pod is only ready if pgAdmin is accessible on port 5050 at the path `/login`. The basic pgadmin test is updated to ensure that probe exists on the pgadmin pod. The tests already check for readiness on the pod.
1 parent 98ea894 commit 94898c5

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

internal/controller/standalone_pgadmin/pod.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,26 @@ func pod(
154154
},
155155
},
156156
}
157+
158+
// Creating a readiness probe that will check that the pgAdmin `/login`
159+
// endpoint is reachable at the specified port
160+
readinessProbe := &corev1.Probe{
161+
ProbeHandler: corev1.ProbeHandler{
162+
HTTPGet: &corev1.HTTPGetAction{
163+
Port: *initialize.IntOrStringInt32(pgAdminPort),
164+
Path: "/login",
165+
Scheme: corev1.URISchemeHTTP,
166+
},
167+
},
168+
}
169+
gunicornData := inConfigMap.Data[gunicornConfigKey]
170+
// Check the configmap to see if we think TLS is enabled
171+
// If so, update the readiness check scheme to HTTPS
172+
if strings.Contains(gunicornData, "certfile") && strings.Contains(gunicornData, "keyfile") {
173+
readinessProbe.ProbeHandler.HTTPGet.Scheme = corev1.URISchemeHTTPS
174+
}
175+
container.ReadinessProbe = readinessProbe
176+
157177
startup := corev1.Container{
158178
Name: naming.ContainerPGAdminStartup,
159179
Command: startupCommand(),

internal/controller/standalone_pgadmin/pod_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ containers:
111111
- containerPort: 5050
112112
name: pgadmin
113113
protocol: TCP
114+
readinessProbe:
115+
httpGet:
116+
path: /login
117+
port: 5050
118+
scheme: HTTP
114119
resources: {}
115120
securityContext:
116121
allowPrivilegeEscalation: false
@@ -291,6 +296,11 @@ containers:
291296
- containerPort: 5050
292297
name: pgadmin
293298
protocol: TCP
299+
readinessProbe:
300+
httpGet:
301+
path: /login
302+
port: 5050
303+
scheme: HTTP
294304
resources:
295305
requests:
296306
cpu: 100m

testing/kuttl/e2e/standalone-pgadmin/files/00-pgadmin-check.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ metadata:
2626
postgres-operator.crunchydata.com/data: pgadmin
2727
postgres-operator.crunchydata.com/role: pgadmin
2828
postgres-operator.crunchydata.com/pgadmin: pgadmin
29+
spec:
30+
containers:
31+
- name: pgadmin
32+
readinessProbe:
33+
httpGet:
34+
path: /login
35+
port: 5050
36+
scheme: HTTP
2937
status:
3038
containerStatuses:
3139
- name: pgadmin

0 commit comments

Comments
 (0)