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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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 @@ -41,7 +41,7 @@ spec:
- name: {{ template "astro.registry_secret" . }}
{{- end }}
serviceAccountName: {{ .Release.Name }}-dag-server
securityContext: {{ toYaml .Values.dagDeploy.securityContext | nindent 8 }}
securityContext: {{ toYaml .Values.dagDeploy.podSecurityContext | nindent 8 }}
containers:
- name: dag-server
image: "{{ .Values.dagDeploy.images.dagServer.repository }}:{{ .Values.dagDeploy.images.dagServer.tag }}"
Expand All @@ -50,6 +50,7 @@ spec:
ports:
- name: server
containerPort: {{ .Values.dagDeploy.ports.dagServerHttp }}
securityContext: {{ toYaml .Values.dagDeploy.containerSecurityContext | nindent 12 }}
resources:
{{- toYaml .Values.dagDeploy.resources | nindent 12 }}
env:
Expand Down
19 changes: 15 additions & 4 deletions tests/chart/test_dag_server_statefulset.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,18 @@ def test_dag_server_statefulset_with_resource_overrides(self, kube_version):
c_by_name = get_containers_by_name(doc)
assert c_by_name["dag-server"]["resources"] == resources

def test_dag_server_statefulset_with_securitycontext_overrides(self, kube_version):
def test_dag_server_statefulset_with_podsecuritycontext_overrides(
self, kube_version
):
"""Test that dag-server statefulset are configurable with custom securitycontext."""
dag_serversecuritycontext = {"runAsUser": 12345, "privileged": True}
dag_server_pod_securitycontext = {"runAsUser": 12345, "privileged": True}
dag_server_container_securitycontext = {"allowPrivilegeEscalation": False}
values = {
"dagDeploy": {"enabled": True, "securityContext": dag_serversecuritycontext}
"dagDeploy": {
"enabled": True,
"podSecurityContext": dag_server_pod_securitycontext,
"containerSecurityContext": dag_server_container_securitycontext,
}
}

docs = render_chart(
Expand All @@ -90,9 +97,13 @@ def test_dag_server_statefulset_with_securitycontext_overrides(self, kube_versio
assert doc["apiVersion"] == "apps/v1"
assert doc["metadata"]["name"] == "release-name-dag-server"
assert (
dag_serversecuritycontext
dag_server_pod_securitycontext
== doc["spec"]["template"]["spec"]["securityContext"]
)
assert (
dag_server_container_securitycontext
== doc["spec"]["template"]["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
3 changes: 2 additions & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,10 @@ dagDeploy:
# when it wants to scale a node down.
safeToEvict: true

securityContext: {}
podSecurityContext: {}
# runAsUser: 999
# runAsGroup: 0
containerSecurityContext: {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

securityContexts: 
    pod: {}
    container: {}


gitSyncRelay:
enabled: ~
Expand Down