Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support pod securitycontext and container security context #496

Merged
merged 15 commits into from
Nov 4, 2024
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
3 changes: 2 additions & 1 deletion templates/dag-deploy/dag-server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
- name: {{ template "astro.registry_secret" . }}
{{- end }}
serviceAccountName: {{ template "astro.dagDeploy.serviceAccountName" . }}
securityContext: {{ toYaml .Values.dagDeploy.securityContext | nindent 8 }}
securityContext: {{ toYaml .Values.dagDeploy.securityContexts.pod | nindent 8 }}
containers:
- name: dag-server
image: "{{ .Values.dagDeploy.images.dagServer.repository }}:{{ .Values.dagDeploy.images.dagServer.tag }}"
Expand All @@ -59,6 +59,7 @@ spec:
ports:
- name: server
containerPort: {{ .Values.dagDeploy.ports.dagServerHttp }}
securityContext: {{ toYaml .Values.dagDeploy.securityContexts.container | nindent 12 }}
resources:
{{- toYaml .Values.dagDeploy.resources | nindent 12 }}
env:
Expand Down
24 changes: 20 additions & 4 deletions tests/chart/test_dag_server_statefulset.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,23 @@ def test_dag_server_statefulset_with_resource_overrides(self, kube_version):

def test_dag_server_statefulset_with_securitycontext_overrides(self, kube_version):
"""Test that dag-server statefulset are configurable with custom securitycontext."""
dag_serversecuritycontext = {"runAsUser": 12345, "privileged": True}
values = {"dagDeploy": {"enabled": True, "securityContext": dag_serversecuritycontext}}
dag_server_pod_securitycontext = {
"runAsUser": 12345,
"allowPrivilegeEscalation": True,
"runAsGroup": 1000,
"fsGroup": 2000,
"readOnlyRootFilesystem": True,
}
dag_server_container_securitycontext = {"allowPrivilegeEscalation": False}
values = {
"dagDeploy": {
"enabled": True,
"securityContexts": {
"pod": dag_server_pod_securitycontext,
"container": dag_server_container_securitycontext,
},
}
}

docs = render_chart(
kube_version=kube_version,
Expand All @@ -118,8 +133,9 @@ def test_dag_server_statefulset_with_securitycontext_overrides(self, kube_versio
doc = docs[0]

common_default_tests(doc)

assert dag_serversecuritycontext == doc["spec"]["template"]["spec"]["securityContext"]
spec = doc["spec"]["template"]["spec"]
assert dag_server_pod_securitycontext == spec["securityContext"]
assert dag_server_container_securitycontext == spec["containers"][0]["securityContext"]

def test_dag_server_statefulset_with_custom_registry_secret(self, kube_version):
"""Test dag-server statefulset with custom registry secret."""
Expand Down
6 changes: 3 additions & 3 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,9 @@ dagDeploy:
# when it wants to scale a node down.
safeToEvict: true

securityContext: {}
# runAsUser: 999
# runAsGroup: 0
securityContexts:
pod: {}
container: {}

gitSyncRelay:
enabled: ~
Expand Down