Skip to content

Commit

Permalink
feature(main): support crun youki gvisor kata
Browse files Browse the repository at this point in the history
Signed-off-by: cuisongliu <[email protected]>
  • Loading branch information
cuisongliu committed Oct 29, 2023
1 parent 2015389 commit c231a49
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions staging/src/github.com/labring/image-cri-shim/pkg/cri/cri.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ func (runtime *ContainerdRuntime) configFile() {

func (runtime *ContainerdRuntime) processConfigFile() (string, error) {
// Config is a wrapper of server config for printing out.
type Runtime struct {
RuntimeType string `toml:"runtime_type"`
RuntimeEngine string `toml:"runtime_engine"`
RuntimeRoot string `toml:"runtime_root"`
Options struct {
SystemdCgroup bool `toml:"SystemdCgroup"`
BinaryName string `toml:"BinaryName"`
} `toml:"options"`
}
type Config struct {
Version int `toml:"version"`
Root string `toml:"root"`
Expand All @@ -176,14 +185,11 @@ func (runtime *ContainerdRuntime) processConfigFile() (string, error) {
Snapshotter string `toml:"snapshotter"`
DefaultRuntimeName string `toml:"default_runtime_name"`
Runtimes struct {
Runc struct {
RuntimeType string `toml:"runtime_type"`
RuntimeEngine string `toml:"runtime_engine"`
RuntimeRoot string `toml:"runtime_root"`
Options struct {
SystemdCgroup bool `toml:"SystemdCgroup"`
} `toml:"options"`
} `toml:"runc"`
Crun Runtime `toml:"crun"`
Gvisor Runtime `toml:"gvisor"`
Kata Runtime `toml:"kata"`
Youki Runtime `toml:"youki"`
Runc Runtime `toml:"runc"`
} `toml:"runtimes"`
} `toml:"containerd"`
} `toml:"io.containerd.grpc.v1.cri"`
Expand All @@ -199,8 +205,23 @@ func (runtime *ContainerdRuntime) processConfigFile() (string, error) {
if err != nil {
return "", err
}
if config.Plugins.IoContainerdGrpcV1Cri.Containerd.Runtimes.Runc.Options.SystemdCgroup {
return DefaultSystemdCgroupDriver, nil
var containerRuntime *Runtime
switch config.Plugins.IoContainerdGrpcV1Cri.Containerd.DefaultRuntimeName {
case "runc":
containerRuntime = &config.Plugins.IoContainerdGrpcV1Cri.Containerd.Runtimes.Runc
case "crun":
containerRuntime = &config.Plugins.IoContainerdGrpcV1Cri.Containerd.Runtimes.Crun
case "youki":
containerRuntime = &config.Plugins.IoContainerdGrpcV1Cri.Containerd.Runtimes.Youki
case "gvisor":
containerRuntime = &config.Plugins.IoContainerdGrpcV1Cri.Containerd.Runtimes.Gvisor
case "kata":
containerRuntime = &config.Plugins.IoContainerdGrpcV1Cri.Containerd.Runtimes.Kata
}
if containerRuntime != nil {
if containerRuntime.Options.SystemdCgroup {
return DefaultSystemdCgroupDriver, nil
}
}
}
return DefaultCgroupDriver, nil
Expand Down

0 comments on commit c231a49

Please sign in to comment.