cncf-tags / container-device-interface

Apache License 2.0
216 stars 39 forks source link

Tutorial / How-to for creating a CDI spec #234

Open wahabk opened 1 month ago

wahabk commented 1 month ago

Hello, thank you for making CDI and unifying device interfaces into a spec that is relatively simple. I'm working with a vendor to create a spec and test it in podman. I know what device nodes / driver files / environment variables I need to set.

Thank you for creating the example, I have 2 questions:

  1. How can I use the repo to validat/generate a spec?
  2. Is there a plan to write a documentation how-to?

Thanks!

wahabk commented 1 month ago

Showing my working out so it helps with generating examples.

Something like the following would help an uninitiated user start quickly:

Requirements

Installation

git clone https://github.com/cncf-tags/container-device-interface.git
cd container-device-interface
make
export PATH=$PATH:$(realpath bin)

Example: Validating a spec

$ validate /etc/cdi/nvidia.yaml 
Validating against JSON schema builtin...
/etc/cdi/nvidia.yaml: document is valid.
wahabk commented 1 month ago

To clarify, I'm still confused as to the functionality of this repo.

$ cdi inject test.yaml /dev/nvidia0
Updated OCI Spec:
  ociVersion: ""
$ cdi resolve test.yaml 
  ociVersion: ""

I've been using the help functionality of the CLI which is great, but there are no manpages.

The only example I can find of a generated CDI online is Nvidia's GPUs. So it is unclear to me how to generate a spec from scratch.