Skip to content

Commit 17830b8

Browse files
committed
Add hostNetwork, geolocation, custom ports, require-subdomain and extra ports support
1 parent 912a430 commit 17830b8

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed

charts/netbird-proxy/templates/deployment.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ spec:
3535
hostAliases:
3636
{{- toYaml . | nindent 8 }}
3737
{{- end }}
38+
{{- if .Values.hostNetwork }}
39+
hostNetwork: true
40+
dnsPolicy: ClusterFirstWithHostNet
41+
{{- end }}
3842
securityContext:
3943
{{- toYaml .Values.podSecurityContext | nindent 8 }}
4044
{{- with .Values.initContainers }}
@@ -69,6 +73,11 @@ spec:
6973
containerPort: {{ .Values.wireguard.port }}
7074
protocol: UDP
7175
{{- end }}
76+
{{- range .Values.extraPorts }}
77+
- name: {{ .name }}
78+
containerPort: {{ .port }}
79+
protocol: {{ .protocol }}
80+
{{- end }}
7281
env:
7382
- name: USER
7483
value: "netbird"
@@ -149,6 +158,21 @@ spec:
149158
- name: NB_PROXY_WG_PORT
150159
value: {{ .Values.wireguard.port | quote }}
151160
{{- end }}
161+
{{- if .Values.supportsCustomPorts }}
162+
- name: NB_PROXY_SUPPORTS_CUSTOM_PORTS
163+
value: "true"
164+
{{- end }}
165+
{{- if .Values.requireSubdomain }}
166+
- name: NB_PROXY_REQUIRE_SUBDOMAIN
167+
value: "true"
168+
{{- end }}
169+
{{- if .Values.geolocation.enabled }}
170+
- name: NB_PROXY_GEO_DATA_DIR
171+
value: {{ .Values.geolocation.dataDir | quote }}
172+
{{- else }}
173+
- name: NB_PROXY_DISABLE_GEOLOCATION
174+
value: "true"
175+
{{- end }}
152176
{{- if .Values.debug.enabled }}
153177
- name: NB_PROXY_DEBUG_ENDPOINT
154178
value: "true"
@@ -163,6 +187,8 @@ spec:
163187
mountPath: {{ .Values.certDir }}
164188
- name: tmp
165189
mountPath: /tmp
190+
- name: data
191+
mountPath: /var/lib/netbird
166192
{{- with .Values.extraVolumeMounts }}
167193
{{- toYaml . | nindent 12 }}
168194
{{- end }}
@@ -209,6 +235,16 @@ spec:
209235
{{- end }}
210236
- name: tmp
211237
emptyDir: {}
238+
- name: data
239+
{{- if and .Values.geolocation.enabled .Values.geolocation.volume.existingClaim }}
240+
persistentVolumeClaim:
241+
claimName: {{ .Values.geolocation.volume.existingClaim }}
242+
{{- else if and .Values.geolocation.enabled .Values.geolocation.volume.enabled }}
243+
persistentVolumeClaim:
244+
claimName: {{ include "netbird-proxy.fullname" . }}-geodata
245+
{{- else }}
246+
emptyDir: {}
247+
{{- end }}
212248
{{- with .Values.extraVolumes }}
213249
{{- toYaml . | nindent 8 }}
214250
{{- end }}

charts/netbird-proxy/templates/pvc.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,21 @@ spec:
1515
requests:
1616
storage: {{ .Values.certVolume.size | default "256Mi" }}
1717
{{- end }}
18+
---
19+
{{- if and .Values.geolocation.enabled .Values.geolocation.volume.enabled (not .Values.geolocation.volume.existingClaim) }}
20+
apiVersion: v1
21+
kind: PersistentVolumeClaim
22+
metadata:
23+
name: {{ include "netbird-proxy.fullname" . }}-geodata
24+
labels:
25+
{{- include "netbird-proxy.labels" . | nindent 4 }}
26+
spec:
27+
accessModes:
28+
- {{ .Values.geolocation.volume.accessMode | default "ReadWriteMany" }}
29+
{{- if .Values.geolocation.volume.storageClass }}
30+
storageClassName: {{ .Values.geolocation.volume.storageClass }}
31+
{{- end }}
32+
resources:
33+
requests:
34+
storage: {{ .Values.geolocation.volume.size | default "128Mi" }}
35+
{{- end }}

charts/netbird-proxy/templates/service.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,9 @@ spec:
5656
targetPort: wireguard
5757
protocol: UDP
5858
{{- end }}
59+
{{- range .Values.extraPorts }}
60+
- name: {{ .name }}
61+
port: {{ .port }}
62+
targetPort: {{ .port }}
63+
protocol: {{ .protocol }}
64+
{{- end }}

charts/netbird-proxy/values.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@ proxy:
3737
# that use PROXY protocol to forward real client IPs.
3838
proxyProtocol: false
3939

40+
# -- Allow users to choose a specific listen port for TCP/UDP services.
41+
# When false, ports are auto-assigned by management. When true, users
42+
# can specify a custom port number via the API or dashboard.
43+
supportsCustomPorts: true
44+
45+
# -- Require a subdomain label in front of the cluster domain. When true,
46+
# accounts cannot create services on the bare cluster domain. Enable this
47+
# on shared proxy deployments to prevent a single account from claiming
48+
# the cluster domain.
49+
requireSubdomain: false
50+
51+
# -- Use host networking. Required for TCP/UDP service passthrough in
52+
# Kubernetes, since dynamically bound ports cannot be declared in the
53+
# Service manifest. When enabled, the container shares the host's
54+
# network namespace and all listen ports are directly reachable.
55+
hostNetwork: false
56+
4057
wireguard:
4158
# -- Enable WireGuard UDP port exposure for P2P connectivity.
4259
# Only works with single-account deployments; multiple accounts
@@ -72,6 +89,23 @@ oidc:
7289
endpoint: "https://api.netbird.io/oauth2"
7390
scopes: "openid,profile,email"
7491

92+
geolocation:
93+
# -- Enable geolocation lookups for country-based access restrictions.
94+
enabled: true
95+
# -- Directory for the geolocation database inside the container.
96+
dataDir: "/var/lib/netbird/geolocation"
97+
volume:
98+
# -- Enable persistent storage for the geolocation database.
99+
# When false, an emptyDir is used and the database re-downloads on every pod restart.
100+
enabled: true
101+
# -- Use an existing PVC instead of creating one.
102+
existingClaim: ""
103+
# -- PVC access mode.
104+
accessMode: "ReadWriteOnce"
105+
# -- Storage class. Leave empty for the cluster default.
106+
storageClass: ""
107+
size: "128Mi"
108+
75109
debug:
76110
# -- Enable the debug HTTP endpoint.
77111
enabled: false
@@ -251,5 +285,11 @@ extraVolumeMounts: []
251285
# mountPath: /pebble-ca
252286
# readOnly: true
253287

288+
# -- Extra ports to expose on the Service and container.
289+
extraPorts: []
290+
# - name: tcp-10000
291+
# port: 10000
292+
# protocol: TCP
293+
254294
# -- Init containers to add to the pod.
255295
initContainers: []

0 commit comments

Comments
 (0)