-
Notifications
You must be signed in to change notification settings - Fork 129
Description
FR description
Currently, the k8s-dra-driver-gpu container image relies on several bash scripts during runtime:
hack/kubelet-plugin-prestart.sh(Used as the entrypoint for theinit-kubelet-plugininitContainer).scripts/bind_to_driver.sh(Executed viaos/execin the Go kubelet plugin).scripts/unbind_from_driver.sh(Executed viaos/execin the Go kubelet plugin).
Because of these runtime dependencies, the Dockerfile has to explicitly download and copy a static bash binary (ghcr.io/nvidia/k8s-dra-driver-gpu:v25.12.0-dev-839e966a) into the final image.
This reliance on a shell environment prevents the project from adopting pure, zero-shell distroless base images (like gcr.io/distroless/static or gcr.io/distroless/base). In strict, highly-regulated enterprise Kubernetes environments (where supply chain security and minimizing the attack surface are critical), deploying containers that contain a shell is increasingly flagged by security policies.
Describe the solution you'd like
I propose we refactor the logic currently contained in these bash scripts directly into the Go codebase. This would allow us to completely eliminate the bash dependency from the final container image.
Proposed Implementation Path:
-
bind_to_driver.sh&unbind_from_driver.sh:- These scripts primarily handle reading and writing to
sysfs(/sys/bus/pci/...) andprocfs(/proc/driver/nvidia/...). - We can replace the
exec.Commandcalls incmd/gpu-kubelet-plugin/vfio-device.gowith native Go file I/O (os.WriteFile,
os.ReadFile, etc.). This will also improve error handling, as we won't have to parsestdout/stderrfrom a subprocess.
- These scripts primarily handle reading and writing to
-
kubelet-plugin-prestart.sh: (less important)- This script acts as an init container, looping to check for the presence and health of
nvidia-smiandlibnvidia-ml.so.1on the host mount. - We can implement this logic as a new subcommand in the existing
gpu-kubelet-pluginbinary (e.g.,gpu-kubelet-plugin prestart-init) or as a tiny, separate Go binary built alongside the others.
- This script acts as an init container, looping to check for the presence and health of
Additional thoughts
I'd also love to hear if there were some special considerations behind the reason for using shell scripts over golang code.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status