Skip to content

Commit 7f5625f

Browse files
committed
K8SPG-708 replace ready/live probe http check with custom command
1 parent 2d3207f commit 7f5625f

2 files changed

Lines changed: 12 additions & 20 deletions

File tree

internal/patroni/reconcile.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ import (
88
"context"
99
"strings"
1010

11-
corev1 "k8s.io/api/core/v1"
12-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13-
"k8s.io/apimachinery/pkg/util/intstr"
14-
1511
"github.com/percona/percona-postgresql-operator/internal/initialize"
1612
"github.com/percona/percona-postgresql-operator/internal/naming"
1713
"github.com/percona/percona-postgresql-operator/internal/pgbackrest"
1814
"github.com/percona/percona-postgresql-operator/internal/pki"
1915
"github.com/percona/percona-postgresql-operator/internal/postgres"
2016
"github.com/percona/percona-postgresql-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
17+
corev1 "k8s.io/api/core/v1"
18+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2119
)
2220

2321
// ClusterBootstrapped returns a bool indicating whether or not Patroni has successfully
@@ -150,10 +148,8 @@ func instanceProbes(cluster *v1beta1.PostgresCluster, container *corev1.Containe
150148
// TODO(cbandy): Consider if a PreStop hook is necessary.
151149
container.LivenessProbe = probeTiming(cluster.Spec.Patroni)
152150
container.LivenessProbe.InitialDelaySeconds = 3
153-
container.LivenessProbe.HTTPGet = &corev1.HTTPGetAction{
154-
Path: "/liveness",
155-
Port: intstr.FromInt(int(*cluster.Spec.Patroni.Port)),
156-
Scheme: corev1.URISchemeHTTPS,
151+
container.LivenessProbe.Exec = &corev1.ExecAction{
152+
Command: []string{"/usr/local/bin/postgres-liveness-check.sh"},
157153
}
158154

159155
// Readiness is reflected in the controlling object's status (e.g. ReadyReplicas)
@@ -163,10 +159,8 @@ func instanceProbes(cluster *v1beta1.PostgresCluster, container *corev1.Containe
163159
// of the leader Pod in the leader Service.
164160
container.ReadinessProbe = probeTiming(cluster.Spec.Patroni)
165161
container.ReadinessProbe.InitialDelaySeconds = 3
166-
container.ReadinessProbe.HTTPGet = &corev1.HTTPGetAction{
167-
Path: "/readiness",
168-
Port: intstr.FromInt(int(*cluster.Spec.Patroni.Port)),
169-
Scheme: corev1.URISchemeHTTPS,
162+
container.ReadinessProbe.Exec = &corev1.ExecAction{
163+
Command: []string{"/usr/local/bin/postgres-readiness-check.sh"},
170164
}
171165
}
172166

internal/patroni/reconcile_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,22 +176,20 @@ containers:
176176
- name: PATRONICTL_CONFIG_FILE
177177
value: /etc/patroni
178178
livenessProbe:
179+
exec:
180+
command:
181+
- /usr/local/bin/postgres-liveness-check.sh
179182
failureThreshold: 3
180-
httpGet:
181-
path: /liveness
182-
port: 8008
183-
scheme: HTTPS
184183
initialDelaySeconds: 3
185184
periodSeconds: 10
186185
successThreshold: 1
187186
timeoutSeconds: 5
188187
name: database
189188
readinessProbe:
189+
exec:
190+
command:
191+
- /usr/local/bin/postgres-readiness-check.sh
190192
failureThreshold: 3
191-
httpGet:
192-
path: /readiness
193-
port: 8008
194-
scheme: HTTPS
195193
initialDelaySeconds: 3
196194
periodSeconds: 10
197195
successThreshold: 1

0 commit comments

Comments
 (0)