Skip to content

Commit

Permalink
operator: Add liveness probe to keepalived
Browse files Browse the repository at this point in the history
  • Loading branch information
ezekiel-alexrod committed Aug 9, 2023
1 parent 38a9f99 commit b7324ad
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@
[1.19](https://golang.org/doc/devel/release.html#go1.19.minor)
(PR[#4110](https://github.com/scality/metalk8s/pull/4110))

- Add liveness probe to `keepalived` pod
(PR[#4118](https://github.com/scality/metalk8s/pull/4118))

## Release 125.0.6 (In development)


Expand Down
1 change: 1 addition & 0 deletions images/metalk8s-keepalived/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ COPY --chown=keepalived:keepalived keepalived.conf.j2 /etc/keepalived/
COPY --chown=keepalived:keepalived check-get.sh /etc/keepalived/

COPY --chown=keepalived:keepalived generate-config.py /
COPY --chown=keepalived:keepalived liveness-probe.sh /
COPY --chown=keepalived:keepalived entrypoint.sh /

COPY --chown=keepalived:keepalived --from=build-step /keepalived /usr/sbin/
Expand Down
4 changes: 2 additions & 2 deletions images/metalk8s-keepalived/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This image is composed of several scripts.

## Entrypoint script

This script is the entrypoint for the container, it generate the
This script is the entrypoint for the container, it generates the
configuration and start keepalived process.

## Generate config script
Expand Down Expand Up @@ -39,7 +39,7 @@ addresses:
The check script is used by keepalived to check that the local node, where
the keepalived process is running, is ready to get some load.
It check that the local Ingress Controller is available
It checks that the local Ingress Controller is available.
## Dockerfile
Expand Down
6 changes: 6 additions & 0 deletions images/metalk8s-keepalived/liveness-probe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -xue -o pipefail

# Simple check to ensure that the config does not need to be updated
/generate-config.py --input /etc/keepalived/keepalived-input.yaml --template /etc/keepalived/keepalived.conf.j2 | diff -qw /etc/keepalived/keepalived.conf -
14 changes: 14 additions & 0 deletions operator/pkg/controller/virtualippool/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,20 @@ func (r *VirtualIPPoolReconciler) mutateDaemonSet(obj *appsv1.DaemonSet) error {
},
},
}
if container.LivenessProbe == nil {
container.LivenessProbe = &corev1.Probe{}
}
container.LivenessProbe.ProbeHandler = corev1.ProbeHandler{
Exec: &corev1.ExecAction{
Command: []string{
"/liveness-probe.sh",
},
},
}
container.LivenessProbe.InitialDelaySeconds = 10
container.LivenessProbe.PeriodSeconds = 30
container.LivenessProbe.TimeoutSeconds = 10
container.LivenessProbe.FailureThreshold = 1

return nil
}

0 comments on commit b7324ad

Please sign in to comment.