Skip to content

Commit 817e8d4

Browse files
mvalarhwcheang
authored andcommitted
Buildah can use registry self-signed certificate
Signed-off-by: Martin Vala <[email protected]>
1 parent a9b1040 commit 817e8d4

File tree

7 files changed

+73
-1
lines changed

7 files changed

+73
-1
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,27 @@ tkn pipeline start operator-ci-pipeline \
5353
--showlog
5454
```
5555

56+
If using an kind cluster with registry, the CI pipeline can be triggered using the tkn CLI like so:
57+
> Warning: This mode is currently in development and it might not work yet.
58+
59+
> Note: kind cluster with registry setup is documented [here](docs/kind-cluster.md#kind-cluster-setup)
60+
```bash
61+
tkn pipeline start operator-ci-pipeline \
62+
--use-param-defaults \
63+
--param git_repo_url=https://github.com/redhat-openshift-ecosystem/operator-pipelines-test.git \
64+
--param git_branch=main \
65+
--param bundle_path=operators/kogito-operator/1.6.0-ok \
66+
--param env=prod \
67+
--param gitInitImage=quay.io/operator_testing/pipelines-git-init-rhel8:latest \
68+
--param builder_image=quay.io/operator_testing/buildah:latest \
69+
--param registry=$(hostname):5000 \
70+
--workspace name=pipeline,volumeClaimTemplateFile=templates/workspace-template.yml \
71+
--workspace name=registry-cacert,config=registry-ca-cert
72+
--showlog
73+
```
74+
75+
76+
5677
To enable opening the PR and uploading the pipeline logs (visible to the certification project
5778
owner in Red Hat Connect), pass the following argument:
5879

ansible/roles/install-kind-cluster/defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ kind_binary: kind
99
kind_version: v0.12.0
1010
kind_kube_version: v1.23.4
1111
kind_cluster_name: "operator-test"
12+
kind_cluster_apiServerAddress: "127.0.0.1"
1213
kund_cluster_install_retries: 1
1314
kind_config_path: "{{ ikc_tmp_dir }}/kind_config.yaml"
1415
kind_config_map_registry_path: "{{ ikc_tmp_dir }}/kind_config_map_registry.yaml"
@@ -21,6 +22,9 @@ registry_name: kind-registry
2122
registry_port: 5000
2223
registry_ssl: false
2324
registry_cert_dir: "{{ op_work_dir }}/certs"
25+
registry_ca_cert_name: "registry-ca-cert"
26+
registry_ca_cert_namespace: "default"
27+
2428
kubectl_binary: kubectl
2529
kubectl_version: v1.23.5
2630
oc_binary: oc

ansible/roles/install-kind-cluster/tasks/install.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@
99
- clean
1010
- install
1111

12+
- name: "Create secret 'kubeconfig'"
13+
kubernetes.core.k8s:
14+
state: present
15+
definition:
16+
apiVersion: v1
17+
kind: Secret
18+
metadata:
19+
name: "kubeconfig"
20+
namespace: "default"
21+
data:
22+
kubeconfig: "{{ lookup('file', ansible_env.HOME + '/.kube/config') | b64encode }}"
23+
tags:
24+
- install
25+
1226
- name: "Install registry"
1327
ansible.builtin.include_tasks:
1428
file: install_registry.yml

ansible/roles/install-kind-cluster/tasks/install_registry.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,17 @@
9090
kubernetes.core.k8s:
9191
state: present
9292
src: "{{ kind_config_map_registry_path }}"
93+
94+
- name: "Create configMap '{{ registry_ca_cert_name }}' in namespace '{{ registry_ca_cert_namespace }}' from file '{{ registry_cert_dir }}/domain.crt'"
95+
kubernetes.core.k8s:
96+
state: present
97+
definition:
98+
apiVersion: v1
99+
kind: ConfigMap
100+
metadata:
101+
name: "{{ registry_ca_cert_name }}"
102+
namespace: "{{ registry_ca_cert_namespace }}"
103+
data:
104+
registry-ca.crt: "{{ lookup('file', registry_cert_dir + '/domain.crt') }}"
93105
tags:
94106
- install

ansible/roles/install-kind-cluster/templates/kind_config.yaml.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
kind: Cluster
22
apiVersion: kind.x-k8s.io/v1alpha4
3+
networking:
4+
# WARNING: It is _strongly_ recommended that you keep this the default
5+
# (127.0.0.1) for security reasons. However it is possible to change this.
6+
apiServerAddress: "{{ kind_cluster_apiServerAddress }}"
7+
apiServerPort: 6443
38
{% if registry_enable|bool == true %}
49
containerdConfigPatches:
510
- |-

ansible/roles/operator-pipeline/templates/openshift/pipelines/operator-ci-pipeline.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ spec:
2727
default: "registry.redhat.io/rhel8/buildah@sha256:a1e5cc0fb334e333e5eab69689223e8bd1f0c060810d260603b26cf8c0da2023"
2828
- name: registry
2929
default: image-registry.openshift-image-registry.svc:5000
30+
- name: podman_image
31+
description: Podman image
32+
default: "registry.redhat.io/rhel8/podman:8.5-13"
3033
- name: env
3134
description: Which environment to run in. Can be one of [dev, qa, stage, prod]
3235
default: "prod"
@@ -72,6 +75,8 @@ spec:
7275
optional: true
7376
- name: registry-credentials
7477
optional: true
78+
- name: registry-cacert
79+
optional: true
7580
tasks:
7681
- name: set-env
7782
taskRef:
@@ -313,6 +318,8 @@ spec:
313318
subPath: src
314319
- name: credentials
315320
workspace: registry-credentials
321+
- name: cacert
322+
workspace: registry-cacert
316323

317324
# Index image contains a record of bundle images from which
318325
# manifests could be extract in order to install an operator.
@@ -327,6 +334,8 @@ spec:
327334
value: "$(params.pipeline_image)"
328335
- name: bundle_image
329336
value: *bundleImage
337+
- name: podman_image
338+
value: "$(params.podman_image)"
330339
- name: from_index
331340
value: "$(tasks.get-supported-versions.results.max_supported_index)"
332341
workspaces:

ansible/roles/operator-pipeline/templates/openshift/tasks/buildah.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ spec:
2828
name: CONTEXT
2929
type: string
3030
- default: "true"
31-
description: Verify the TLS on the registry endpoint (for push/pull to a non-TLS
31+
description: >-
32+
Verify the TLS on the registry endpoint (for push/pull to a non-TLS
3233
registry)
3334
name: TLSVERIFY
3435
type: string
@@ -88,6 +89,10 @@ spec:
8889
EXTRA_ARGS+=" --authfile $(workspaces.credentials.path)/.dockerconfigjson"
8990
fi
9091
92+
if [[ "$(workspaces.cacert.bound)" == "true" ]]; then
93+
export SSL_CERT_FILE=$(workspaces.cacert.path)/registry-ca.crt
94+
fi
95+
9196
echo "Pushing $(params.IMAGE)"
9297
buildah --storage-driver=$(params.STORAGE_DRIVER) push \
9398
$(params.PUSH_EXTRA_ARGS) $EXTRA_ARGS --tls-verify=$(params.TLSVERIFY) \
@@ -115,3 +120,5 @@ spec:
115120
- name: source
116121
- name: credentials
117122
optional: true
123+
- name: cacert
124+
optional: true

0 commit comments

Comments
 (0)