Skip to content

Commit 681391f

Browse files
author
David Sariel
committed
[openshift_setup] pre-pull RBAC proxy images on master nodes
When digest mirrors are configured, optionally pre-pull any RBAC proxy images found in the mirror list on all master nodes. This avoids pull failures at workload deployment time when the cluster cannot reach the original registry directly. The feature is controlled by cifmw_openshift_setup_prepull_rbac_images (default: true) and is skipped when no digest mirrors are defined or when no mirrors match the RBAC proxy image pattern. Each image is pulled via `oc debug node` using the node's existing kubelet auth credentials. Failures are non-fatal and a summary of successful pulls is logged at the end. Signed-off-by: David Sariel <dsariel@redhat.com> ANVIL-142
1 parent 2d92bae commit 681391f

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

roles/openshift_setup/tasks/configure_registries.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,54 @@
7171
name: registry-tag-mirrors
7272
spec:
7373
imageTagMirrors: "{{ cifmw_openshift_setup_tag_mirrors }}"
74+
75+
- name: Pre-pull RBAC proxy images on all master nodes
76+
when:
77+
- cifmw_openshift_setup_digest_mirrors is defined
78+
- cifmw_openshift_setup_digest_mirrors | length > 0
79+
- cifmw_openshift_setup_prepull_rbac_images | default(true) | bool
80+
block:
81+
- name: Extract RBAC proxy images from digest mirrors
82+
ansible.builtin.set_fact:
83+
_rbac_proxy_images: >-
84+
{{
85+
cifmw_openshift_setup_digest_mirrors
86+
| map(attribute='mirrors')
87+
| flatten
88+
| select('match', '^image-rbac.*\\.com/.*')
89+
| list
90+
}}
91+
92+
- name: Get list of master nodes
93+
kubernetes.core.k8s_info:
94+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
95+
api_key: "{{ cifmw_openshift_token | default(omit)}}"
96+
context: "{{ cifmw_openshift_context | default(omit)}}"
97+
kind: Node
98+
label_selectors:
99+
- node-role.kubernetes.io/master
100+
register: _master_nodes_info
101+
102+
- name: Set master node names list
103+
ansible.builtin.set_fact:
104+
_master_node_names: "{{ _master_nodes_info.resources | map(attribute='metadata.name') | list }}"
105+
106+
- name: Pre-pull RBAC proxy images on each master node
107+
ansible.builtin.shell: |
108+
oc debug node/{{ item.0 }} -- \
109+
chroot /host podman pull --authfile /var/lib/kubelet/config.json {{ item.1 }}
110+
environment:
111+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
112+
loop: "{{ _master_node_names | product(_rbac_proxy_images) | list }}"
113+
loop_control:
114+
label: "{{ item.0 }}: {{ item.1 | basename }}"
115+
failed_when: false
116+
changed_when: true
117+
register: _prepull_results
118+
119+
- name: Display pre-pull summary
120+
ansible.builtin.debug:
121+
msg: >-
122+
Pre-pulled {{ _prepull_results.results | selectattr('rc', 'equalto', 0) | list | length }}
123+
/ {{ _prepull_results.results | length }} RBAC proxy images
124+
({{ _master_node_names | length }} masters × {{ _rbac_proxy_images | length }} images)

0 commit comments

Comments
 (0)