mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
Add support for containerd to the runtime configure CLI
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
f1e201d368
commit
70920d7a04
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## v1.14.0-rc.1
|
## v1.14.0-rc.1
|
||||||
|
|
||||||
|
* Add support for updating containerd configs to the `nvidia-ctk runtime configure` command.
|
||||||
|
|
||||||
## v1.13.1
|
## v1.13.1
|
||||||
|
|
||||||
* Update `update-ldcache` hook to only update ldcache if it exists.
|
* Update `update-ldcache` hook to only update ldcache if it exists.
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/config/engine"
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/config/engine"
|
||||||
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/config/engine/containerd"
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/config/engine/crio"
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/config/engine/crio"
|
||||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/config/engine/docker"
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/config/engine/docker"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -36,8 +37,9 @@ const (
|
|||||||
defaultNVIDIARuntimeExecutable = "nvidia-container-runtime"
|
defaultNVIDIARuntimeExecutable = "nvidia-container-runtime"
|
||||||
defailtNVIDIARuntimeExpecutablePath = "/usr/bin/nvidia-container-runtime"
|
defailtNVIDIARuntimeExpecutablePath = "/usr/bin/nvidia-container-runtime"
|
||||||
|
|
||||||
defaultCrioConfigFilePath = "/etc/crio/crio.conf"
|
defaultContainerdConfigFilePath = "/etc/containerd/config.toml"
|
||||||
defaultDockerConfigFilePath = "/etc/docker/daemon.json"
|
defaultCrioConfigFilePath = "/etc/crio/crio.conf"
|
||||||
|
defaultDockerConfigFilePath = "/etc/docker/daemon.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type command struct {
|
type command struct {
|
||||||
@ -90,7 +92,7 @@ func (m command) build() *cli.Command {
|
|||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "runtime",
|
Name: "runtime",
|
||||||
Usage: "the target runtime engine; one of [crio, docker]",
|
Usage: "the target runtime engine; one of [containerd, crio, docker]",
|
||||||
Value: defaultRuntime,
|
Value: defaultRuntime,
|
||||||
Destination: &config.runtime,
|
Destination: &config.runtime,
|
||||||
},
|
},
|
||||||
@ -125,14 +127,14 @@ func (m command) build() *cli.Command {
|
|||||||
|
|
||||||
func validateFlags(c *cli.Context, config *config) error {
|
func validateFlags(c *cli.Context, config *config) error {
|
||||||
switch config.runtime {
|
switch config.runtime {
|
||||||
case "crio", "docker":
|
case "containerd", "crio", "docker":
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unrecognized runtime '%v'", config.runtime)
|
return fmt.Errorf("unrecognized runtime '%v'", config.runtime)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch config.runtime {
|
switch config.runtime {
|
||||||
case "crio":
|
case "containerd", "crio":
|
||||||
if config.nvidiaRuntime.path == defaultNVIDIARuntimeExecutable {
|
if config.nvidiaRuntime.path == defaultNVIDIARuntimeExecutable {
|
||||||
config.nvidiaRuntime.path = defailtNVIDIARuntimeExpecutablePath
|
config.nvidiaRuntime.path = defailtNVIDIARuntimeExpecutablePath
|
||||||
}
|
}
|
||||||
@ -151,6 +153,10 @@ func (m command) configureWrapper(c *cli.Context, config *config) error {
|
|||||||
var cfg engine.Interface
|
var cfg engine.Interface
|
||||||
var err error
|
var err error
|
||||||
switch config.runtime {
|
switch config.runtime {
|
||||||
|
case "containerd":
|
||||||
|
cfg, err = containerd.New(
|
||||||
|
containerd.WithPath(configFilePath),
|
||||||
|
)
|
||||||
case "crio":
|
case "crio":
|
||||||
cfg, err = crio.New(
|
cfg, err = crio.New(
|
||||||
crio.WithPath(configFilePath),
|
crio.WithPath(configFilePath),
|
||||||
@ -197,6 +203,8 @@ func (c *config) resolveConfigFilePath() string {
|
|||||||
return c.configFilePath
|
return c.configFilePath
|
||||||
}
|
}
|
||||||
switch c.runtime {
|
switch c.runtime {
|
||||||
|
case "containerd":
|
||||||
|
return defaultContainerdConfigFilePath
|
||||||
case "crio":
|
case "crio":
|
||||||
return defaultCrioConfigFilePath
|
return defaultCrioConfigFilePath
|
||||||
case "docker":
|
case "docker":
|
||||||
|
Loading…
Reference in New Issue
Block a user