Support external CRI implementations

This commit is contained in:
Darren Shepherd 2019-03-03 23:29:06 -07:00
parent 3d113ceb2d
commit 70e6ca4ab8
5 changed files with 35 additions and 23 deletions

View File

@ -156,8 +156,9 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
}
nodeConfig := &config.Node{
Docker: envInfo.Docker,
NoFlannel: envInfo.NoFlannel,
Docker: envInfo.Docker,
NoFlannel: envInfo.NoFlannel,
ContainerRuntimeEndpoint: envInfo.ContainerRuntimeEndpoint,
}
nodeConfig.LocalAddress = localAddress(controlConfig)
nodeConfig.AgentConfig.NodeIP = nodeIP
@ -183,8 +184,10 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
nodeConfig.AgentConfig.CNIBinDir = filepath.Dir(hostLocal)
nodeConfig.AgentConfig.CNIConfDir = filepath.Join(envInfo.DataDir, "etc/cni/net.d")
}
if !nodeConfig.Docker {
if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" {
nodeConfig.AgentConfig.RuntimeSocket = "unix://" + nodeConfig.Containerd.Address
} else {
nodeConfig.AgentConfig.RuntimeSocket = "unix://" + nodeConfig.ContainerRuntimeEndpoint
}
if controlConfig.ClusterIPRange != nil {
nodeConfig.AgentConfig.ClusterCIDR = *controlConfig.ClusterIPRange

View File

@ -30,8 +30,8 @@ func run(ctx context.Context, cfg cmds.Agent) error {
}
}
if nodeConfig.Docker {
nodeConfig.AgentConfig.RuntimeSocket = ""
if nodeConfig.Docker || nodeConfig.ContainerRuntimeEndpoint != "" {
nodeConfig.AgentConfig.RuntimeSocket = nodeConfig.ContainerRuntimeEndpoint
} else {
if err := containerd.Run(ctx, nodeConfig); err != nil {
return err

View File

@ -8,15 +8,16 @@ import (
)
type Agent struct {
Token string
ServerURL string
DataDir string
NodeIP string
NodeName string
ClusterSecret string
Docker bool
NoFlannel bool
Debug bool
Token string
ServerURL string
DataDir string
NodeIP string
NodeName string
ClusterSecret string
Docker bool
ContainerRuntimeEndpoint string
NoFlannel bool
Debug bool
AgentShared
}
@ -48,6 +49,11 @@ var (
Usage: "(agent) Disable embedded flannel",
Destination: &AgentConfig.NoFlannel,
}
CRIEndpointFlag = cli.StringFlag{
Name: "container-runtime-endpoint",
Usage: "(agent) Disable embedded containerd and use alternative CRI implementation",
Destination: &AgentConfig.ContainerRuntimeEndpoint,
}
)
func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
@ -85,6 +91,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
FlannelFlag,
NodeNameFlag,
NodeIPFlag,
CRIEndpointFlag,
},
}
}

View File

@ -85,6 +85,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
NodeNameFlag,
DockerFlag,
FlannelFlag,
CRIEndpointFlag,
},
}
}

View File

@ -10,15 +10,16 @@ import (
)
type Node struct {
Docker bool
NoFlannel bool
FlannelConf string
LocalAddress string
Containerd Containerd
AgentConfig Agent
CACerts []byte
ServerAddress string
Certificate *tls.Certificate
Docker bool
ContainerRuntimeEndpoint string
NoFlannel bool
FlannelConf string
LocalAddress string
Containerd Containerd
AgentConfig Agent
CACerts []byte
ServerAddress string
Certificate *tls.Certificate
}
type Containerd struct {