RHIDP-14790: Add OLM v1 code path to install-rhdh-catalog-source.sh#3047
Conversation
Add --olm-version v0|v1|auto flag (default: auto) with CRD-based detection of OLM v1. When OLM v1 is detected, creates ClusterCatalog, ServiceAccount, ClusterRoleBinding, and ClusterExtension instead of OLM v0 CatalogSource, OperatorGroup, and Subscription. The IIB rendering/rebuild phase is shared by both paths. OLM v0 behavior is fully preserved for backward compatibility. Signed-off-by: Fortune-Ndlovu <fndlovu@redhat.com> Assisted-by: Claude (claude-opus-4-6)
PR Summary by QodoAdd OLM v1 support to install-rhdh-catalog-source.sh Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Cluster-admin installer binding
|
| # ClusterRoleBinding granting cluster-admin to the installer SA | ||
| CRB_NAME="${OPERATOR_NAME_TO_INSTALL}-installer-binding" | ||
| echo "apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: ${CRB_NAME} | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: cluster-admin | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: ${SA_NAME} | ||
| namespace: ${NAMESPACE_SUBSCRIPTION} | ||
| " > "$TMPDIR"/ClusterRoleBinding.yml && invoke_cluster_cli apply -f "$TMPDIR"/ClusterRoleBinding.yml |
There was a problem hiding this comment.
1. Cluster-admin installer binding 🐞 Bug ⛨ Security
In the OLM v1 path, the script creates a ClusterRoleBinding that grants the installer ServiceAccount the built-in cluster-admin ClusterRole, giving it full cluster-wide privileges. This leaves a highly privileged credential in-cluster and substantially increases impact if the ServiceAccount token is leaked or the namespace is compromised.
Agent Prompt
### Issue description
The OLM v1 install flow creates a `ClusterRoleBinding` to `cluster-admin` for the `${OPERATOR_NAME_TO_INSTALL}-installer` ServiceAccount. This grants broad, persistent cluster-admin privileges, which is an unnecessary security risk for a script-driven install path.
### Issue Context
The new OLM v1 code path creates a ServiceAccount and binds it to `cluster-admin` before creating the `ClusterExtension`.
### Fix Focus Areas
- Replace the `cluster-admin` ClusterRoleBinding with least-privilege permissions required by the OLM v1 ClusterExtension installer (use an existing purpose-built ClusterRole if available, otherwise define a custom ClusterRole with only needed verbs/resources).
- If elevated privileges are truly required, gate them behind an explicit flag (e.g. `--grant-cluster-admin`) and/or clean them up after installation completes (delete the ClusterRoleBinding/ServiceAccount once the ClusterExtension is installed).
- .rhdh/scripts/install-rhdh-catalog-source.sh[928-951]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
/agentic-review |
… the operator-controller namespace and granting image-puller access to necessary service accounts. Update ClusterCatalog and ClusterRoleBinding creation to align with OLM v1 specifications.
| debugf "Using operator-controller namespace: ${NAMESPACE_OLM_CONTROLLER}" | ||
|
|
||
| # Grant image-puller access to OLM v1 controller SAs so they can pull images from the internal registry | ||
| oc policy add-role-to-user system:image-puller system:serviceaccount:${NAMESPACE_CATALOGD}:catalogd-controller-manager -n rhdh || true |
|
|
||
| # Grant image-puller access to OLM v1 controller SAs so they can pull images from the internal registry | ||
| oc policy add-role-to-user system:image-puller system:serviceaccount:${NAMESPACE_CATALOGD}:catalogd-controller-manager -n rhdh || true | ||
| oc policy add-role-to-user system:image-puller system:serviceaccount:${NAMESPACE_OLM_CONTROLLER}:operator-controller-controller-manager -n rhdh || true |
| " > "$TMPDIR"/ClusterRoleBinding.yml && invoke_cluster_cli apply -f "$TMPDIR"/ClusterRoleBinding.yml | ||
|
|
||
| # Grant installer SA image-puller access so it can pull operator images from the internal registry | ||
| oc policy add-role-to-user system:image-puller system:serviceaccount:${NAMESPACE_SUBSCRIPTION}:${SA_NAME} -n rhdh || true |
|




Adds an
--olm-version v0|v1|autoCLI flag (default:auto) toinstall-rhdh-catalog-source.shwith CRD-based OLM v1 detection. When OLM v1 is detected (or forced), the script creates a ClusterCatalog and ClusterExtension with a ServiceAccount and ClusterRoleBinding, instead of the OLM v0 CatalogSource, Subscription, and OperatorGroup. Resolution is pinned to the custom catalog viaselector.matchLabels, and CRD upgrade safety preflight is disabled (enforcement: None) per the known blocker RHIDP-8656. The OLM v0 path is fully preserved for backward compatibility on older clusters.Which issue(s) does this PR fix or relate to
Resolves: https://redhat.atlassian.net/browse/RHIDP-14790
PR acceptance criteria
How to test changes / Special notes to the reviewer
bash .rhdh/scripts/install-rhdh-catalog-source.sh --latest --install-operator rhdh 2>&1 | tee /tmp/olmv1-test3.log)
Signed-off-by: Fortune-Ndlovu fndlovu@redhat.com
Assisted-by: Claude (claude-opus-4-6)