Commit 4a3d283b authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Remove --docker/dockershim support

parent 360f18d1
...@@ -321,6 +321,10 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N ...@@ -321,6 +321,10 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
logrus.SetLevel(logrus.DebugLevel) 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) info, err := clientaccess.ParseAndValidateToken(proxy.SupervisorURL(), envInfo.Token)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -433,7 +437,6 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N ...@@ -433,7 +437,6 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
} }
nodeConfig := &config.Node{ nodeConfig := &config.Node{
Docker: envInfo.Docker,
SELinux: envInfo.EnableSELinux, SELinux: envInfo.EnableSELinux,
ContainerRuntimeEndpoint: envInfo.ContainerRuntimeEndpoint, ContainerRuntimeEndpoint: envInfo.ContainerRuntimeEndpoint,
FlannelBackend: controlConfig.FlannelBackend, FlannelBackend: controlConfig.FlannelBackend,
...@@ -462,7 +465,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N ...@@ -462,7 +465,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
nodeConfig.AgentConfig.StrongSwanDir = filepath.Join(envInfo.DataDir, "agent", "strongswan") nodeConfig.AgentConfig.StrongSwanDir = filepath.Join(envInfo.DataDir, "agent", "strongswan")
nodeConfig.Containerd.Config = filepath.Join(envInfo.DataDir, "agent", "etc", "containerd", "config.toml") nodeConfig.Containerd.Config = filepath.Join(envInfo.DataDir, "agent", "etc", "containerd", "config.toml")
nodeConfig.Containerd.Root = filepath.Join(envInfo.DataDir, "agent", "containerd") nodeConfig.Containerd.Root = filepath.Join(envInfo.DataDir, "agent", "containerd")
if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" { if nodeConfig.ContainerRuntimeEndpoint == "" {
switch nodeConfig.AgentConfig.Snapshotter { switch nodeConfig.AgentConfig.Snapshotter {
case "overlayfs": case "overlayfs":
if err := containerd.OverlaySupported(nodeConfig.Containerd.Root); err != nil { if err := containerd.OverlaySupported(nodeConfig.Containerd.Root); err != nil {
...@@ -531,7 +534,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N ...@@ -531,7 +534,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
nodeConfig.AgentConfig.CNIConfDir = filepath.Join(envInfo.DataDir, "agent", "etc", "cni", "net.d") nodeConfig.AgentConfig.CNIConfDir = filepath.Join(envInfo.DataDir, "agent", "etc", "cni", "net.d")
} }
if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" { if nodeConfig.ContainerRuntimeEndpoint == "" {
nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.Containerd.Address nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.Containerd.Address
} else { } else {
nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.ContainerRuntimeEndpoint nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.ContainerRuntimeEndpoint
......
...@@ -62,7 +62,7 @@ func Test_createFlannelConf(t *testing.T) { ...@@ -62,7 +62,7 @@ func Test_createFlannelConf(t *testing.T) {
var agent = config.Agent{} var agent = config.Agent{}
agent.ClusterCIDR = stringToCIDR(tt.args)[0] agent.ClusterCIDR = stringToCIDR(tt.args)[0]
agent.ClusterCIDRs = stringToCIDR(tt.args) agent.ClusterCIDRs = stringToCIDR(tt.args)
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} 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}
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
if err := createFlannelConf(nodeConfig); (err != nil) != tt.wantErr { if err := createFlannelConf(nodeConfig); (err != nil) != tt.wantErr {
......
...@@ -100,7 +100,7 @@ func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error { ...@@ -100,7 +100,7 @@ func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error {
} }
} }
if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" { if nodeConfig.ContainerRuntimeEndpoint == "" {
if err := containerd.Run(ctx, nodeConfig); err != nil { if err := containerd.Run(ctx, nodeConfig); err != nil {
return err return err
} }
......
...@@ -13,7 +13,6 @@ import ( ...@@ -13,7 +13,6 @@ import (
) )
const ( const (
dockershimSock = "unix:///var/run/dockershim.sock"
containerdSock = "unix:///run/k3s/containerd/containerd.sock" containerdSock = "unix:///run/k3s/containerd/containerd.sock"
) )
...@@ -22,12 +21,7 @@ const ( ...@@ -22,12 +21,7 @@ const (
func setupCriCtlConfig(cfg cmds.Agent, nodeConfig *config.Node) error { func setupCriCtlConfig(cfg cmds.Agent, nodeConfig *config.Node) error {
cre := nodeConfig.ContainerRuntimeEndpoint cre := nodeConfig.ContainerRuntimeEndpoint
if cre == "" { if cre == "" {
switch { cre = containerdSock
case cfg.Docker:
cre = dockershimSock
default:
cre = containerdSock
}
} }
agentConfDir := filepath.Join(cfg.DataDir, "agent", "etc") agentConfDir := filepath.Join(cfg.DataDir, "agent", "etc")
......
...@@ -7,14 +7,12 @@ import ( ...@@ -7,14 +7,12 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"github.com/k3s-io/k3s/pkg/cli/cmds" "github.com/k3s-io/k3s/pkg/cli/cmds"
"github.com/k3s-io/k3s/pkg/daemons/config" "github.com/k3s-io/k3s/pkg/daemons/config"
) )
const ( const (
dockershimSock = "npipe:////./pipe/docker_engine"
containerdSock = "npipe:////./pipe/containerd-containerd" containerdSock = "npipe:////./pipe/containerd-containerd"
) )
...@@ -22,16 +20,10 @@ const ( ...@@ -22,16 +20,10 @@ const (
// with the given data from config. // with the given data from config.
func setupCriCtlConfig(cfg cmds.Agent, nodeConfig *config.Node) error { func setupCriCtlConfig(cfg cmds.Agent, nodeConfig *config.Node) error {
cre := nodeConfig.ContainerRuntimeEndpoint cre := nodeConfig.ContainerRuntimeEndpoint
if cre == "" || strings.HasPrefix(cre, "npipe:") { if cre == "" {
switch {
case cfg.Docker:
cre = dockershimSock
default:
cre = containerdSock
}
} else {
cre = containerdSock cre = containerdSock
} }
agentConfDir := filepath.Join(cfg.DataDir, "agent", "etc") agentConfDir := filepath.Join(cfg.DataDir, "agent", "etc")
if _, err := os.Stat(agentConfDir); os.IsNotExist(err) { if _, err := os.Stat(agentConfDir); os.IsNotExist(err) {
if err := os.MkdirAll(agentConfDir, 0700); err != nil { if err := os.MkdirAll(agentConfDir, 0700); err != nil {
......
...@@ -109,9 +109,6 @@ func CheckCgroups() (kubeletRoot, runtimeRoot string, controllers map[string]boo ...@@ -109,9 +109,6 @@ func CheckCgroups() (kubeletRoot, runtimeRoot string, controllers map[string]boo
// and thus need to set our kubelet root to something out of the context // and thus need to set our kubelet root to something out of the context
// of `/user.slice` to ensure that `CPUAccounting` and `MemoryAccounting` // of `/user.slice` to ensure that `CPUAccounting` and `MemoryAccounting`
// are enabled, as they are generally disabled by default for `user.slice` // 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] last := parts[len(parts)-1]
i := strings.LastIndex(last, ".scope") i := strings.LastIndex(last, ".scope")
if i > 0 { if i > 0 {
......
...@@ -86,8 +86,9 @@ var ( ...@@ -86,8 +86,9 @@ var (
Destination: &AgentConfig.WithNodeID, Destination: &AgentConfig.WithNodeID,
} }
DockerFlag = cli.BoolFlag{ DockerFlag = cli.BoolFlag{
Hidden: true,
Name: "docker", Name: "docker",
Usage: "(agent/runtime) Use docker instead of containerd", Usage: "(deprecated) (agent/runtime) Use docker instead of containerd",
Destination: &AgentConfig.Docker, Destination: &AgentConfig.Docker,
} }
CRIEndpointFlag = cli.StringFlag{ CRIEndpointFlag = cli.StringFlag{
...@@ -109,7 +110,7 @@ var ( ...@@ -109,7 +110,7 @@ var (
} }
PauseImageFlag = cli.StringFlag{ PauseImageFlag = cli.StringFlag{
Name: "pause-image", Name: "pause-image",
Usage: "(agent/runtime) Customized pause image for containerd or docker sandbox", Usage: "(agent/runtime) Customized pause image for containerd sandbox",
Destination: &AgentConfig.PauseImage, Destination: &AgentConfig.PauseImage,
Value: DefaultPauseImage, Value: DefaultPauseImage,
} }
...@@ -185,14 +186,12 @@ var ( ...@@ -185,14 +186,12 @@ var (
SELinuxFlag = cli.BoolFlag{ SELinuxFlag = cli.BoolFlag{
Name: "selinux", Name: "selinux",
Usage: "(agent/node) Enable SELinux in containerd", Usage: "(agent/node) Enable SELinux in containerd",
Hidden: false,
Destination: &AgentConfig.EnableSELinux, Destination: &AgentConfig.EnableSELinux,
EnvVar: version.ProgramUpper + "_SELINUX", EnvVar: version.ProgramUpper + "_SELINUX",
} }
LBServerPortFlag = cli.IntFlag{ LBServerPortFlag = cli.IntFlag{
Name: "lb-server-port", Name: "lb-server-port",
Usage: "(agent/node) Local port for supervisor client load-balancer. If the supervisor and apiserver are not colocated an additional port 1 less than this port will also be used for the apiserver client load-balancer.", Usage: "(agent/node) Local port for supervisor client load-balancer. If the supervisor and apiserver are not colocated an additional port 1 less than this port will also be used for the apiserver client load-balancer.",
Hidden: false,
Destination: &AgentConfig.LBServerPort, Destination: &AgentConfig.LBServerPort,
EnvVar: version.ProgramUpper + "_LB_SERVER_PORT", EnvVar: version.ProgramUpper + "_LB_SERVER_PORT",
Value: 6444, Value: 6444,
......
...@@ -29,7 +29,6 @@ const ( ...@@ -29,7 +29,6 @@ const (
) )
type Node struct { type Node struct {
Docker bool
ContainerRuntimeEndpoint string ContainerRuntimeEndpoint string
NoFlannel bool NoFlannel bool
SELinux bool SELinux bool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment