Skip to content

Commit 4d7e66d

Browse files
committed
FEATURE/MINOR: haproxy: add basic instructions for haproxy config reload
Thanks-to: Timur-ND Signed-off-by: Antonio Huete Jimenez <[email protected]>
1 parent 2ef5439 commit 4d7e66d

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

haproxy/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,67 @@ extraEnvs:
232232
fieldPath: status.podIP
233233
```
234234

235+
### Automatic configuration reloading
236+
237+
In some cases, configuration changes are frequent and constantly restarting HAProxy is not optimal. For those cases the HAProxy hot-reload feature
238+
can be used.
239+
240+
In master-worker mode, sending a USR2 signal to the HAProxy process will trigger a configuration reload.
241+
242+
```yaml
243+
shareProcessNamespace:
244+
enabled: true
245+
config: |
246+
global
247+
log stdout format raw local0
248+
master-worker
249+
daemon
250+
maxconn 1024
251+
defaults
252+
log global
253+
timeout client 60s
254+
timeout connect 60s
255+
timeout server 60s
256+
frontend fe_main
257+
mode http
258+
bind :80
259+
http-request redirect scheme https code 301 unless { ssl_fc }
260+
default_backend be_main
261+
backend be_main
262+
mode http
263+
server web1 10.0.0.1:8080 check
264+
```
265+
266+
Make sure you are not specifying subPath for any of your volumeMounts so that Kubernetes will automatically update the volumes created from
267+
ConfigMaps.
268+
269+
And finally, use some sidecar container which will be delivering the signal to the process. The shareProcessNamespace Pod property is required
270+
for the sidecars to be able to access other containers' processes.
271+
272+
```yaml
273+
sidecarContainers:
274+
- name: reflex
275+
image: acim/go-reflex:1.17.3
276+
command: ["reflex", "-d", "fancy"]
277+
workingDir: /usr/local/etc/haproxy
278+
args:
279+
- -svr
280+
- "..data"
281+
- --
282+
- bash
283+
- -c
284+
- 'pkill -SIGUSR2 "haproxy|hapee-lb"'
285+
volumeMounts:
286+
- name: haproxy-config
287+
mountPath: /usr/local/etc/haproxy
288+
resources:
289+
limits:
290+
memory: 128Mi
291+
requests:
292+
cpu: 50m
293+
memory: 64Mi
294+
```
295+
235296
## Installing as non-root with binding to privileged ports
236297

237298
To be able to bind to privileged ports such as tcp/80 and tcp/443 without root privileges (UID and GID are set to 1000 in the example, as HAProxy Docker image has UID/GID of 1000 reserved for HAProxy), there is a special workaround required as `NET_BIND_SERVICE` capability is [not propagated](https://github.com/kubernetes/kubernetes/issues/56374), so we need to use `initContainers` feature as well:

0 commit comments

Comments
 (0)