diff --git a/docs/releases/1.26-NOTES.md b/docs/releases/1.26-NOTES.md index 8e13ab75fa..8515a1f0d4 100644 --- a/docs/releases/1.26-NOTES.md +++ b/docs/releases/1.26-NOTES.md @@ -55,7 +55,9 @@ error is encountered while updating an InstanceGroup. # Other changes of note -* Add unreachable route for pod IP on deletion option in Cilium. +* containerd config is now written to `/etc/containerd/config.toml`. + +* Cilium can be configured to add unreachable route for pod IP on deletion. # Breaking changes diff --git a/nodeup/pkg/model/containerd.go b/nodeup/pkg/model/containerd.go index 50e11e551d..13d236b2fc 100644 --- a/nodeup/pkg/model/containerd.go +++ b/nodeup/pkg/model/containerd.go @@ -35,6 +35,8 @@ import ( "k8s.io/kops/util/pkg/distributions" ) +const containerdConfigFilePath = "/etc/containerd/config.toml" + // ContainerdBuilder install containerd (just the packages at the moment) type ContainerdBuilder struct { *NodeupModelContext @@ -203,7 +205,7 @@ func (b *ContainerdBuilder) buildSystemdService(sv semver.Version) *nodetasks.Se manifest.Set("Service", "EnvironmentFile", "/etc/sysconfig/containerd") manifest.Set("Service", "EnvironmentFile", "/etc/environment") manifest.Set("Service", "ExecStartPre", "-/sbin/modprobe overlay") - manifest.Set("Service", "ExecStart", "/usr/bin/containerd -c "+b.containerdConfigFilePath()+" \"$CONTAINERD_OPTS\"") + manifest.Set("Service", "ExecStart", "/usr/bin/containerd -c "+containerdConfigFilePath+" \"$CONTAINERD_OPTS\"") // notify the daemon's readiness to systemd if (b.NodeupConfig.ContainerRuntime == "containerd" && sv.GTE(semver.MustParse("1.3.4"))) || sv.GTE(semver.MustParse("19.3.13")) { @@ -248,18 +250,6 @@ func (b *ContainerdBuilder) buildSystemdService(sv semver.Version) *nodetasks.Se return service } -// containerdConfigFilePath returns the path we use for the containerd config file -// We normally use a different path for clarity, but on some OSes we can't override the path. -// TODO: Should we just use config.toml everywhere? -func (b *ContainerdBuilder) containerdConfigFilePath() string { - switch b.Distribution { - case distributions.DistributionContainerOS: - return "/etc/containerd/config.toml" - default: - return "/etc/containerd/config-kops.toml" - } -} - // buildSystemdServiceOverrideContainerOS is responsible for overriding the containerd service for ContainerOS func (b *ContainerdBuilder) buildSystemdServiceOverrideContainerOS(c *fi.NodeupModelBuilderContext) { lines := []string{ @@ -273,7 +263,7 @@ func (b *ContainerdBuilder) buildSystemdServiceOverrideContainerOS(c *fi.NodeupM Path: "/etc/systemd/system/containerd.service.d/10-kops.conf", Contents: fi.NewStringResource(contents), Type: nodetasks.FileType_File, - AfterFiles: []string{b.containerdConfigFilePath()}, + AfterFiles: []string{containerdConfigFilePath}, OnChangeExecute: [][]string{ {"systemctl", "daemon-reload"}, {"systemctl", "restart", "containerd.service"}, @@ -292,7 +282,7 @@ func (b *ContainerdBuilder) buildSystemdServiceOverrideFlatcar(c *fi.NodeupModel "[Service]", "EnvironmentFile=/etc/environment", "ExecStart=", - "ExecStart=/usr/bin/containerd --config " + b.containerdConfigFilePath(), + "ExecStart=/usr/bin/containerd --config " + containerdConfigFilePath, } contents := strings.Join(lines, "\n") @@ -300,7 +290,7 @@ func (b *ContainerdBuilder) buildSystemdServiceOverrideFlatcar(c *fi.NodeupModel Path: "/etc/systemd/system/containerd.service.d/10-kops.conf", Contents: fi.NewStringResource(contents), Type: nodetasks.FileType_File, - AfterFiles: []string{b.containerdConfigFilePath()}, + AfterFiles: []string{containerdConfigFilePath}, OnChangeExecute: [][]string{ {"systemctl", "daemon-reload"}, {"systemctl", "restart", "containerd.service"}, @@ -353,7 +343,7 @@ func (b *ContainerdBuilder) buildConfigFile(c *fi.NodeupModelBuilderContext) err } } c.AddTask(&nodetasks.File{ - Path: b.containerdConfigFilePath(), + Path: containerdConfigFilePath, Contents: fi.NewStringResource(config), Type: nodetasks.FileType_File, }) diff --git a/nodeup/pkg/model/tests/containerdbuilder/flatcar/tasks.yaml b/nodeup/pkg/model/tests/containerdbuilder/flatcar/tasks.yaml index a8530ec10c..14ad8293bf 100644 --- a/nodeup/pkg/model/tests/containerdbuilder/flatcar/tasks.yaml +++ b/nodeup/pkg/model/tests/containerdbuilder/flatcar/tasks.yaml @@ -40,16 +40,16 @@ contents: | [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] SystemdCgroup = true -path: /etc/containerd/config-kops.toml +path: /etc/containerd/config.toml type: file --- afterFiles: -- /etc/containerd/config-kops.toml +- /etc/containerd/config.toml contents: |- [Service] EnvironmentFile=/etc/environment ExecStart= - ExecStart=/usr/bin/containerd --config /etc/containerd/config-kops.toml + ExecStart=/usr/bin/containerd --config /etc/containerd/config.toml onChangeExecute: - - systemctl - daemon-reload diff --git a/nodeup/pkg/model/tests/containerdbuilder/from_docker_19.03.11/tasks.yaml b/nodeup/pkg/model/tests/containerdbuilder/from_docker_19.03.11/tasks.yaml index 0acc0311bd..ea4361c302 100644 --- a/nodeup/pkg/model/tests/containerdbuilder/from_docker_19.03.11/tasks.yaml +++ b/nodeup/pkg/model/tests/containerdbuilder/from_docker_19.03.11/tasks.yaml @@ -1,6 +1,6 @@ contents: | disabled_plugins = ["cri"] -path: /etc/containerd/config-kops.toml +path: /etc/containerd/config.toml type: file --- contents: CONTAINERD_OPTS=--log-level=info @@ -214,7 +214,7 @@ definition: | EnvironmentFile=/etc/sysconfig/containerd EnvironmentFile=/etc/environment ExecStartPre=-/sbin/modprobe overlay - ExecStart=/usr/bin/containerd -c /etc/containerd/config-kops.toml "$CONTAINERD_OPTS" + ExecStart=/usr/bin/containerd -c /etc/containerd/config.toml "$CONTAINERD_OPTS" Delegate=yes KillMode=process Restart=always diff --git a/nodeup/pkg/model/tests/containerdbuilder/from_docker_19.03.14/tasks.yaml b/nodeup/pkg/model/tests/containerdbuilder/from_docker_19.03.14/tasks.yaml index d30fcdc0ff..638da7cb5b 100644 --- a/nodeup/pkg/model/tests/containerdbuilder/from_docker_19.03.14/tasks.yaml +++ b/nodeup/pkg/model/tests/containerdbuilder/from_docker_19.03.14/tasks.yaml @@ -1,6 +1,6 @@ contents: | disabled_plugins = ["cri"] -path: /etc/containerd/config-kops.toml +path: /etc/containerd/config.toml type: file --- contents: CONTAINERD_OPTS=--log-level=info @@ -214,7 +214,7 @@ definition: | EnvironmentFile=/etc/sysconfig/containerd EnvironmentFile=/etc/environment ExecStartPre=-/sbin/modprobe overlay - ExecStart=/usr/bin/containerd -c /etc/containerd/config-kops.toml "$CONTAINERD_OPTS" + ExecStart=/usr/bin/containerd -c /etc/containerd/config.toml "$CONTAINERD_OPTS" Type=notify Delegate=yes KillMode=process diff --git a/nodeup/pkg/model/tests/containerdbuilder/simple/tasks.yaml b/nodeup/pkg/model/tests/containerdbuilder/simple/tasks.yaml index d0b5084a91..ef5335c686 100644 --- a/nodeup/pkg/model/tests/containerdbuilder/simple/tasks.yaml +++ b/nodeup/pkg/model/tests/containerdbuilder/simple/tasks.yaml @@ -40,7 +40,7 @@ contents: | [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] SystemdCgroup = true -path: /etc/containerd/config-kops.toml +path: /etc/containerd/config.toml type: file --- contents: |2 @@ -347,7 +347,7 @@ definition: | EnvironmentFile=/etc/sysconfig/containerd EnvironmentFile=/etc/environment ExecStartPre=-/sbin/modprobe overlay - ExecStart=/usr/bin/containerd -c /etc/containerd/config-kops.toml "$CONTAINERD_OPTS" + ExecStart=/usr/bin/containerd -c /etc/containerd/config.toml "$CONTAINERD_OPTS" Type=notify Delegate=yes KillMode=process