-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for containerd 1.5+ config_path
: On-the-fly container registry configuration
#5568
Comments
I will note that I'm not a huge fan of the new config_path mechanism - scattering files about the filesystem with names matching remote hosts doesn't feel very tidy to me, compared to having everything configured from a single config file. It is also more complicated to manage declaratively. We can take a look at this, though. |
Using hosts.toml would allow us to override paths. It's not as flexible as full rewriting, but it is per-endpoint, and probably accomplishes 99% of what people want out of rewrites. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@networkhermit your comments have nothing to do with this issue to track switching the config schema and structure. Fallback does work, with some restrictions on the rewrite behavior as described above. Please don't change the topic. |
Sorry about any misunderstanding. Maybe I should give more context. As reported by #7007 and suggested in #7007 (comment), when using harbor registry as a registry mirror in k3s, the old rewrite mechanism would keep containerd from falling back to upstream endpoint when the mirror instance is down, and the workaround is manually adding
So I believe switching the config schema and structure is the final fix to that issue? Am I supposed to comment in already closed #7007 in order to address my similar situation? Edited: As Harbor puts a registry name in the pull image path, one need to use the |
What it will mean for end users? k3s will still be using single config as usual, but registries will be split into separate files in path specified in config_path? Old way of registries.yaml will be removed? Asking because i maintain k3s ansible role. |
Take a look at the PR. It doesn't change anything regarding registries.yaml. |
Validated on master branch with version v1.29.1+k3s2Environment DetailsInfrastructure
Node(s) CPU architecture, OS, and Version:
Cluster Configuration:
Config.yaml:
Registries.yaml
Testing Steps
Copy registries.yaml to /etc/rancher/k3s/registries.yaml
Validation Results:
config.toml content:
certs.d directory content:
hosts.toml file contents:
|
Is your feature request related to a problem? Please describe.
containerd versions 1.4 and older require adding any custom registry information via
registry.mirrors
/registry.configs
sections in the mainetc/containerd/config.toml
. This mechanism has a few downsides, including that it requires editing the main containerd configuration in-place (which cannot be done in K3s since it'll be automatically re-rendered), and also it requires restarting containerd to take effect. This older mechanism is still available and is what k3s currently uses, but it has been deprecated.With 1.5, containerd added support for a new
config_path
configuration option which imitates the behavior of dockerd'scerts.d
directory, with some additional functionality on top. This new system resolves the problems of the 1.4-and-earlier mechanism, making it very easy for an operator to manage custom registry configurations.Describe the solution you'd like
K3s already exposes a custom
registries.yaml
configuration to add container registry configurations intocontainerd/config.toml
. I think that the existing K3s configuration options could continue to be supported via the newconfig_path
mechanism, where K3s would just write files into theconfig_path
structure, rather than directly tocontainerd/config.toml
. Meanwhile, users who wish to manage custom certs on-the-fly would be able to do so by adding them to theconfig_path
directly on the host filesystem - e.g. via a DaemonSet with a hostPath mount, or externally via separate configuration management tooling (e.g. ansible or similar).Implementation steps:
containerd/config.toml
templates would be updated to specify a reasonableconfig_path
path by default. For example, this could beetc/containerd/certs.d/
within the K3s install - so a newetc/containerd/certs.d
directory next to the existing K3s-renderedetc/containerd/config.toml
. It would probably make sense to allow customizing theconfig_path
location via a flag and/or envvar.containerd/config.toml
PrivateRegistryConfig
templating would be migrated to writing files into the configuredconfig_path
. This would effectively migrate users ofregistries.yaml
to usingconfig_path
.I think the K3s
config_path
output implementation should be permissive of any other "unknown" files that the user may have added to the directory. This has the potential downside of leaving "leftover" registry configurations lying around inconfig_path
if they are removed from the user'sregistries.yaml
configuration. The user would be able to delete these leftover files fromconfig_path
manually after removing them fromregistries.yaml
.Also, it may be worth thinking about deprecating the current
registries.yaml
mechanism entirely in favor of having users add their custom registry configs toconfig_path
directly. Given that in-place editing of the mainetc/containerd/config.toml
would no longer be necessary under the new system, the customregistries.yaml
mechanism wouldn't be providing much value. But there would be no rush sinceregistries.yaml
could continue to work on top ofconfig_path
as described above.Describe alternatives you've considered
Alternative options:
containerd/config.toml
-based configuration mechanism exposed by K3s, requiring restarting the cluster after any changes.certs.d
support.config.toml.tmpl
which specifiesconfig_path
, effectively implementing the suggested config change manually.config_path
enabled (but at this point why use K3s?)Additional context
I encountered this when trying to set up a local Harbor registry. The most finicky part has been getting K3s' containerd-based kubelets to acknowledge the CA cert that was being used by Harbor. After looking through containerd docs, I noticed that they had recently added support for directory-based configuration which would allow me to automatically add the CA certs to the nodes without requiring reconfiguring and restarting the whole cluster.
Backporting
The text was updated successfully, but these errors were encountered: