Skip to content

Commit 09adfd7

Browse files
authored
Mount HAProxy config via ConfigMap instead of baking into image (#483)
1 parent cbad802 commit 09adfd7

4 files changed

Lines changed: 98 additions & 3 deletions

File tree

charts/whatsapp-proxy-chart/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type: application
1717
# This is the chart version. This version number should be incremented each time you make changes
1818
# to the chart and its templates, including the app version.
1919
# Versions are expected to follow Semantic Versioning (https://semver.org/)
20-
version: 1.2.0
20+
version: 1.3.0
2121

2222
# This is the version number of the application being deployed. This version number should be
2323
# incremented each time you make changes to the application. Versions are not expected to
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# License found in the LICENSE file in the root directory
4+
# of this source tree.
5+
apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: {{ include "whatsapp-proxy-chart.fullname" . }}-haproxy
9+
labels:
10+
{{- include "whatsapp-proxy-chart.labels" . | nindent 4 }}
11+
data:
12+
haproxy.cfg: |
13+
{{- .Values.haproxyConfig | nindent 4 }}

charts/whatsapp-proxy-chart/templates/deployment.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ spec:
1717
{{- include "whatsapp-proxy-chart.selectorLabels" . | nindent 6 }}
1818
template:
1919
metadata:
20-
{{- with .Values.podAnnotations }}
2120
annotations:
21+
checksum/haproxy-config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
22+
{{- with .Values.podAnnotations }}
2223
{{- toYaml . | nindent 8 }}
23-
{{- end }}
24+
{{- end }}
2425
labels:
2526
{{- include "whatsapp-proxy-chart.selectorLabels" . | nindent 8 }}
2627
spec:
@@ -94,6 +95,15 @@ spec:
9495
env:
9596
- name: "PUBLIC_IP"
9697
value: "{{ .Values.public_ip }}"
98+
volumeMounts:
99+
- name: haproxy-config
100+
mountPath: /usr/local/etc/haproxy/haproxy.cfg
101+
subPath: haproxy.cfg
102+
readOnly: true
103+
volumes:
104+
- name: haproxy-config
105+
configMap:
106+
name: {{ include "whatsapp-proxy-chart.fullname" . }}-haproxy
97107
{{- with .Values.nodeSelector }}
98108
nodeSelector:
99109
{{- toYaml . | nindent 8 }}

charts/whatsapp-proxy-chart/values.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,75 @@ nodeSelector: {}
102102
tolerations: []
103103

104104
affinity: {}
105+
106+
# HAProxy configuration file contents.
107+
# Edit this to customize proxy behavior without rebuilding the image.
108+
haproxyConfig: |
109+
global
110+
tune.bufsize 4096
111+
maxconn 27500
112+
spread-checks 5
113+
ssl-server-verify none
114+
115+
defaults
116+
mode tcp
117+
timeout client-fin 1s
118+
timeout server-fin 1s
119+
timeout connect 5s
120+
timeout client 200s
121+
timeout server 200s
122+
default-server inter 10s fastinter 1s downinter 3s error-limit 50
123+
124+
listen stats
125+
bind :::8199
126+
mode http
127+
http-request use-service prometheus-exporter if { path /metrics }
128+
stats uri /
129+
130+
frontend haproxy_v4_http
131+
maxconn 27495
132+
#PUBLIC_IP
133+
134+
bind ipv4@*:80
135+
bind ipv4@*:8080 accept-proxy
136+
137+
default_backend wa_http
138+
139+
frontend haproxy_v4_https
140+
maxconn 27495
141+
#PUBLIC_IP
142+
143+
bind ipv4@*:443 ssl crt /etc/haproxy/ssl/proxy.whatsapp.net.pem
144+
bind ipv4@*:8443 ssl crt /etc/haproxy/ssl/proxy.whatsapp.net.pem accept-proxy
145+
146+
default_backend wa
147+
148+
frontend haproxy_v4_xmpp
149+
maxconn 27495
150+
#PUBLIC_IP
151+
152+
bind ipv4@*:5222
153+
bind ipv4@*:8222 accept-proxy
154+
155+
default_backend wa
156+
157+
frontend haproxy_v4_whatsapp_net
158+
maxconn 27495
159+
#PUBLIC_IP
160+
161+
bind ipv4@*:587
162+
bind ipv4@*:7777
163+
164+
default_backend wa_whatsapp_net
165+
166+
backend wa_whatsapp_net
167+
default-server check inter 60000 observe layer4
168+
server whatsapp_net_443 whatsapp.net:443
169+
170+
backend wa
171+
default-server check inter 60000 observe layer4 send-proxy
172+
server g_whatsapp_net_5222 g.whatsapp.net:5222
173+
174+
backend wa_http
175+
default-server check inter 60000 observe layer4 send-proxy
176+
server g_whatsapp_net_80 g.whatsapp.net:80

0 commit comments

Comments
 (0)