Deploy a registries.yaml from registries_config on k3s servers and restart k3s on its change

This commit is contained in:
2026-10-09 14:37:29 +00:00
parent 80658c632f
commit 4d1725f17f
4 changed files with 20 additions and 1 deletions
+11
View File
@@ -52,3 +52,14 @@ kubernetes:
etcd-arg:
heartbeat-interval: 500
election-timeout: 5000
registries_config:
# Defines the names and endpoints of registries
# When embedded-registry is enabled, every registry needs to be defined here to allow this node to distribute those images.
#mirrors:
# Enable distribution for all registries
#"*": {}
# Defines authentication and extra settings for the registries
#config:
+7
View File
@@ -36,6 +36,13 @@
mode: "744"
# todo: update when file changed?
- name: Deploy registries.yaml
ansible.builtin.template:
src: k3s/server/registries.yaml.j2
dest: /etc/rancher/k3s/registries.yaml
register: registries_config
when: "type == 'server'"
- import_tasks: ./install/server/setup_network.yml
when: "type == 'server'"
@@ -15,7 +15,7 @@
service:
name: k3s
enabled: true
state: "{{ 'restarted' if not command.changed and config.changed else 'started' }}"
state: "{{ 'restarted' if not command.changed and (config.changed or registries_config.changed) else 'started' }}"
- name: Waiting for K3s-server to accept connections
ansible.builtin.wait_for:
@@ -0,0 +1 @@
{{ kubernetes.registries_config | to_nice_yaml(indent=2) }}