mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Support external CRI implementations
This commit is contained in:
parent
3d113ceb2d
commit
70e6ca4ab8
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
|
||||
NodeNameFlag,
|
||||
DockerFlag,
|
||||
FlannelFlag,
|
||||
CRIEndpointFlag,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user