Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,23 @@ spec:
template:
spec:
serviceAccountName: kubeflow-trainer-cache-initializer
securityContext:
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: dataset-initializer
image: {{ printf "ghcr.io/kubeflow/trainer/dataset-initializer:%s" (include "trainer.defaultImageTag" .) }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
env:
- name: CACHE_IMAGE
value: {{ include "trainer.runtimeImage" (list .Values.dataCache.cacheImage .) | quote }}
Expand All @@ -68,9 +82,24 @@ spec:
spec:
template:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: node
image: pytorch/pytorch:2.10.0-cuda12.8-cudnn9-runtime
workingDir: /tmp
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
env:
- name: TRAIN_JOB_NAME
valueFrom:
Expand Down
15 changes: 15 additions & 0 deletions charts/kubeflow-trainer/templates/runtimes/torch-distributed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,22 @@ spec:
spec:
template:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: node
image: pytorch/pytorch:2.10.0-cuda12.8-cudnn9-runtime
workingDir: /tmp
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
{{- end }}
28 changes: 28 additions & 0 deletions charts/kubeflow-trainer/tests/runtimes/torch_distributed_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,31 @@ tests:
- equal:
path: spec.template.spec.replicatedJobs[0].template.spec.template.spec.containers[0].image
value: pytorch/pytorch:2.10.0-cuda12.8-cudnn9-runtime

- it: Should set restricted PSS compatible security contexts
set:
runtimes:
torchDistributed:
enabled: true
asserts:
- equal:
path: spec.template.spec.replicatedJobs[0].template.spec.template.spec.securityContext
value:
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
- equal:
path: spec.template.spec.replicatedJobs[0].template.spec.template.spec.containers[0].workingDir
value: /tmp
- equal:
path: spec.template.spec.replicatedJobs[0].template.spec.template.spec.containers[0].securityContext
value:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,57 @@ tests:
- equal:
path: spec.template.spec.replicatedJobs[1].dependsOn[0].status
value: Complete

- it: Should set restricted PSS compatible security contexts
set:
dataCache:
enabled: true
cacheImage:
registry: ghcr.io
repository: kubeflow/trainer/data-cache
tag: "v1.0.0"
runtimes:
torchDistributedWithCache:
enabled: true
asserts:
- equal:
path: spec.template.spec.replicatedJobs[0].template.spec.template.spec.securityContext
value:
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
- notExists:
path: spec.template.spec.replicatedJobs[0].template.spec.template.spec.containers[0].workingDir
- equal:
path: spec.template.spec.replicatedJobs[0].template.spec.template.spec.containers[0].securityContext
value:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
- equal:
path: spec.template.spec.replicatedJobs[1].template.spec.template.spec.securityContext
value:
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
- equal:
path: spec.template.spec.replicatedJobs[1].template.spec.template.spec.containers[0].workingDir
value: /tmp
- equal:
path: spec.template.spec.replicatedJobs[1].template.spec.template.spec.containers[0].securityContext
value:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,23 @@ spec:
template:
spec:
serviceAccountName: kubeflow-trainer-cache-initializer
securityContext:
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: dataset-initializer
image: ghcr.io/kubeflow/trainer/dataset-initializer
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
env:
- name: CACHE_IMAGE
value: "ghcr.io/kubeflow/trainer/data-cache:latest"
Expand All @@ -58,9 +72,24 @@ spec:
spec:
template:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: node
image: pytorch/pytorch:2.10.0-cuda12.8-cudnn9-runtime
workingDir: /tmp
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
env:
- name: TRAIN_JOB_NAME
valueFrom:
Expand Down
15 changes: 15 additions & 0 deletions manifests/base/runtimes/torch_distributed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ spec:
spec:
template:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: node
image: pytorch/pytorch:2.10.0-cuda12.8-cudnn9-runtime
workingDir: /tmp
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
Loading