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

cri-o registry auth support #7837

Merged
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
6 changes: 6 additions & 0 deletions inventory/sample/group_vars/all/cri-o.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# crio_insecure_registries:
# - 10.0.0.2:5000
# crio_registry_auth:
# - registry: 10.0.0.2:5000
# username: user
# password: pass
6 changes: 6 additions & 0 deletions roles/container-engine/cri-o/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ crio_registries: []
# Configure insecure registries.
crio_insecure_registries: []

# Configure registry auth (if applicable to secure/insecure registries)
crio_registry_auth: []
# - registry: 10.0.0.2:5000
# username: user
# password: pass

# Define registiries mirror

crio_registries_mirrors: []
Expand Down
7 changes: 7 additions & 0 deletions roles/container-engine/cri-o/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
mode: 0644
register: config_install

- name: Install config.json
template:
src: config.json.j2
dest: /etc/crio/config.json
register: reg_auth_install

- name: Add skopeo pkg to install
set_fact:
crio_packages: "{{ crio_packages + skopeo_packages }}"
Expand Down Expand Up @@ -198,6 +204,7 @@
state: restarted
when:
- config_install.changed
- reg_auth_install.changed
- not package_install.changed
- not service_start.changed

Expand Down
17 changes: 17 additions & 0 deletions roles/container-engine/cri-o/templates/config.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% if crio_registry_auth is defined and crio_registry_auth|length %}
{
{% for reg in crio_registry_auth %}
"auths": {
"{{ reg.registry }}": {
"auth": "{{ (reg.username + ':' + reg.password) | string | b64encode }}"
}
{% if not loop.last %}
},
{% else %}
}
{% endif %}
{% endfor %}
}
{% else %}
{}
{% endif %}
2 changes: 1 addition & 1 deletion roles/container-engine/cri-o/templates/crio.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ default_transport = "docker://"

# The path to a file containing credentials necessary for pulling images from
# secure registries. The file is similar to that of /var/lib/kubelet/config.json
global_auth_file = ""
global_auth_file = "/etc/crio/config.json"

# The image used to instantiate infra containers.
# This option supports live configuration reload.
Expand Down