Skip to content

CKS: make node containerd setup work with containerd 2.x - #14898

Open
bhouse-nexthop wants to merge 1 commit into
apache:4.22from
bhouse-nexthop:cks-containerd2
Open

bhouse-nexthop wants to merge 1 commit into
apache:4.22from
bhouse-nexthop:cks-containerd2

Conversation

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator

Description

Fixes #14896

CKS node bootstrap only worked with containerd 1.x config files. On containerd 2.x the private registry and the pause image were silently not set, because both were written with sed against config version 2 keys. Every node also threw away whatever containerd config the template shipped.

Before After
Base config always containerd config default, template config lost generated only if there is none, CRI is disabled (Docker's containerd.io package ships disabled_plugins = ["cri"]), or it doesn't set SystemdCgroup = true
Registry mirror registry.mirrors table, config version 2 only config_path + /etc/containerd/certs.d/<host>/hosts.toml, works on 1.7 and 2.x
Registry credentials registry.configs.<host>.auth with username/password, version 2 table only same auth table, written for the config version in use, with the base64 auth field (a password with a " no longer breaks the script)
Pause image sandbox_image (version 2) sandbox_image or pinned_images.sandbox (version 3+), also in upgrade-kubernetes.sh
Registry script replaced the base config step runs after it

A path in the registry URL is still used as the registry's API root, as the old mirror endpoint did (override_path = true in hosts.toml).

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

  • Unit test: the registry script runs right after the SystemdCgroup step in all three node templates, with the registry URL and auth filled in.
  • Rendered the three templates the way the management server does (registry URL http://reg:5000, a password containing " and a space), pulled out the containerd runcmd lines, setup-containerd and the pause image sed, and ran them in Ubuntu 24.04 containers against the containerd release binaries 1.7.36, 2.0.14 and 2.4.2. Starting configs: none, Docker's containerd.io config, version = 2 only, a prepared config with a custom setting, a config with SystemdCgroup=false written without spaces, a custom config_path (kept, with a warning), and running everything twice. Each time containerd config dump parses and shows SystemdCgroup = true, the pause image, the registry config_path and the auth entry. The prepared config keeps its custom setting, and the other configs are regenerated.
  • Live pulls: a registry:2 with htpasswd auth over plain http, containerd started in a privileged container on the same network, then crictl pull reg:5000/test/busybox:1.36:
containerd Starting config Before After
1.7.36 none pull OK pull OK
2.4.2 none http: server gave HTTP response to HTTPS client pull OK
1.7.36, 2.0.14, 2.4.2 none / Docker containerd.io pull OK
2.0.14, 2.4.2 kept containerd 1.7 config (version 2) pull OK
1.7.36, 2.0.14, 2.4.2 none, auth table removed no basic auth credentials (so the pull above really used the auth)
1.7.36, 2.4.2 registry URL http://reg:5000/v2 pull OK (URL path used as the API root)
  • Not tested yet: a full CKS cluster deploy on a containerd 2.x template.

How did you try to break this feature and the system with this change?

  • Ran the bootstrap twice on the same node: no duplicate TOML tables.
  • Kept config that already sets its own config_path: left as is and the script prints a warning. containerd 2.1+ reads config_path as a single directory on some pull paths, so joining two paths isn't safe.
  • A config with SystemdCgroup=false or a commented SystemdCgroup = true: regenerated, so containerd and kubelet both use the systemd cgroup driver.

Not done here:

  • containerd 2.7 removes registry.configs. Credentials will then need another route, such as image pull secrets or a kubelet credential provider.
  • A template config that keeps the deprecated registry.mirrors or configs.tls can't be combined with config_path; containerd refuses that mix.
  • On the first control node the registry script is still gated by {% if registry is defined %}, which never matches. fix cks cluster stuck starting when a private registry is set #14408 fixes that.
  • Existing nodes upgraded with upgrade-kubernetes.sh get the pause image fix but not the registry, as before.

CKS node bootstrap overwrote /etc/containerd/config.toml with the
default config on every node and added the private registry by
appending to the config version 2 registry tables. containerd 2.x
writes config version 3 or later, where those tables moved, so the
registry was silently dropped. The pause image was also only set
through the version 2 sandbox_image key.

- Generate the default config only when there is none, CRI is
  disabled (Docker's containerd.io package), or it does not set
  SystemdCgroup = true; a template's own config is kept otherwise.
- Add the registry through config_path and certs.d/<host>/hosts.toml,
  and its credentials in the auth table for the config version in
  use. Run this after the base containerd config instead of in its
  place.
- Set the pause image through either sandbox_image (version 2) or
  pinned_images sandbox (version 3+), in the node templates and in
  upgrade-kubernetes.sh.

Signed-off-by: Brad House <bhouse@nexthop.ai>
@codecov

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 18.34%. Comparing base (a8735b2) to head (29dc8e2).

Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #14898   +/-   ##
=========================================
  Coverage     18.34%   18.34%           
- Complexity    16671    16678    +7     
=========================================
  Files          5939     5939           
  Lines        537817   537814    -3     
  Branches      65938    65938           
=========================================
+ Hits          98640    98673   +33     
+ Misses       427954   427917   -37     
- Partials      11223    11224    +1     
Flag Coverage Δ
uitests 4.08% <ø> (ø)
unittests 19.44% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

Tested on a KVM lab, with this change on 4.22 and on main. Each cluster used a private registry with a username and password.

Build Node containerd Cluster Result
4.22 without this change 2.4.2, Docker-style config with CRI disabled 1 etcd, 1 control, 1 worker, k8s 1.32.3 stuck in Starting: CRI still disabled, kubeadm preflight fails
4.22 with this change same same Running. The CRI-disabled config was regenerated, SystemdCgroup true, pause image set, worker pulls from the registry
main with this change 1.7.28 (stock template) 1 control, 1 worker, k8s 1.33.1 Running. Both nodes pull from the registry
main with this change 2.4.2: control with the CRI-disabled config, worker with its own usable config 1 control, 1 worker, k8s 1.33.1 Running. Both nodes pull. The worker kept its config (custom setting still there); the control regenerated its config

On 4.22 the control node still can't pull from the registry, because the control-node template never writes the registry setup there. That's the bug #14408 fixes on main; with both PRs on main, both nodes pull. Workers are fine on 4.22.

containerd 2.4 logs that the registry auth table is deprecated. It still works; that is the "not done" item in the description.

Not run: the upgrade-kubernetes.sh pause image change (no upgrade), containerd 2.0 and 2.2 on a live cluster.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant