Skip to content

Commit 58c13e5

Browse files
committed
Run VLAN NSE,NSC as non-root
VLAN NSE does not require any changes or capabilities to run as non-root. NSC requires CAP_DAC_OVERRIDE to write to nsm-sock, and optionally CAP_NET_RAW to use ping from the container. (The Dockerfile must be changed accordingly.)
1 parent b1100bf commit 58c13e5

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

deployments/helm/templates/load-balancer.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ spec:
120120
- name: nsm-socket
121121
mountPath: /var/lib/networkservicemesh
122122
readOnly: true
123+
securityContext:
124+
runAsNonRoot: true
125+
runAsUser: {{ .Values.vlanNSC.userId }}
126+
runAsGroup: {{ .Values.vlanNSC.userId }}
127+
readOnlyRootFilesystem: true
128+
capabilities:
129+
drop:
130+
- all
131+
add:
132+
- DAC_OVERRIDE
133+
- NET_RAW
123134
- name: fe
124135
image: {{ .Values.registry }}/{{ .Values.organization }}/{{ .Values.frontEnd.image }}:{{ .Values.frontEnd.version }}
125136
imagePullPolicy: {{ .Values.pullPolicy }}

deployments/helm/templates/nse-vlan.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ spec:
2929
- containerPort: 5003
3030
hostPort: 5003
3131
securityContext:
32+
runAsNonRoot: true
33+
runAsUser: {{ .Values.vlanNSE.userId }}
34+
runAsGroup: {{ .Values.vlanNSE.userId }}
3235
readOnlyRootFilesystem: true
36+
capabilities:
37+
drop:
38+
- all
3339
env:
3440
- name: SPIFFE_ENDPOINT_SOCKET
3541
value: unix:///run/spire/sockets/agent.sock

deployments/helm/values.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ vlanNSE:
9999
probe:
100100
addr: :5003
101101
spiffe: true
102+
userId: 10000
102103

103104
vlanNSC:
104105
image: cmd-nsc
105106
version: v1.4.0
107+
userId: 10000
106108

107109
vlan:
108110
networkServiceName: external-vlan

0 commit comments

Comments
 (0)