Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changelog/3549.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```release-note:bug
mesh-gw: update capabilities on the security context needed for the dataplane container.
Adds NET_BIND_SERVICE to capabilities.add
Adds ALL to capabilities.drop unless .Values.meshGateway.hostNetwork is true
```
8 changes: 8 additions & 0 deletions charts/consul/templates/mesh-gateway-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ spec:
containers:
- name: mesh-gateway
image: {{ .Values.global.imageConsulDataplane | quote }}
securityContext:
capabilities:
{{ if not .Values.meshGateway.hostNetwork}}
drop:
- ALL
{{- end }}
add:
- NET_BIND_SERVICE
{{- if .Values.meshGateway.resources }}
resources:
{{- if eq (typeOf .Values.meshGateway.resources) "string" }}
Expand Down
28 changes: 28 additions & 0 deletions charts/consul/test/unit/mesh-gateway-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1783,4 +1783,32 @@ key2: value2' \
local actual=$(echo "$cmd" |
yq 'any(contains("-log-level=warn"))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

#--------------------------------------------------------------------
# security context

@test "meshGateway/Deployment: don't drop ALL capabilities when hostNetwork=true" {
cd `chart_dir`
local actual=$(helm template \
-s templates/mesh-gateway-deployment.yaml \
--set 'meshGateway.enabled=true' \
--set 'connectInject.enabled=true' \
--set 'meshGateway.hostNetwork=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].securityContext' | tee /dev/stderr)

[ $(echo "${actual}" | yq -r '.capabilities.drop | length') -eq 0 ]
}

@test "meshGateway/Deployment: drop ALL capabilities when hostNetwork!=true" {
cd `chart_dir`
local actual=$(helm template \
-s templates/mesh-gateway-deployment.yaml \
--set 'meshGateway.enabled=true' \
--set 'connectInject.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].securityContext' | tee /dev/stderr)

[ $(echo "${actual}" | yq -r '.capabilities.drop[0]') = "ALL" ]
}