Skip to content

Commit

Permalink
Adjust health check to return 503 if all backends are down
Browse files Browse the repository at this point in the history
If all backends are down, the haproxy instance should not be served
anymore by kubernetes and the readiness probe should fail.
Furthermore, we also fail the liveness probe to enforce a restart of
haproxy, as this can resolve the issue in some cases (eg. network or dns
issues).

Signed-off-by: Nicolas Bigler <[email protected]>
  • Loading branch information
TheBigLee committed Oct 26, 2023
1 parent b7e0eae commit 29a5f5a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ helm repo add appuio https://charts.appuio.ch
| [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/data-cube-curation-0.3.1/total)](https://github.com/appuio/charts/releases/tag/data-cube-curation-0.3.1) | [data-cube-curation](appuio/data-cube-curation/README.md) |
| [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/exoip-1.0.4/total)](https://github.com/appuio/charts/releases/tag/exoip-1.0.4) | [exoip](appuio/exoip/README.md) |
| [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/generic-0.1.2/total)](https://github.com/appuio/charts/releases/tag/generic-0.1.2) | [generic](appuio/generic/README.md) |
| [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/haproxy-2.4.0/total)](https://github.com/appuio/charts/releases/tag/haproxy-2.4.0) | [haproxy](appuio/haproxy/README.md) |
| [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/haproxy-2.5.0/total)](https://github.com/appuio/charts/releases/tag/haproxy-2.5.0) | [haproxy](appuio/haproxy/README.md) |
| [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/mariadb-galera-1.2.4/total)](https://github.com/appuio/charts/releases/tag/mariadb-galera-1.2.4) | [mariadb-galera](appuio/mariadb-galera/README.md) |
| [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/maxscale-2.0.1/total)](https://github.com/appuio/charts/releases/tag/maxscale-2.0.1) | [maxscale](appuio/maxscale/README.md) |
| [![chart downloads](https://img.shields.io/github/downloads/appuio/charts/metrics-server-2.12.1/total)](https://github.com/appuio/charts/releases/tag/metrics-server-2.12.1) | [metrics-server](appuio/metrics-server/README.md) |
Expand Down
2 changes: 1 addition & 1 deletion appuio/haproxy/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
appVersion: 2.7.3
description: A Helm chart for HAProxy which can be customized by a config map.
name: haproxy
version: 2.4.0
version: 2.5.0
maintainers:
- name: APPUiO Team
email: [email protected]
2 changes: 1 addition & 1 deletion appuio/haproxy/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# haproxy

![Version: 2.4.0](https://img.shields.io/badge/Version-2.4.0-informational?style=flat-square) ![AppVersion: 2.7.3](https://img.shields.io/badge/AppVersion-2.7.3-informational?style=flat-square)
![Version: 2.5.0](https://img.shields.io/badge/Version-2.5.0-informational?style=flat-square) ![AppVersion: 2.7.3](https://img.shields.io/badge/AppVersion-2.7.3-informational?style=flat-square)

A Helm chart for HAProxy which can be customized by a config map.

Expand Down
17 changes: 16 additions & 1 deletion appuio/haproxy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ Create chart name and version as used by the chart label.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create backendName depending on the selected configuration
*/}}
{{- define "haproxy.backendName" -}}
{{- if eq .Values.haproxy.config "redisk8s" -}}
redis-nodes
{{- else if or (eq .Values.haproxy.config "galerak8s") (eq .Values.haproxy.config "galera") -}}
galera-nodes
{{- else -}}
backend
{{- end -}}
{{- end -}}

{{/*
{{/*
HAProxy config for stats and metrics
*/}}
Expand All @@ -43,8 +57,9 @@ frontend stats
stats uri /stats
stats refresh 3s
acl server_stopping stopping
acl service_down nbsrv({{ include "haproxy.backendName" . }}) eq 0
monitor-uri /healthz
monitor fail if server_stopping
monitor fail if server_stopping || service_down
option dontlog-normal
option httplog
http-request use-service prometheus-exporter if { path /metrics }
Expand Down

0 comments on commit 29a5f5a

Please sign in to comment.