mirror of https://github.com/k3s-io/k3s
Add --image-service-endpoint flag (#8279)
* Add --image-service-endpoint flag
Problem:
External container runtime can be set but image service endpoint is unchanged
and also is not exposed as a flag. This is useful for using containerd
snapshotters outside of the ones that have built-in support like
stargz-snapshotter.
Solution:
Add a flag --image-service-endpoint and also default image service endpoint to
container runtime endpoint if set.
Signed-off-by: Edgar Lee <edgarhinshunlee@gmail.com>
(cherry picked from commit fe18b1fce9
)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
pull/8692/head
parent
ec31704c1a
commit
b02a874d53
|
@ -495,6 +495,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
|
||||||
Docker: envInfo.Docker,
|
Docker: envInfo.Docker,
|
||||||
SELinux: envInfo.EnableSELinux,
|
SELinux: envInfo.EnableSELinux,
|
||||||
ContainerRuntimeEndpoint: envInfo.ContainerRuntimeEndpoint,
|
ContainerRuntimeEndpoint: envInfo.ContainerRuntimeEndpoint,
|
||||||
|
ImageServiceEndpoint: envInfo.ImageServiceEndpoint,
|
||||||
FlannelBackend: controlConfig.FlannelBackend,
|
FlannelBackend: controlConfig.FlannelBackend,
|
||||||
FlannelIPv6Masq: controlConfig.FlannelIPv6Masq,
|
FlannelIPv6Masq: controlConfig.FlannelIPv6Masq,
|
||||||
FlannelExternalIP: controlConfig.FlannelExternalIP,
|
FlannelExternalIP: controlConfig.FlannelExternalIP,
|
||||||
|
@ -525,7 +526,10 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
|
||||||
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")
|
||||||
nodeConfig.CRIDockerd.Root = filepath.Join(envInfo.DataDir, "agent", "cri-dockerd")
|
nodeConfig.CRIDockerd.Root = filepath.Join(envInfo.DataDir, "agent", "cri-dockerd")
|
||||||
if !nodeConfig.Docker && nodeConfig.ContainerRuntimeEndpoint == "" {
|
if !nodeConfig.Docker {
|
||||||
|
if nodeConfig.ImageServiceEndpoint != "" {
|
||||||
|
nodeConfig.AgentConfig.ImageServiceSocket = nodeConfig.ImageServiceEndpoint
|
||||||
|
} else 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 {
|
||||||
|
@ -544,6 +548,9 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
|
||||||
}
|
}
|
||||||
nodeConfig.AgentConfig.ImageServiceSocket = "/run/containerd-stargz-grpc/containerd-stargz-grpc.sock"
|
nodeConfig.AgentConfig.ImageServiceSocket = "/run/containerd-stargz-grpc/containerd-stargz-grpc.sock"
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
nodeConfig.AgentConfig.ImageServiceSocket = nodeConfig.ContainerRuntimeEndpoint
|
||||||
|
}
|
||||||
}
|
}
|
||||||
nodeConfig.Containerd.Opt = filepath.Join(envInfo.DataDir, "agent", "containerd")
|
nodeConfig.Containerd.Opt = filepath.Join(envInfo.DataDir, "agent", "containerd")
|
||||||
nodeConfig.Containerd.Log = filepath.Join(envInfo.DataDir, "agent", "containerd", "containerd.log")
|
nodeConfig.Containerd.Log = filepath.Join(envInfo.DataDir, "agent", "containerd", "containerd.log")
|
||||||
|
|
|
@ -37,5 +37,9 @@ func setupCriCtlConfig(cfg cmds.Agent, nodeConfig *config.Node) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
crp := "runtime-endpoint: " + cre + "\n"
|
crp := "runtime-endpoint: " + cre + "\n"
|
||||||
|
ise := nodeConfig.ImageServiceEndpoint
|
||||||
|
if ise != "" && ise != cre {
|
||||||
|
crp += "image-endpoint: " + cre + "\n"
|
||||||
|
}
|
||||||
return os.WriteFile(agentConfDir+"/crictl.yaml", []byte(crp), 0600)
|
return os.WriteFile(agentConfDir+"/crictl.yaml", []byte(crp), 0600)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,5 +39,9 @@ func setupCriCtlConfig(cfg cmds.Agent, nodeConfig *config.Node) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
crp := "runtime-endpoint: " + cre + "\n"
|
crp := "runtime-endpoint: " + cre + "\n"
|
||||||
|
ise := nodeConfig.ImageServiceEndpoint
|
||||||
|
if ise != "" && ise != cre {
|
||||||
|
crp += "image-endpoint: " + cre + "\n"
|
||||||
|
}
|
||||||
return os.WriteFile(filepath.Join(agentConfDir, "crictl.yaml"), []byte(crp), 0600)
|
return os.WriteFile(filepath.Join(agentConfDir, "crictl.yaml"), []byte(crp), 0600)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ type Agent struct {
|
||||||
Snapshotter string
|
Snapshotter string
|
||||||
Docker bool
|
Docker bool
|
||||||
ContainerRuntimeEndpoint string
|
ContainerRuntimeEndpoint string
|
||||||
|
ImageServiceEndpoint string
|
||||||
NoFlannel bool
|
NoFlannel bool
|
||||||
FlannelIface string
|
FlannelIface string
|
||||||
FlannelConf string
|
FlannelConf string
|
||||||
|
@ -116,6 +117,11 @@ var (
|
||||||
Usage: "(agent/runtime) Disable embedded containerd and use the CRI socket at the given path; when used with --docker this sets the docker socket path",
|
Usage: "(agent/runtime) Disable embedded containerd and use the CRI socket at the given path; when used with --docker this sets the docker socket path",
|
||||||
Destination: &AgentConfig.ContainerRuntimeEndpoint,
|
Destination: &AgentConfig.ContainerRuntimeEndpoint,
|
||||||
}
|
}
|
||||||
|
ImageServiceEndpointFlag = &cli.StringFlag{
|
||||||
|
Name: "image-service-endpoint",
|
||||||
|
Usage: "(agent/runtime) Disable embedded containerd image service and use remote image service socket at the given path. If not specified, defaults to --container-runtime-endpoint.",
|
||||||
|
Destination: &AgentConfig.ImageServiceEndpoint,
|
||||||
|
}
|
||||||
PrivateRegistryFlag = &cli.StringFlag{
|
PrivateRegistryFlag = &cli.StringFlag{
|
||||||
Name: "private-registry",
|
Name: "private-registry",
|
||||||
Usage: "(agent/runtime) Private registry configuration file",
|
Usage: "(agent/runtime) Private registry configuration file",
|
||||||
|
@ -271,6 +277,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
|
||||||
LBServerPortFlag,
|
LBServerPortFlag,
|
||||||
ProtectKernelDefaultsFlag,
|
ProtectKernelDefaultsFlag,
|
||||||
CRIEndpointFlag,
|
CRIEndpointFlag,
|
||||||
|
ImageServiceEndpointFlag,
|
||||||
PauseImageFlag,
|
PauseImageFlag,
|
||||||
SnapshotterFlag,
|
SnapshotterFlag,
|
||||||
PrivateRegistryFlag,
|
PrivateRegistryFlag,
|
||||||
|
|
|
@ -491,6 +491,7 @@ var ServerFlags = []cli.Flag{
|
||||||
ImageCredProvConfigFlag,
|
ImageCredProvConfigFlag,
|
||||||
DockerFlag,
|
DockerFlag,
|
||||||
CRIEndpointFlag,
|
CRIEndpointFlag,
|
||||||
|
ImageServiceEndpointFlag,
|
||||||
PauseImageFlag,
|
PauseImageFlag,
|
||||||
SnapshotterFlag,
|
SnapshotterFlag,
|
||||||
PrivateRegistryFlag,
|
PrivateRegistryFlag,
|
||||||
|
|
|
@ -39,6 +39,7 @@ const (
|
||||||
type Node struct {
|
type Node struct {
|
||||||
Docker bool
|
Docker bool
|
||||||
ContainerRuntimeEndpoint string
|
ContainerRuntimeEndpoint string
|
||||||
|
ImageServiceEndpoint string
|
||||||
NoFlannel bool
|
NoFlannel bool
|
||||||
SELinux bool
|
SELinux bool
|
||||||
FlannelBackend string
|
FlannelBackend string
|
||||||
|
|
Loading…
Reference in New Issue