Skip to content
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

T7092: Add Container Registry Mirror #4321

Merged
merged 5 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions data/templates/container/registries.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,14 @@
{% set _ = registry_list.append(r) %}
{% endfor %}
unqualified-search-registries = {{ registry_list }}
{% for r, r_options in registry.items() if r_options.disable is not vyos_defined %}
[[registry]]
{% if r_options.mirror is vyos_defined %}
location = "{{ r_options.mirror.host_name if r_options.mirror.host_name is vyos_defined else r_options.mirror.address }}{{ ":" + r_options.mirror.port if r_options.mirror.port is vyos_defined }}{{ r_options.mirror.path if r_options.mirror.path is vyos_defined }}"
{% else %}
location = "{{ r }}"
{% endif %}
insecure = {{ 'true' if r_options.insecure is vyos_defined else 'false' }}
prefix = "{{ r }}"
{% endfor %}
{% endif %}
48 changes: 48 additions & 0 deletions interface-definitions/container.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,54 @@
<children>
#include <include/interface/authentication.xml.i>
#include <include/generic-disable-node.xml.i>
<leafNode name="insecure">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How common are HTTP-only mirrors in the age of Let's Encrypt? Are there compelling arguments to support them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't tell how common, but those I have access to are all ip:port only and only for development servers and developer's machines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should insecure & authentication nodes be mutually exclusive?
Can't see it ever being advisable to send credentials over plaintext...

Copy link
Contributor Author

@sskaje sskaje Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should insecure & authentication nodes be mutually exclusive? Can't see it ever being advisable to send credentials over plaintext...

Theoritically yes, but you can't expect small company do everything right in their LAN.
throw a warning is enough.

Also, insecure can be used for self-signed certificate: https://github.com/containers/image/blob/main/docs/containers-registries.conf.5.md

insecure : true or false. By default, container runtimes require TLS when retrieving images from a registry. If insecure is set to true, unencrypted HTTP as well as TLS connections with untrusted certificates are allowed.

<properties>
<help>Allow registry access over unencrypted HTTP or TLS connections with untrusted certificates</help>
<valueless/>
</properties>
</leafNode>
<node name="mirror">
<properties>
<help>Registry mirror, use host-name|address[:port][/path]</help>
</properties>
<children>
<leafNode name="address">
<properties>
<help>IP address of container registry mirror</help>
<valueHelp>
<format>ipv4</format>
<description>IPv4 address of container registry mirror</description>
</valueHelp>
<valueHelp>
<format>ipv6</format>
<description>IPv6 address of container registry mirror</description>
</valueHelp>
<constraint>
<validator name="ip-address"/>
<validator name="ipv6-link-local"/>
</constraint>
</properties>
</leafNode>
<leafNode name="host-name">
<properties>
<help>Hostname of container registry mirror</help>
<valueHelp>
<format>hostname</format>
<description>FQDN of container registry mirror</description>
</valueHelp>
<constraint>
<validator name="fqdn"/>
</constraint>
</properties>
</leafNode>
#include <include/port-number.xml.i>
<leafNode name="path">
<properties>
<help>Path of container registry mirror, optional, must be start with '/' if not empty</help>
</properties>
</leafNode>
</children>
</node>
</children>
</tagNode>
</children>
Expand Down
7 changes: 7 additions & 0 deletions src/conf_mode/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ def verify(container):

if 'registry' in container:
for registry, registry_config in container['registry'].items():
if 'mirror' in registry_config:
if 'host_name' in registry_config['mirror'] and 'address' in registry_config['mirror']:
raise ConfigError(f'Container registry mirror address/host-name are mutually exclusive!')

if 'path' in registry_config['mirror'] and not registry_config['mirror']['path'].startswith('/'):
raise ConfigError('Container registry mirror path must start with "/"!')

if 'authentication' not in registry_config:
continue
if not {'username', 'password'} <= set(registry_config['authentication']):
Expand Down
Loading