Skip to content

Commit cf613ef

Browse files
authored
fix: add security context for hypervisor (#285)
1 parent 9d00999 commit cf613ef

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

internal/constants/env.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ const (
121121
HypervisorMetricsExtraLabelsEnv = "TF_HYPERVISOR_METRICS_EXTRA_LABELS"
122122
HypervisorDetectUsedGPUEnv = "DETECT_IN_USED_GPUS"
123123

124+
// Add ptrace capability to hypervisor container, to trace all host PID using GPU
125+
SystemPtraceCapability = "SYS_PTRACE"
126+
124127
HypervisorDefaultPortNumber int32 = 8000
125128
HypervisorPortName string = "http"
126129

internal/utils/compose.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,14 @@ func composeHypervisorContainer(spec *v1.PodSpec, pool *tfv1.GPUPool) {
386386
MountPath: constants.KubeletDevicePluginPath,
387387
})
388388

389+
spec.Containers[0].SecurityContext = &v1.SecurityContext{
390+
Capabilities: &v1.Capabilities{
391+
Add: []v1.Capability{
392+
constants.SystemPtraceCapability,
393+
},
394+
},
395+
}
396+
389397
port := getHypervisorPortNumber(pool.Spec.ComponentConfig.Hypervisor)
390398
spec.ServiceAccountName = constants.HypervisorServiceAccountName
391399
spec.Containers[0].Env = append(spec.Containers[0].Env, v1.EnvVar{

0 commit comments

Comments
 (0)