Skip to content

Add CAPI patch: fix containerd v2 registry mirror auth for Bottlerocket#5571

Open
peirulu wants to merge 2 commits into
aws:mainfrom
peirulu:fix/containerdv2-registry-mirror-auth
Open

Add CAPI patch: fix containerd v2 registry mirror auth for Bottlerocket#5571
peirulu wants to merge 2 commits into
aws:mainfrom
peirulu:fix/containerdv2-registry-mirror-auth

Conversation

@peirulu

@peirulu peirulu commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

Fixes containerd v2 registry mirror auth for Bottlerocket k8s-1.33+ variants. Two changes:

  1. CAPI patch (0037): Adds registryMirrorHostsTomlFile() that generates a write_files entry with hosts.toml containing inline authorization headers
  2. bottlerocket-bootstrap fix: Rewrites /etc/containerd/certs.d/ paths to /.bottlerocket/rootfs/etc/containerd/certs.d/ so the file lands on the actual rootfs that containerd reads

Root Cause

Containerd 2.x does not read credentials.toml from certs.d/ in the CRI image pull path. Bottlerocket's thar-be-registries writes credentials.toml but containerd ignores it. Additionally, thar-be-registries atomically swaps the certs.d/ directory, so writes to the container-visible path (/etc/containerd/certs.d/) land in the old swapped-out directory.

Fix

  1. CAPI patch adds hosts.toml with auth headers to the bootstrap container's write_files
  2. bottlerocket-bootstrap writes to /.bottlerocket/rootfs/etc/containerd/certs.d/ (actual rootfs) instead of /etc/containerd/certs.d/ (container view)

Verification

Tested end-to-end on cluster cluster-133-dev-write (Bottlerocket k8s-1.34, vmware provider, authenticated registry mirror):

  • etcd node (195.18.68.69): hosts.toml has auth header, etcd running, health check passed
  • controlplane (195.18.71.115): kube-apiserver, scheduler, controller-manager all running
  • worker (195.18.0.35): images pulling from mirror with auth

Also verified backwards compatible on k8s-1.32 (containerd 1.7) — hosts.toml with header field is harmless.

Images for testing

Component Image
bottlerocket-bootstrap public.ecr.aws/p2x5x2t2/bottlerocket-bootstrap:v0.1.0-dev-write-file
etcdadm-bootstrap-provider public.ecr.aws/p2x5x2t2/aws/etcdadm-bootstrap-provider:v0.1.0-dev-write-file
kubeadm-bootstrap-controller public.ecr.aws/p2x5x2t2/kubernetes-sigs/cluster-api/kubeadm-bootstrap-controller:v0.1.0-dev-write-file

Related

Test plan

  • etcd node: hosts.toml written with auth, etcd starts and passes health check
  • controlplane: all static pods pull from mirror and start
  • worker: CAPI controller images pull from mirror during pivot
  • Backwards compatible: k8s-1.32 unaffected

Testing on cluster creation

  • Do bundle overrides on kubeadm-bootstrap-controller, etcdadm-bootstrap-controller, and bottlerocket-bootstrap and create a 1-33 bottlerocket authenticated registry mirror cluster (bottlerocket 1-33 use containerd v2), and the cluster creation succeed.

@eks-distro-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign pokearu for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@eks-distro-bot eks-distro-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 7, 2026
@peirulu peirulu force-pushed the fix/containerdv2-registry-mirror-auth branch 2 times, most recently from 26ace15 to c8b7791 Compare July 7, 2026 07:18
@eks-distro-bot eks-distro-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 7, 2026
@peirulu peirulu force-pushed the fix/containerdv2-registry-mirror-auth branch from c8b7791 to 50084ce Compare July 7, 2026 18:45
Containerd 2.x does not read credentials.toml files from the certs.d
directory in the CRI image pull path. This causes ImagePullBackOff with
"authorization failed: no basic auth credentials" on Bottlerocket
k8s-1.33+ variants using containerd 2.1.7.

Patch 0037 adds registryMirrorHostsTomlFile() that writes hosts.toml
with inline auth headers via the bootstrap container's write_files
mechanism. This works on all Bottlerocket variants (k8s 1.30-1.36).

Verified:
- Build compiles with Go 1.26
- Patches apply cleanly on CAPI v1.13.2
- containerd 1.7 (k8s-1.32): harmless, no breakage
- containerd 2.1 (k8s-1.34): fixes image pulls from auth mirror
@peirulu peirulu force-pushed the fix/containerdv2-registry-mirror-auth branch from 50084ce to 51cc861 Compare July 7, 2026 19:20
@peirulu peirulu force-pushed the fix/containerdv2-registry-mirror-auth branch from 2c32590 to 1012937 Compare July 9, 2026 17:54
The bottlerocket-bootstrap container writes hosts.toml to
/etc/containerd/certs.d/ which is the container's filesystem view.
Due to thar-be-registries' atomic directory swap (renameat2), writes
to this path land in the old (swapped-out) directory that containerd
no longer reads.

Fix by rewriting paths under /etc/containerd/certs.d/ to
/.bottlerocket/rootfs/etc/containerd/certs.d/ which is the actual
Bottlerocket rootfs that containerd reads.

This enables the write_files approach for fixing containerd v2
registry mirror auth — the etcdadm/CAPI bootstrap providers add
hosts.toml with authorization headers to write_files, and the
bottlerocket-bootstrap container now writes them to the correct
location.

Verified: etcd node successfully pulled images from authenticated
mirror after this fix (tested on cluster-133-dev-write).

Signed-off-by: peirulu <peirulu@amazon.com>
@peirulu peirulu force-pushed the fix/containerdv2-registry-mirror-auth branch from 1012937 to a5892bc Compare July 9, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants