-
Notifications
You must be signed in to change notification settings - Fork 43
Add multi OS support #439
Description
Problem statement
One key advantage of Clear Containers over runc
containers is the ability for each container/pod to run on top of its own kernel and guest image.
For customized workloads like e.g. NFV ones, this is very important as they sometimes need some specific kernel features that can be mutually exclusive with other workload needs.
Unfortunately, the OCI runtime specifications do not allow (yet) for specifying a kernel and guest image and thus virtcontainers
callers can only use a default path for each of those and pass it through the HypervisorConfig
structure.
Proposed solutions
We want to be able to define a kernel and a guest image paths per container/pod. Both of them should be absolute paths, and should be optional. In other words, there must be a default value for those paths which will be passed to virtcontainers through the HypervisorConfig
structure. Clear Containers, for example, gets the default paths for its kernel and guest image through the configuration.toml
system wide configuration file.
Short term solution: Annotations
As a short term solution we are going to use virtcontainers namespaced pod annotations for passing a kernel and guest image absolute path:
// KernelPath is a pod annotation for passing a per container path pointing at the kernel needed to boot the container VM.
KernelPath = "com.github.containers.virtcontainers.KernelPath"
// ImagePath is an pod annotation for passing a per container path pointing at the guest image that will run the container VM.
ImagePath = "com.github.containers.virtcontainers.ImagePath"
Both annotations can be set through virtcontainers
PodConfig
annotations. Kernel or image path ContainerConfig
annotations will be ignored.
Long term solution: OCI specification changes
See opencontainers/runtime-spec#405
Code path
The virtcontainers code path should be identical for both solutions: The pod.go
will trap pod creation request and modify its config.HypervisorConfig
structure if there is an ImagePath
and/or KernelPath
annotation as part of its PodConfig
The pkg/oci/utils.go
file will be responsible for adding the right pod annotation, either by parsing the OCI config.json
annotations or by parsing the future VM specific section in that file. The latter should take precedence over the former.
Error handling
If any of the kernel or guest image path is invalid (empty files, or inexistent ones), virtcontainers
will error out and stop creating the pod's VM. Passing an image or/and a guest image into the container configuration file is a very specific requirement from the user and thus switching to the default value when one of those paths is invalid could be misleading and error prone.
Security
Optionally virtcontainers
callers can require kernel and/or image binaries integrity checking. For that purpose, virtcontainers
will handle 2 additional annotations:
// KernelHash is a pod annotation for passing a container kernel image SHA-512 hash value.
KernelHash = "com.github.containers.virtcontainers.KernelHash"
// ImageHash is an pod annotation for passing a container guest image SHA-512 hash value.
ImageHash = "com.github.containers.virtcontainers.ImageHash"
By default virtcontainers
will not verify the kernel and image binaries integrity unless one or both of the hash annotations are passed in the PodConfig
annotations. In the latter case, virtcontainers
will build SHA-512 hashes on the kernel or/and image binaries and compare that against the passed annotations.