feat: Add a CLI to help prepare a precompiled driver image - #658
Open
dlipovetsky wants to merge 1 commit into
Open
dlipovetsky wants to merge 1 commit into
dlipovetsky wants to merge 1 commit into
Conversation
dlipovetsky
force-pushed
the
prepareimage-cli
branch
from
September 24, 2026 19:22
5135dc6 to
068b73e
Compare
Author
|
I first asked about a CLI for this purpose in this discussion: #641 |
dlipovetsky
marked this pull request as ready for review
September 24, 2026 21:03
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
There are many reasons to use precompiled driver container images. There is not an official upstream source of these images, so users need to create their own.
The process for doing that right now is described in https://instinct.docs.amd.com/projects/gpu-operator/en/latest/drivers/precompiled-driver.html. Because it takes multiple steps, and copying/pasting, it can be prone to errors.
This PR proposes a CLI to simplify the process. It takes the guess work out of choosing the right Dockerfile template, as well as using the correct image tag.
Demo:
Note that the default output is shell script that embeds the Dockerfile, and executes a
docker buildcommand. This is needed in order to guarantee the right image tag is used, since the tag cannot be defined by the Dockerfile itself. If the wrong image tag is used, the operator will not find the image.The CLI can emit shell scripts for docker, podman, or buildah. The CLI can also output just the Dockerfile, and leave the rest to the user. See the
-formatflag.The user can specify the drivers version, kernel version, as well as other inputs. The CLI assigns the values as defaults to the build args in the Dockerfile, so that the user does not need to set build args.
Technical Details
The CLI uses the same functions as the operator uses in the cluster to derive the Dockerfile. The API surface is very small: it imports
internal/kmmoduleand callsGetOSName,GetCMName. It also calls theNewKMMModuleconstructor, and thenSetBuildConfigMapAsDesiredto derive the Dockerfile.Test Plan
I have added unit tests that exercise creation of the output. They are not exhaustive, but I will expand them, if the project is interested in merging this PR.
Test Result
The CLI defines its own unit tests, which are passing. The CLI is separate from the operator.
Submission Checklist