mirror of https://github.com/k3s-io/k3s
Revert "Remove --docker/dockershim support"
This reverts commit 4a3d283bc1
.
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
pull/5979/head
parent
cf66559940
commit
b1fa63dfb7
|
@ -321,10 +321,6 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
|
|||
logrus.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
|
||||
if envInfo.Docker {
|
||||
return nil, errors.New("--docker is no longer supported; to continue using docker, install cri-dockerd and set --container-runtime-endpoint")
|
||||
}
|
||||
|
||||
info, err := clientaccess.ParseAndValidateToken(proxy.SupervisorURL(), envInfo.Token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -437,6 +433,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
|
|||
}
|
||||
|
||||
nodeConfig := &config.Node{
|
||||
Docker: envInfo.Docker,
|
||||
SELinux: envInfo.EnableSELinux,
|
||||
ContainerRuntimeEndpoint: envInfo.ContainerRuntimeEndpoint,
|
||||
FlannelBackend: controlConfig.FlannelBackend,
|
||||
|
@ -466,7 +463,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
|
|||
nodeConfig.AgentConfig.StrongSwanDir = filepath.Join(envInfo.DataDir, "agent", "strongswan")
|
||||
nodeConfig.Containerd.Config = filepath.Join(envInfo.DataDir, "agent", "etc", "containerd", "config.toml")
|
||||
nodeConfig.Containerd.Root = filepath.Join(envInfo.DataDir, "agent", "containerd")
|
||||
if nodeConfig.ContainerRuntimeEndpoint == "" {
|
||||
if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" {
|
||||
switch nodeConfig.AgentConfig.Snapshotter {
|
||||
case "overlayfs":
|
||||
if err := containerd.OverlaySupported(nodeConfig.Containerd.Root); err != nil {
|
||||
|
@ -539,7 +536,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
|
|||
nodeConfig.AgentConfig.FlannelCniConfFile = envInfo.FlannelCniConfFile
|
||||
}
|
||||
|
||||
if nodeConfig.ContainerRuntimeEndpoint == "" {
|
||||
if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" {
|
||||
nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.Containerd.Address
|
||||
} else {
|
||||
nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.ContainerRuntimeEndpoint
|
||||
|
|
|
@ -62,7 +62,7 @@ func Test_createFlannelConf(t *testing.T) {
|
|||
var agent = config.Agent{}
|
||||
agent.ClusterCIDR = stringToCIDR(tt.args)[0]
|
||||
agent.ClusterCIDRs = stringToCIDR(tt.args)
|
||||
var nodeConfig = &config.Node{ContainerRuntimeEndpoint: "", NoFlannel: false, SELinux: false, FlannelBackend: "vxlan", FlannelConfFile: "test_file", FlannelConfOverride: false, FlannelIface: nil, Containerd: containerd, Images: "", AgentConfig: agent, Token: "", Certificate: nil, ServerHTTPSPort: 0}
|
||||
var nodeConfig = &config.Node{Docker: false, ContainerRuntimeEndpoint: "", NoFlannel: false, SELinux: false, FlannelBackend: "vxlan", FlannelConfFile: "test_file", FlannelConfOverride: false, FlannelIface: nil, Containerd: containerd, Images: "", AgentConfig: agent, Token: "", Certificate: nil, ServerHTTPSPort: 0}
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := createFlannelConf(nodeConfig); (err != nil) != tt.wantErr {
|
||||
|
|
|
@ -101,7 +101,7 @@ func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error {
|
|||
}
|
||||
}
|
||||
|
||||
if nodeConfig.ContainerRuntimeEndpoint == "" {
|
||||
if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" {
|
||||
if err := containerd.Run(ctx, nodeConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
dockershimSock = "unix:///var/run/dockershim.sock"
|
||||
containerdSock = "unix:///run/k3s/containerd/containerd.sock"
|
||||
)
|
||||
|
||||
|
@ -21,7 +22,12 @@ const (
|
|||
func setupCriCtlConfig(cfg cmds.Agent, nodeConfig *config.Node) error {
|
||||
cre := nodeConfig.ContainerRuntimeEndpoint
|
||||
if cre == "" {
|
||||
cre = containerdSock
|
||||
switch {
|
||||
case cfg.Docker:
|
||||
cre = dockershimSock
|
||||
default:
|
||||
cre = containerdSock
|
||||
}
|
||||
}
|
||||
|
||||
agentConfDir := filepath.Join(cfg.DataDir, "agent", "etc")
|
||||
|
|
|
@ -7,12 +7,14 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/k3s-io/k3s/pkg/cli/cmds"
|
||||
"github.com/k3s-io/k3s/pkg/daemons/config"
|
||||
)
|
||||
|
||||
const (
|
||||
dockershimSock = "npipe:////./pipe/docker_engine"
|
||||
containerdSock = "npipe:////./pipe/containerd-containerd"
|
||||
)
|
||||
|
||||
|
@ -20,10 +22,16 @@ const (
|
|||
// with the given data from config.
|
||||
func setupCriCtlConfig(cfg cmds.Agent, nodeConfig *config.Node) error {
|
||||
cre := nodeConfig.ContainerRuntimeEndpoint
|
||||
if cre == "" {
|
||||
if cre == "" || strings.HasPrefix(cre, "npipe:") {
|
||||
switch {
|
||||
case cfg.Docker:
|
||||
cre = dockershimSock
|
||||
default:
|
||||
cre = containerdSock
|
||||
}
|
||||
} else {
|
||||
cre = containerdSock
|
||||
}
|
||||
|
||||
agentConfDir := filepath.Join(cfg.DataDir, "agent", "etc")
|
||||
if _, err := os.Stat(agentConfDir); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(agentConfDir, 0700); err != nil {
|
||||
|
|
|
@ -109,6 +109,9 @@ func CheckCgroups() (kubeletRoot, runtimeRoot string, controllers map[string]boo
|
|||
// and thus need to set our kubelet root to something out of the context
|
||||
// of `/user.slice` to ensure that `CPUAccounting` and `MemoryAccounting`
|
||||
// are enabled, as they are generally disabled by default for `user.slice`
|
||||
// Note that we are not setting the `runtimeRoot` as if we are running with
|
||||
// `--docker`, we will inadvertently move the cgroup `dockerd` lives in
|
||||
// which is not ideal and causes dockerd to become unmanageable by systemd.
|
||||
last := parts[len(parts)-1]
|
||||
i := strings.LastIndex(last, ".scope")
|
||||
if i > 0 {
|
||||
|
|
|
@ -123,7 +123,7 @@ var (
|
|||
}
|
||||
PauseImageFlag = cli.StringFlag{
|
||||
Name: "pause-image",
|
||||
Usage: "(agent/runtime) Customized pause image for containerd sandbox",
|
||||
Usage: "(agent/runtime) Customized pause image for containerd or docker sandbox",
|
||||
Destination: &AgentConfig.PauseImage,
|
||||
Value: DefaultPauseImage,
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ var KubeletReservedPorts = map[string]bool{
|
|||
}
|
||||
|
||||
type Node struct {
|
||||
Docker bool
|
||||
ContainerRuntimeEndpoint string
|
||||
NoFlannel bool
|
||||
SELinux bool
|
||||
|
|
Loading…
Reference in New Issue