Skip to content
Open
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
2 changes: 1 addition & 1 deletion charts/shield/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ maintainers:
- name: mavimo
email: marcovito.moscaritolo@sysdig.com
type: application
version: 1.37.1
version: 1.37.2
appVersion: "1.0.0"
2 changes: 2 additions & 0 deletions charts/shield/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,5 @@ The following table lists the configurable parameters of the `shield` chart and
| gke_autopilot.allowlist_waiter.resources.limits.memory | The memory limit for the allowlist waiter Job | <code>128Mi</code> |
| gke_autopilot.allowlist_waiter.resources.requests.cpu | The CPU request for the allowlist waiter Job | <code>50m</code> |
| gke_autopilot.allowlist_waiter.resources.requests.memory | The memory request for the allowlist waiter Job | <code>64Mi</code> |
| gke_autopilot.allowlist_waiter.pod_security_context | Pod-level securityContext for the waiter Job. Defaults satisfy the Kubernetes PodSecurity "restricted" profile and OpenShift "restricted-v2" SCC. | <code>{"runAsGroup":65532,"runAsNonRoot":true,"runAsUser":65532,"seccompProfile":{"type":"RuntimeDefault"}}</code> |
| gke_autopilot.allowlist_waiter.security_context | Container-level securityContext for the waiter Job. The wait-for-allowlist container only runs `kubectl wait`, so root, escalation, and capabilities are not required. | <code>{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true}</code> |
4 changes: 4 additions & 0 deletions charts/shield/templates/host/gke-allowlist-waiter-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ spec:
spec:
restartPolicy: OnFailure
serviceAccountName: {{ include "host.allowlist_waiter.service_account_name" . }}
securityContext:
{{- toYaml .Values.gke_autopilot.allowlist_waiter.pod_security_context | nindent 8 }}
{{- with .Values.gke_autopilot.allowlist_waiter.image.pull_secrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
Expand All @@ -31,6 +33,8 @@ spec:
- name: wait-for-allowlist
image: {{ include "host.allowlist_waiter.image" . | replace " " "" }}
imagePullPolicy: {{ .Values.gke_autopilot.allowlist_waiter.image.pull_policy }}
securityContext:
{{- toYaml .Values.gke_autopilot.allowlist_waiter.security_context | nindent 12 }}
command:
- /bin/bash
- -c
Expand Down
114 changes: 114 additions & 0 deletions charts/shield/tests/host/gke-allowlist-waiter-job_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
suite: Host - GKE Allowlist Waiter Job
templates:
- templates/host/gke-allowlist-waiter-job.yaml
release:
name: release-name
namespace: shield-namespace
values:
- ../values/gke-autopilot.yaml
tests:
- it: Doesn't render when allowlist_waiter is disabled (default)
asserts:
- hasDocuments:
count: 0

- it: Renders the Job when allowlist_waiter is enabled
set:
gke_autopilot:
allowlist_waiter:
enabled: true
asserts:
- hasDocuments:
count: 1
- containsDocument:
kind: Job
apiVersion: batch/v1
name: release-name-shield-host-allowlist-waiter

- it: Job has PSA Restricted compatible pod securityContext by default
set:
gke_autopilot:
allowlist_waiter:
enabled: true
asserts:
- equal:
path: spec.template.spec.securityContext.runAsNonRoot
value: true
- equal:
path: spec.template.spec.securityContext.runAsUser
value: 65532
- equal:
path: spec.template.spec.securityContext.runAsGroup
value: 65532
- equal:
path: spec.template.spec.securityContext.seccompProfile.type
value: RuntimeDefault

- it: Container has PSA Restricted compatible securityContext by default
set:
gke_autopilot:
allowlist_waiter:
enabled: true
asserts:
- equal:
path: spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation
value: false
- equal:
path: spec.template.spec.containers[0].securityContext.readOnlyRootFilesystem
value: true
- equal:
path: spec.template.spec.containers[0].securityContext.capabilities.drop
value:
- ALL

- it: Pod securityContext is overridable via values
set:
gke_autopilot:
allowlist_waiter:
enabled: true
pod_security_context:
runAsNonRoot: true
runAsUser: 1000
fsGroup: 1000
asserts:
- equal:
path: spec.template.spec.securityContext.runAsUser
value: 1000
- equal:
path: spec.template.spec.securityContext.fsGroup
value: 1000

- it: Container securityContext is overridable via values
set:
gke_autopilot:
allowlist_waiter:
enabled: true
security_context:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false
capabilities:
drop:
- ALL
add:
- NET_BIND_SERVICE
asserts:
- equal:
path: spec.template.spec.containers[0].securityContext.readOnlyRootFilesystem
value: false
- equal:
path: spec.template.spec.containers[0].securityContext.capabilities.add
value:
- NET_BIND_SERVICE

- it: Job pre-install hook annotations are preserved
set:
gke_autopilot:
allowlist_waiter:
enabled: true
asserts:
- equal:
path: metadata.annotations["helm.sh/hook"]
value: pre-install,pre-upgrade
- equal:
path: metadata.annotations["helm.sh/hook-weight"]
value: "5"
18 changes: 18 additions & 0 deletions charts/shield/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -684,3 +684,21 @@ gke_autopilot:
cpu: 50m
# The memory request for the allowlist waiter Job
memory: 64Mi
# Pod-level securityContext for the waiter Job. Defaults satisfy the
# Kubernetes PodSecurity "restricted" profile and OpenShift "restricted-v2"
# SCC so the pre-install hook is admitted on hardened clusters.
pod_security_context:
runAsNonRoot: true
runAsUser: 65532
runAsGroup: 65532
seccompProfile:
type: RuntimeDefault
# Container-level securityContext for the waiter Job. The wait-for-allowlist
# container only runs `kubectl wait`, so root, escalation, and capabilities
# are not required.
security_context:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
Loading