Skip to content

Commit ea8ce2d

Browse files
authored
Configure liveness and readiness probes for controller deployments (#508)
Part of aws-controllers-k8s/community#2012 This patch enhances controller availability by introducing liveness and readiness probes. By configuring /healthz and /readyz endpoints for all the controllers, the deployments can now effectively monitor their health status. While it's still a simple ping/pong healthz endpoints. We're laying the ground for future more complex healthz and readiness checks. Thinking something like checking that the CARM informer health... Signed-off-by: Amine Hilaly <[email protected]> By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 9c8a01f commit ea8ce2d

File tree

5 files changed

+49
-6
lines changed

5 files changed

+49
-6
lines changed

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.21
44

55
require (
66
github.com/aws-controllers-k8s/pkg v0.0.9
7-
github.com/aws-controllers-k8s/runtime v0.30.0
7+
github.com/aws-controllers-k8s/runtime v0.30.1-0.20240217174305-eb1315466efb
88
github.com/aws/aws-sdk-go v1.49.0
99
github.com/dlclark/regexp2 v1.10.0 // indirect
1010
// pin to v0.1.1 due to release problem with v0.1.2
@@ -20,7 +20,7 @@ require (
2020
github.com/stretchr/testify v1.8.4
2121
golang.org/x/mod v0.14.0
2222
k8s.io/apimachinery v0.29.0
23-
sigs.k8s.io/controller-runtime v0.17.0
23+
sigs.k8s.io/controller-runtime v0.17.2
2424
)
2525

2626
require (

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:l
7373
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
7474
github.com/aws-controllers-k8s/pkg v0.0.9 h1:f3ejpb6VKnt5CS8F/0+7dGH691eox0xT9mQ2PW4ZrR4=
7575
github.com/aws-controllers-k8s/pkg v0.0.9/go.mod h1:VvdjLWmR6IJ3KU8KByKiq/lJE8M+ur2piXysXKTGUS0=
76-
github.com/aws-controllers-k8s/runtime v0.30.0 h1:AibYRdi/7xUA3t8BA0u8g+J+OioaTAT6R4Vq8hxLiYw=
77-
github.com/aws-controllers-k8s/runtime v0.30.0/go.mod h1:Pv1ozlUaO11KO2mwPN/HzhAtZ70ZDE9UP24mjsbkul0=
76+
github.com/aws-controllers-k8s/runtime v0.30.1-0.20240217174305-eb1315466efb h1:Cdicq3reak7cXeuSYpJJEf8lyEHcE/ACnevC133vWGc=
77+
github.com/aws-controllers-k8s/runtime v0.30.1-0.20240217174305-eb1315466efb/go.mod h1:6qr9ULkjOHo0fTwEUkE+48IxHqNbHxvvf/9JzGoR8pM=
7878
github.com/aws/aws-sdk-go v1.49.0 h1:g9BkW1fo9GqKfwg2+zCD+TW/D36Ux+vtfJ8guF4AYmY=
7979
github.com/aws/aws-sdk-go v1.49.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
8080
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
@@ -1037,8 +1037,8 @@ rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
10371037
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.7/go.mod h1:PHgbrJT7lCHcxMU+mDHEm+nx46H4zuuHZkDP6icnhu0=
10381038
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
10391039
sigs.k8s.io/controller-runtime v0.8.0/go.mod h1:v9Lbj5oX443uR7GXYY46E0EE2o7k2YxQ58GxVNeXSW4=
1040-
sigs.k8s.io/controller-runtime v0.17.0 h1:fjJQf8Ukya+VjogLO6/bNX9HE6Y2xpsO5+fyS26ur/s=
1041-
sigs.k8s.io/controller-runtime v0.17.0/go.mod h1:+MngTvIQQQhfXtwfdGw/UOQ/aIaqsYywfCINOtwMO/s=
1040+
sigs.k8s.io/controller-runtime v0.17.2 h1:FwHwD1CTUemg0pW2otk7/U5/i5m2ymzvOXdbeGOUvw0=
1041+
sigs.k8s.io/controller-runtime v0.17.2/go.mod h1:+MngTvIQQQhfXtwfdGw/UOQ/aIaqsYywfCINOtwMO/s=
10421042
sigs.k8s.io/controller-tools v0.4.1/go.mod h1:G9rHdZMVlBDocIxGkK3jHLWqcTMNvveypYJwrvYKjWU=
10431043
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
10441044
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=

templates/cmd/controller/main.go.tpl

+19
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
1818
ctrlrt "sigs.k8s.io/controller-runtime"
1919
ctrlrtcache "sigs.k8s.io/controller-runtime/pkg/cache"
20+
ctrlrthealthz "sigs.k8s.io/controller-runtime/pkg/healthz"
2021
ctrlrtmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
2122
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
2223
ctrlrtwebhook "sigs.k8s.io/controller-runtime/pkg/webhook"
@@ -122,6 +123,9 @@ func main() {
122123
LeaderElection: ackCfg.EnableLeaderElection,
123124
LeaderElectionID: "ack-" + awsServiceAPIGroup,
124125
LeaderElectionNamespace: ackCfg.LeaderElectionNamespace,
126+
HealthProbeBindAddress: ackCfg.HealthzAddr,
127+
LivenessEndpointName: "/healthz",
128+
ReadinessEndpointName: "/readyz",
125129
})
126130
if err != nil {
127131
setupLog.Error(
@@ -172,6 +176,21 @@ func main() {
172176
os.Exit(1)
173177
}
174178

179+
if err = mgr.AddHealthzCheck("health", ctrlrthealthz.Ping); err != nil {
180+
setupLog.Error(
181+
err, "unable to set up health check",
182+
"aws.service", awsServiceAlias,
183+
)
184+
os.Exit(1)
185+
}
186+
if err = mgr.AddReadyzCheck("check", ctrlrthealthz.Ping); err != nil {
187+
setupLog.Error(
188+
err, "unable to set up ready check",
189+
"aws.service", awsServiceAlias,
190+
)
191+
os.Exit(1)
192+
}
193+
175194
setupLog.Info(
176195
"starting manager",
177196
"aws.service", awsServiceAlias,

templates/config/controller/deployment.yaml.tpl

+12
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ spec:
7979
capabilities:
8080
drop:
8181
- ALL
82+
livenessProbe:
83+
httpGet:
84+
path: /healthz
85+
port: 8081
86+
initialDelaySeconds: 15
87+
periodSeconds: 20
88+
readinessProbe:
89+
httpGet:
90+
path: /readyz
91+
port: 8081
92+
initialDelaySeconds: 5
93+
periodSeconds: 10
8294
securityContext:
8395
seccompProfile:
8496
type: RuntimeDefault

templates/helm/templates/deployment.yaml.tpl

+12
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ spec:
132132
capabilities:
133133
drop:
134134
- ALL
135+
livenessProbe:
136+
httpGet:
137+
path: /healthz
138+
port: 8081
139+
initialDelaySeconds: 15
140+
periodSeconds: 20
141+
readinessProbe:
142+
httpGet:
143+
path: /readyz
144+
port: 8081
145+
initialDelaySeconds: 5
146+
periodSeconds: 10
135147
securityContext:
136148
seccompProfile:
137149
type: RuntimeDefault

0 commit comments

Comments
 (0)