Skip to content

Commit 5be28f2

Browse files
rebtoorcursoragent
andcommitted
[openshift_setup] Add catalog registry auth and signature policy bypass
When cifmw_openshift_setup_catalog_registry_credentials is defined: - Merge the auth into the cluster pull-secret so nodes can pull from the Konflux image-rbac-proxy registry. - Add the catalog registry to insecure and allowed registries to bypass image signature validation for Konflux-built FBC catalogs. - Wait for MachineConfigPools to settle after IDMS + pull-secret changes before proceeding. Related-Issue: #OSPCIX-1431 Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Roberto Alfieri <ralfieri@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 670f562 commit 5be28f2

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

roles/openshift_setup/tasks/configure_registries.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,115 @@
5353
spec:
5454
imageDigestMirrors: "{{ cifmw_openshift_setup_digest_mirrors }}"
5555

56+
- name: Add catalog registry credentials to cluster pull-secret
57+
when:
58+
- cifmw_openshift_setup_catalog_registry_credentials is defined
59+
- cifmw_openshift_setup_catalog_registry_credentials | length > 0
60+
no_log: true
61+
block:
62+
- name: Get current cluster pull-secret
63+
kubernetes.core.k8s_info:
64+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
65+
api_key: "{{ cifmw_openshift_token | default(omit) }}"
66+
context: "{{ cifmw_openshift_context | default(omit) }}"
67+
kind: Secret
68+
name: pull-secret
69+
namespace: openshift-config
70+
register: _cluster_pull_secret
71+
72+
- name: Merge catalog registry auth into cluster pull-secret
73+
vars:
74+
_current_auths: >-
75+
{{
76+
(_cluster_pull_secret.resources[0].data['.dockerconfigjson']
77+
| b64decode | from_json).auths
78+
}}
79+
_catalog_auth: >-
80+
{{
81+
{
82+
cifmw_openshift_setup_catalog_registry_credentials.registry: {
83+
'auth': (
84+
cifmw_openshift_setup_catalog_registry_credentials.username ~ ':'
85+
~ cifmw_openshift_setup_catalog_registry_credentials.password
86+
) | b64encode
87+
}
88+
}
89+
}}
90+
_merged:
91+
auths: "{{ _current_auths | combine(_catalog_auth) }}"
92+
kubernetes.core.k8s:
93+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
94+
api_key: "{{ cifmw_openshift_token | default(omit) }}"
95+
context: "{{ cifmw_openshift_context | default(omit) }}"
96+
state: present
97+
definition:
98+
apiVersion: v1
99+
kind: Secret
100+
metadata:
101+
name: pull-secret
102+
namespace: openshift-config
103+
type: kubernetes.io/dockerconfigjson
104+
data:
105+
.dockerconfigjson: "{{ _merged | to_json | b64encode }}"
106+
107+
- name: Add catalog registry to insecure and allowed registries
108+
when:
109+
- cifmw_openshift_setup_catalog_registry_credentials is defined
110+
- cifmw_openshift_setup_catalog_registry_credentials.registry is defined
111+
vars:
112+
_catalog_reg: "{{ cifmw_openshift_setup_catalog_registry_credentials.registry }}"
113+
all_registries: >-
114+
{{
115+
([_catalog_reg] +
116+
cifmw_openshift_setup_allowed_registries +
117+
cifmw_openshift_setup_allowed_extra_registries) | unique
118+
}}
119+
kubernetes.core.k8s:
120+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
121+
api_key: "{{ cifmw_openshift_token | default(omit)}}"
122+
context: "{{ cifmw_openshift_context | default(omit)}}"
123+
merge_type: "merge"
124+
definition:
125+
apiVersion: config.openshift.io/v1
126+
kind: Image
127+
metadata:
128+
name: cluster
129+
spec:
130+
registrySources:
131+
insecureRegistries:
132+
- "{{ _catalog_reg }}"
133+
allowedRegistries: "{{ all_registries }}"
134+
135+
- name: Wait for MachineConfigPools to settle after registry changes
136+
when:
137+
- cifmw_openshift_setup_digest_mirrors is defined
138+
- cifmw_openshift_setup_digest_mirrors | length > 0
139+
environment:
140+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
141+
PATH: "{{ cifmw_path }}"
142+
ansible.builtin.shell:
143+
cmd: |
144+
set -eo pipefail
145+
MCP_JSON=$(oc get mcp -o json)
146+
UPDATING=$(echo "$MCP_JSON" | jq -r '
147+
.items[] |
148+
select(
149+
.status.conditions // [] |
150+
map(select(.type == "Updating" and .status == "True")) |
151+
length > 0
152+
) | .metadata.name')
153+
if [ -z "$UPDATING" ]; then
154+
echo "All MCPs settled."
155+
exit 0
156+
fi
157+
echo "MCPs still updating: $UPDATING"
158+
exit 1
159+
register: _mcp_settle
160+
until: _mcp_settle.rc == 0
161+
retries: 60
162+
delay: 30
163+
changed_when: false
164+
56165
# If both ImageDigestMirrorSet and ImageTagMirrorSet are applied to the registries,
57166
# ITMS acts as a fallback for tag-based pulls, while IDMS provides the primary
58167
# secure source for digests

0 commit comments

Comments
 (0)