mirror of
https://git.vectorsigma.ru/public/k3s.git
synced 2026-07-28 23:09:37 +00:00
Create a generic helper function that finds extra containerd runtimes. The code was originally inside of the nvidia container discovery file. Signed-off-by: Flavio Castelli <fcastelli@suse.com> Discover the containerd shims based on runwasi that are already available on the node. The runtimes could have been installed either by a package manager or by the kwasm operator. Signed-off-by: Flavio Castelli <fcastelli@suse.com> The containerd configuration on a Linux system now handles the nvidia and the WebAssembly runtimes. Signed-off-by: Flavio Castelli <fcastelli@suse.com> --------- Signed-off-by: Flavio Castelli <fcastelli@suse.com>
61 lines
1.9 KiB
Go
61 lines
1.9 KiB
Go
//go:build linux
|
|
// +build linux
|
|
|
|
package containerd
|
|
|
|
import (
|
|
"io/fs"
|
|
)
|
|
|
|
// findWasiRuntimes returns a list of WebAssembly (WASI) container runtimes that
|
|
// are available on the system. It checks install locations used by the kwasm
|
|
// operator and by system package managers. The kwasm operator installation
|
|
// takes precedence over the system package manager installation.
|
|
// The given fs.FS should represent the filesystem root directory to search in.
|
|
func findWasiRuntimes(root fs.FS,
|
|
foundRuntimes runtimeConfigs,
|
|
) {
|
|
// Check these locations in order. The GPU operator's installation should
|
|
// take precedence over the package manager's installation.
|
|
locationsToCheck := []string{
|
|
"opt/kwasm/bin", // Path when installing via kwasm Operator
|
|
"usr/bin", // Path when installing via package manager
|
|
"usr/sbin", // Path when installing via package manager
|
|
}
|
|
|
|
// Fill in the binary location with just the name of the binary,
|
|
// and check against each of the possible locations. If a match is found,
|
|
// set the location to the full path.
|
|
potentialRuntimes := runtimeConfigs{
|
|
"lunatic": {
|
|
RuntimeType: "io.containerd.lunatic.v2",
|
|
BinaryName: "containerd-shim-lunatic-v1",
|
|
},
|
|
"slight": {
|
|
RuntimeType: "io.containerd.slight.v2",
|
|
BinaryName: "containerd-shim-slight-v1",
|
|
},
|
|
"spin": {
|
|
RuntimeType: "io.containerd.spin.v2",
|
|
BinaryName: "containerd-shim-spin-v1",
|
|
},
|
|
"wws": {
|
|
RuntimeType: "io.containerd.wws.v2",
|
|
BinaryName: "containerd-shim-wws-v1",
|
|
},
|
|
"wasmedge": {
|
|
RuntimeType: "io.containerd.wasmedge.v2",
|
|
BinaryName: "containerd-shim-wasmedge-v1",
|
|
},
|
|
"wasmer": {
|
|
RuntimeType: "io.containerd.wasmer.v2",
|
|
BinaryName: "containerd-shim-wasmer-v1",
|
|
},
|
|
"wasmtime": {
|
|
RuntimeType: "io.containerd.wasmtime.v2",
|
|
BinaryName: "containerd-shim-wasmtime-v1",
|
|
},
|
|
}
|
|
findContainerRuntimes(root, potentialRuntimes, locationsToCheck, foundRuntimes)
|
|
}
|