2022-03-02 23:47:27 +00:00
|
|
|
//go:build windows
|
2021-06-01 19:29:46 +00:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package containerd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-03-29 23:16:34 +00:00
|
|
|
"github.com/containerd/containerd"
|
2022-03-02 23:47:27 +00:00
|
|
|
"github.com/k3s-io/k3s/pkg/agent/templates"
|
|
|
|
"github.com/k3s-io/k3s/pkg/daemons/config"
|
2022-12-09 23:42:15 +00:00
|
|
|
util3 "github.com/k3s-io/k3s/pkg/util"
|
|
|
|
"github.com/pkg/errors"
|
2021-06-10 19:27:00 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"k8s.io/kubernetes/pkg/kubelet/util"
|
2021-06-01 19:29:46 +00:00
|
|
|
)
|
|
|
|
|
2021-06-10 19:27:00 +00:00
|
|
|
func getContainerdArgs(cfg *config.Node) []string {
|
|
|
|
args := []string{
|
|
|
|
"containerd",
|
|
|
|
"-c", cfg.Containerd.Config,
|
|
|
|
}
|
|
|
|
return args
|
|
|
|
}
|
|
|
|
|
2021-06-01 19:29:46 +00:00
|
|
|
// setupContainerdConfig generates the containerd.toml, using a template combined with various
|
|
|
|
// runtime configurations and registry mirror settings provided by the administrator.
|
|
|
|
func setupContainerdConfig(ctx context.Context, cfg *config.Node) error {
|
2021-06-10 19:27:00 +00:00
|
|
|
if cfg.SELinux {
|
|
|
|
logrus.Warn("SELinux isn't supported on windows")
|
|
|
|
}
|
|
|
|
|
|
|
|
containerdConfig := templates.ContainerdConfig{
|
|
|
|
NodeConfig: cfg,
|
|
|
|
DisableCgroup: true,
|
2022-04-18 23:06:50 +00:00
|
|
|
SystemdCgroup: false,
|
2021-06-10 19:27:00 +00:00
|
|
|
IsRunningInUserNS: false,
|
2023-12-05 18:16:22 +00:00
|
|
|
PrivateRegistryConfig: cfg.AgentConfig.Registry,
|
2023-11-30 02:14:01 +00:00
|
|
|
NoDefaultEndpoint: cfg.Containerd.NoDefault,
|
2021-06-10 19:27:00 +00:00
|
|
|
}
|
|
|
|
|
2023-11-30 02:14:01 +00:00
|
|
|
if err := writeContainerdConfig(cfg, containerdConfig); err != nil {
|
2021-06-10 19:27:00 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-11-30 02:14:01 +00:00
|
|
|
return writeContainerdHosts(cfg, containerdConfig)
|
2021-06-10 19:27:00 +00:00
|
|
|
}
|
|
|
|
|
2022-03-29 23:16:34 +00:00
|
|
|
func Client(address string) (*containerd.Client, error) {
|
|
|
|
addr, _, err := util.GetAddressAndDialer(address)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return containerd.New(addr)
|
|
|
|
}
|
2022-12-09 23:42:15 +00:00
|
|
|
|
|
|
|
func OverlaySupported(root string) error {
|
|
|
|
return errors.Wrapf(util3.ErrUnsupportedPlatform, "overlayfs is not supported")
|
|
|
|
}
|
|
|
|
|
|
|
|
func FuseoverlayfsSupported(root string) error {
|
|
|
|
return errors.Wrapf(util3.ErrUnsupportedPlatform, "fuse-overlayfs is not supported")
|
|
|
|
}
|
|
|
|
|
|
|
|
func StargzSupported(root string) error {
|
|
|
|
return errors.Wrapf(util3.ErrUnsupportedPlatform, "stargz is not supported")
|
|
|
|
}
|