Skip to content

Commit d550393

Browse files
charts/brig: Support running brig with GeoIP database (#2406)
* charts/brig: Support running brig with GeoIP database Co-authored-by: jschaul <[email protected]>
1 parent 33bda9c commit d550393

File tree

7 files changed

+102
-4
lines changed

7 files changed

+102
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Support running brig with GeoIP database when using helm charts

charts/brig/templates/configmap.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ data:
202202
{{- end }}
203203
{{- end }}
204204
205+
{{- if .geoip.enabled }}
206+
# Shared emptyDir with geoipupdate container
207+
geoDb: /usr/share/GeoIP/GeoIP2-City.mmdb
208+
{{- end }}
209+
205210
{{- with .optSettings }}
206211
optSettings:
207212
setActivationTimeout: {{ .setActivationTimeout }}

charts/brig/templates/deployment.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,40 @@ spec:
4242
- name: "brig-secrets"
4343
secret:
4444
secretName: "brig"
45+
{{- if .Values.config.geoip.enabled }}
46+
- name: "geoip"
47+
emptyDir: {}
48+
{{- end }}
49+
{{- if .Values.config.geoip.enabled }}
50+
# Brig needs GeoIP database to be downloaded before it can start.
51+
initContainers:
52+
- name: geoipdownload
53+
image: "{{ .Values.config.geoip.image.repository }}:{{ .Values.config.geoip.image.tag }}"
54+
imagePullPolicy: {{ default "" .Values.config.geoip.imagePullPolicy | quote }}
55+
volumeMounts:
56+
- name: "geoip"
57+
mountPath: "/usr/share/GeoIP"
58+
# The environment variables are documented at:
59+
# https://github.com/maxmind/geoipupdate/blob/62b34e648a842dc03ccf4ad3f61e2d85eaec98fc/doc/docker.md
60+
env:
61+
- name: GEOIPUPDATE_ACCOUNT_ID
62+
valueFrom:
63+
secretKeyRef:
64+
name: brig-geoip
65+
key: accountId
66+
- name: GEOIPUPDATE_LICENSE_KEY
67+
valueFrom:
68+
secretKeyRef:
69+
name: brig-geoip
70+
key: licenseKey
71+
- name: GEOIPUPDATE_EDITION_IDS
72+
valueFrom:
73+
secretKeyRef:
74+
name: brig-geoip
75+
key: editionIds
76+
- name: GEOIPUPDATE_FREQUENCY
77+
value: "0" # Setting this to 0 makes the script only run geoipupdate once.
78+
{{- end }}
4579
containers:
4680
- name: brig
4781
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
@@ -55,6 +89,10 @@ spec:
5589
- name: "turn-servers"
5690
mountPath: "/etc/wire/brig/turn"
5791
{{- end }}
92+
{{- if .Values.config.geoip.enabled }}
93+
- name: "geoip"
94+
mountPath: "/usr/share/GeoIP"
95+
{{- end }}
5896
env:
5997
- name: LOG_LEVEL
6098
value: {{ .Values.config.logLevel }}
@@ -107,3 +145,31 @@ spec:
107145
port: {{ .Values.service.internalPort }}
108146
resources:
109147
{{ toYaml .Values.resources | indent 12 }}
148+
{{- if .Values.config.geoip.enabled }}
149+
- name: geoipupdate
150+
image: "{{ .Values.config.geoip.image.repository }}:{{ .Values.config.geoip.image.tag }}"
151+
imagePullPolicy: {{ default "" .Values.config.geoip.imagePullPolicy | quote }}
152+
volumeMounts:
153+
- name: "geoip"
154+
mountPath: "/usr/share/GeoIP"
155+
# The environment variables are documented at:
156+
# https://github.com/maxmind/geoipupdate/blob/62b34e648a842dc03ccf4ad3f61e2d85eaec98fc/doc/docker.md
157+
env:
158+
- name: GEOIPUPDATE_ACCOUNT_ID
159+
valueFrom:
160+
secretKeyRef:
161+
name: brig-geoip
162+
key: accountId
163+
- name: GEOIPUPDATE_LICENSE_KEY
164+
valueFrom:
165+
secretKeyRef:
166+
name: brig-geoip
167+
key: licenseKey
168+
- name: GEOIPUPDATE_EDITION_IDS
169+
valueFrom:
170+
secretKeyRef:
171+
name: brig-geoip
172+
key: editionIds
173+
- name: GEOIPUPDATE_FREQUENCY
174+
value: "24" # hours
175+
{{- end }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if .Values.config.geoip.enabled }}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: brig-geoip
6+
labels:
7+
wireService: brig
8+
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
9+
release: "{{ .Release.Name }}"
10+
heritage: "{{ .Release.Service }}"
11+
type: Opaque
12+
data:
13+
{{- with .Values.secrets.geoip }}
14+
accountId: {{ required ".secrets.geoip.accountId must be provided when .Values.config.geoip.enabled is True" .accountId | b64enc | quote }}
15+
licenseKey: {{ required ".secrets.geoip.licenseKey must be provided when .Values.config.geoip.enabled is True" .licenseKey | b64enc | quote }}
16+
editionIds: {{ required ".secrets.geoip.editionIds must be provided when .Values.config.geoip.enabled is True" .editionIds | b64enc | quote }}
17+
{{- end }}
18+
{{- end }}

charts/brig/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ config:
8484
smtp:
8585
passwordFile: /etc/wire/brig/secrets/smtp-password.txt
8686
proxy: {}
87+
88+
geoip:
89+
# When enabling this, .secrets.geoip.accountId, .secrets.geoip.licenseKey and
90+
# .secret.geoip.editionIds must be provided.
91+
enabled: false
92+
image:
93+
repository: docker.io/maxmindinc/geoipupdate
94+
tag: v4.9
8795
turnStatic:
8896
v1:
8997
- turn:localhost:3478

hack/bin/set-chart-image-version.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ for chart in $charts
1111
do
1212
if [[ "$chart" == "nginz" ]]; then
1313
# nginz has a different docker tag indentation
14-
sed -i "s/ tag: .*/ tag: $docker_tag/g" "$CHARTS_DIR/$chart/values.yaml"
14+
sed -i "s/^ tag: .*/ tag: $docker_tag/g" "$CHARTS_DIR/$chart/values.yaml"
1515
else
16-
sed -i "s/ tag: .*/ tag: $docker_tag/g" "$CHARTS_DIR/$chart/values.yaml"
16+
sed -i "s/^ tag: .*/ tag: $docker_tag/g" "$CHARTS_DIR/$chart/values.yaml"
1717
fi
1818
done

hack/bin/set-wire-server-image-version.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ CHARTS_DIR="$TOP_LEVEL/.local/charts"
99
charts=(brig cannon galley gundeck spar cargohold proxy cassandra-migrations elasticsearch-index federator)
1010

1111
for chart in "${charts[@]}"; do
12-
sed -i "s/ tag: .*/ tag: $target_version/g" "$CHARTS_DIR/$chart/values.yaml"
12+
sed -i "s/^ tag: .*/ tag: $target_version/g" "$CHARTS_DIR/$chart/values.yaml"
1313
done
1414

1515
#special case nginz
16-
sed -i "s/ tag: .*/ tag: $target_version/g" "$CHARTS_DIR/nginz/values.yaml"
16+
sed -i "s/^ tag: .*/ tag: $target_version/g" "$CHARTS_DIR/nginz/values.yaml"

0 commit comments

Comments
 (0)