Skip to content

Commit 55b70f0

Browse files
evallespopenshift-merge-bot[bot]
authored andcommitted
[openshift_setup] Extract insecure registry logic
We're extracting the logic behind allowing insecure registries. With this, we can use directly this code from other projects that uses parts of ci-framework Signed-off-by: Enrique Vallespi Gil <evallesp@redhat.com>
1 parent a4c1113 commit 55b70f0

4 files changed

Lines changed: 76 additions & 45 deletions

File tree

roles/openshift_setup/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,14 @@ effect if `cifmw_openshift_setup_ca_registry_to_add` is set.
2626
mirrors:
2727
- mirror.quay.rdoproject.org
2828
```
29+
* `cifmw_openshift_setup_allowed_registries`: (List) List of allowed registries when setting up insecure registry configuration. Used in conjunction with `cifmw_update_containers_registry`. Defaults to common registries.
30+
* Example:
31+
```yaml
32+
cifmw_openshift_setup_allowed_registries:
33+
- "quay.io"
34+
- "registry.redhat.io"
35+
- "my-internal-registry.example.com"
36+
```
37+
* `cifmw_openshift_setup_allowed_extra_registries`: (List) List of extra registries we want to allow. Intended to be by CI jobs using the framework.
2938
* `cifmw_openshift_setup_apply_marketplace_fix`: (Boolean) Apply openshift-marketplace workaround which is recreating all pods in the namespace. NOTE: same step is done in `base` job.
3039
* `cifmw_openshift_setup_samples_registry`: (String) Registry sample

roles/openshift_setup/defaults/main.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,14 @@ cifmw_openshift_setup_operator_override_catalog_namespace: "openshift-marketplac
2929
cifmw_openshift_setup_operator_override_catalog_image: "registry.redhat.io/redhat/redhat-operator-index:v4.17"
3030
cifmw_openshift_setup_apply_marketplace_fix: false
3131
cifmw_openshift_setup_samples_registry: "registry.redhat.io"
32+
cifmw_openshift_setup_allowed_registries:
33+
- "quay.io"
34+
- "gcr.io"
35+
- "registry.k8s.io"
36+
- "registry.redhat.io"
37+
- "registry.connect.redhat.com"
38+
- "registry-proxy.engineering.redhat.com"
39+
- "registry.stage.redhat.io"
40+
- "images.paas.redhat.com"
41+
- "image-registry.openshift-image-registry.svc:5000"
42+
cifmw_openshift_setup_allowed_extra_registries: []
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
# This task file configures insecure registries and ImageContentSourcePolicy
18+
# Can be used standalone from playbooks that don't need the full openshift_setup role
19+
20+
- name: Add insecure registry
21+
when: cifmw_update_containers_registry is defined
22+
vars:
23+
all_registries: "{{ ([cifmw_update_containers_registry] + cifmw_openshift_setup_allowed_registries + cifmw_openshift_setup_allowed_extra_registries) | unique }}"
24+
kubernetes.core.k8s:
25+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
26+
api_key: "{{ cifmw_openshift_token | default(omit)}}"
27+
context: "{{ cifmw_openshift_context | default(omit)}}"
28+
merge_type: "merge"
29+
definition:
30+
apiVersion: config.openshift.io/v1
31+
kind: Image
32+
metadata:
33+
name: cluster
34+
spec:
35+
registrySources:
36+
insecureRegistries:
37+
- "{{ cifmw_update_containers_registry }}"
38+
allowedRegistries: "{{ all_registries }}"
39+
40+
- name: Create a ICSP with repository digest mirrors
41+
when:
42+
- cifmw_openshift_setup_digest_mirrors is defined
43+
- cifmw_openshift_setup_digest_mirrors | length > 0
44+
kubernetes.core.k8s:
45+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
46+
api_key: "{{ cifmw_openshift_token | default(omit)}}"
47+
context: "{{ cifmw_openshift_context | default(omit)}}"
48+
definition:
49+
apiVersion: operator.openshift.io/v1alpha1
50+
kind: ImageContentSourcePolicy
51+
metadata:
52+
name: registry-digest-mirrors
53+
spec:
54+
repositoryDigestMirrors: "{{ cifmw_openshift_setup_digest_mirrors }}"

roles/openshift_setup/tasks/main.yml

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -168,51 +168,8 @@
168168
additionalTrustedCA:
169169
name: "registry-cas"
170170

171-
- name: Add insecure registry
172-
when: cifmw_update_containers_registry is defined
173-
vars:
174-
default_allowed_registries:
175-
- "quay.io"
176-
- "gcr.io"
177-
- "registry.k8s.io"
178-
- "registry.redhat.io"
179-
- "registry.connect.redhat.com"
180-
- "registry-proxy.engineering.redhat.com"
181-
- "registry.stage.redhat.io"
182-
- "images.paas.redhat.com"
183-
- "image-registry.openshift-image-registry.svc:5000"
184-
all_registries: "{{ [cifmw_update_containers_registry] + default_allowed_registries | unique }}"
185-
kubernetes.core.k8s:
186-
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
187-
api_key: "{{ cifmw_openshift_token | default(omit)}}"
188-
context: "{{ cifmw_openshift_context | default(omit)}}"
189-
merge_type: "merge"
190-
definition:
191-
apiVersion: config.openshift.io/v1
192-
kind: Image
193-
metadata:
194-
name: cluster
195-
spec:
196-
registrySources:
197-
insecureRegistries:
198-
- "{{ cifmw_update_containers_registry }}"
199-
allowedRegistries: "{{ all_registries }}"
200-
201-
- name: Create a ICSP with repository digest mirrors
202-
when:
203-
- cifmw_openshift_setup_digest_mirrors is defined
204-
- cifmw_openshift_setup_digest_mirrors | length > 0
205-
kubernetes.core.k8s:
206-
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
207-
api_key: "{{ cifmw_openshift_token | default(omit)}}"
208-
context: "{{ cifmw_openshift_context | default(omit)}}"
209-
definition:
210-
apiVersion: operator.openshift.io/v1alpha1
211-
kind: ImageContentSourcePolicy
212-
metadata:
213-
name: registry-digest-mirrors
214-
spec:
215-
repositoryDigestMirrors: "{{ cifmw_openshift_setup_digest_mirrors }}"
171+
- name: Configure insecure registries and ICSP
172+
ansible.builtin.import_tasks: configure_registries.yml
216173

217174
- name: Patch network operator when using OVNKubernetes backend
218175
ansible.builtin.import_tasks: patch_network_operator.yml

0 commit comments

Comments
 (0)