Skip to content

Commit adbe150

Browse files
committed
fix(shield): set seLinuxOptions to control_t for unprivileged host shield bottlerocket deployment
Signed-off-by: Roberto Scolaro <[email protected]>
1 parent 5457803 commit adbe150

File tree

6 files changed

+77
-2
lines changed

6 files changed

+77
-2
lines changed

charts/shield/templates/common/_cluster_type.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ Proxy Secret Name
66
{{- true -}}
77
{{- end -}}
88
{{- end -}}
9+
10+
{{- define "common.cluster_type.is_bottlerocket" -}}
11+
{{- if eq "bottlerocket" .Values.cluster_config.cluster_type -}}
12+
{{- true -}}
13+
{{- end -}}
14+
{{- end -}}

charts/shield/templates/host/_helpers.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ capabilities:
201201
allowPrivilegeEscalation: false
202202
seccompProfile:
203203
type: Unconfined
204+
{{- if (include "common.cluster_type.is_bottlerocket" .) }}
205+
seLinuxOptions:
206+
type: control_t
207+
{{- end }}
204208
capabilities:
205209
drop:
206210
- ALL

charts/shield/tests/host/daemonset_test.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,53 @@ tests:
144144
readOnlyRootFilesystem: false
145145
allowPrivilegeEscalation: true
146146

147+
- it: Test host.privileged=false with bottlerocket cluster_type adds seLinuxOptions
148+
set:
149+
host:
150+
privileged: false
151+
cluster_config:
152+
cluster_type: bottlerocket
153+
asserts:
154+
- isSubset:
155+
path: spec.template.spec.containers[?(@.name == "sysdig-host-shield")].securityContext
156+
content:
157+
allowPrivilegeEscalation: false
158+
seccompProfile:
159+
type: Unconfined
160+
seLinuxOptions:
161+
type: control_t
162+
capabilities:
163+
drop:
164+
- ALL
165+
add:
166+
- DAC_READ_SEARCH
167+
- KILL
168+
- SETGID
169+
- SETUID
170+
- SYS_ADMIN
171+
- SYS_CHROOT
172+
- SYS_PTRACE
173+
- SYS_RESOURCE
174+
175+
- it: Test host.privileged=false with generic cluster_type does not add seLinuxOptions
176+
set:
177+
host:
178+
privileged: false
179+
cluster_config:
180+
cluster_type: generic
181+
asserts:
182+
- isSubset:
183+
path: spec.template.spec.containers[?(@.name == "sysdig-host-shield")].securityContext
184+
content:
185+
allowPrivilegeEscalation: false
186+
seccompProfile:
187+
type: Unconfined
188+
- isNotSubset:
189+
path: spec.template.spec.containers[?(@.name == "sysdig-host-shield")].securityContext
190+
content:
191+
seLinuxOptions:
192+
type: control_t
193+
147194
- it: Test user specified priority class
148195
set:
149196
host:

charts/shield/tests/host/security_context_test.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,23 @@ tests:
5656
runAsNonRoot: false
5757
runAsUser: 0
5858

59+
- it: Ensure the securityContext for bottlerocket includes seLinuxOptions
60+
set:
61+
host:
62+
privileged: false
63+
driver: universal_ebpf
64+
cluster_config:
65+
cluster_type: bottlerocket
66+
asserts:
67+
- isSubset:
68+
path: spec.template.spec.containers[?(@.name == "sysdig-host-shield")].securityContext
69+
content:
70+
allowPrivilegeEscalation: false
71+
seccompProfile:
72+
type: Unconfined
73+
seLinuxOptions:
74+
type: control_t
75+
5976
- it: Ensure the security_context is honored
6077
set:
6178
host:

charts/shield/values.schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
"description": "Type of Kubernetes cluster",
7575
"enum": [
7676
"generic",
77-
"gke-autopilot"
77+
"gke-autopilot",
78+
"bottlerocket"
7879
],
7980
"examples": [
8081
"generic"

charts/shield/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cluster_config:
33
name:
44
# The domain of the cluster
55
cluster_domain: cluster.local
6-
# The type of the cluster (Accepted Values: gke-autopilot, generic)
6+
# The type of the cluster (Accepted Values: gke-autopilot, bottlerocket, generic)
77
cluster_type: generic
88
# The root namespace of the cluster
99
root_namespace: kube-system

0 commit comments

Comments
 (0)