Skip to content

adding templates needed for hcp proxy to work - #3716

Merged
openshift-merge-bot[bot] merged 1 commit into
stolostron:mainfrom
kurwang:ACM-37269
Jul 28, 2026
Merged

adding templates needed for hcp proxy to work#3716
openshift-merge-bot[bot] merged 1 commit into
stolostron:mainfrom
kurwang:ACM-37269

Conversation

@kurwang

@kurwang kurwang commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

Add hub-side HCP proxy infrastructure resources to backplane-operator so the hypershift-addon-manager can serve the hcp.ocm.io/v1alpha1 aggregated API for creating/managing HostedClusters from the hub.

Related Issue

ACM-37269

Companion PR: stolostron/hypershift-addon-operator#760

Changes Made

New Templates (pkg/templates/charts/toggle/hypershift/templates/)

  • hypershift-addon-hcp-proxy-service.yaml — Service (port 443 → targetPort 9443) with service-ca annotation for automatic TLS cert generation
  • hypershift-addon-hcp-proxy-apiservice.yaml — Registers v1alpha1.hcp.ocm.io with kube-apiserver aggregation, routing requests to the HCP proxy Service
  • hypershift-addon-hcp-proxy-clusterrole.yaml — Dedicated ClusterRole granting:
    • clusterview.open-cluster-management.io/userpermissions GET (probe auth API + check caller's admin bindings)
    • User/group/serviceaccount impersonation (forward caller identity for permission checks)
    • authentication.k8s.io/userextras impersonation
    • operator.open-cluster-management.io/multiclusterhubs read access
    • cluster.open-cluster-management.io/managedclusters read access (spoke health checks)
    • config.openshift.io/apiservers read access (TLS profile compliance)
  • hypershift-addon-hcp-proxy-clusterrolebinding.yaml — Binds the above ClusterRole to the hypershift-addon-manager-sa ServiceAccount

Modified Templates

  • hypershift-addon-manager-deployment.yaml — Added:
    • containerPort: 9443 (named hcp-proxy) for the proxy listener
    • Volume mount at /etc/hcp-proxy/tls (readOnly) for the service-ca-generated TLS cert
    • Volume definition referencing the hypershift-addon-hcp-proxy-tls Secret (optional: true for non-OpenShift fallback)

Generated Files

  • pkg/templates/rbac_gen.go — Regenerated via go generate to include HCP proxy RBAC markers
  • config/rbac/role.yaml — Regenerated via make manifests (controller-gen v0.19.0) so the backplane-operator itself has permission to manage the new resources

Screenshots (if applicable)

N/A — infrastructure/RBAC changes only.

Checklist

  • I have tested the changes locally and they are functioning as expected.
  • I have updated the documentation (if necessary) to reflect the changes.
  • I have added/updated relevant unit tests (if applicable).
  • I have ensured that my code follows the project's coding standards.
  • I have checked for any potential security issues and addressed them.
  • I have added necessary comments to the code, especially in complex or unclear sections.
  • I have rebased my branch on top of the latest main/master branch.

Additional Notes

  • The HCP proxy code itself lives in the hypershift-addon-operator repo (pkg/manager/hcp_proxy.go), merged in PR chore(deps): update konflux references to 2be7c9c (backplane-2.4) #760. This PR provides the infrastructure (Service, APIService, RBAC, Deployment wiring) that backplane-operator is responsible for provisioning.
  • The template pattern (service-ca annotation + inject-cabundle on APIService + port 443) follows existing ACM conventions used by ocm-proxyserver and clusterview.
  • controller-gen was upgraded from stale v0.15.0 → v0.19.0 (matching what CONTROLLER_TOOLS_VERSION already specified in the Makefile) to fix incompatibility with k8s v0.35.x vendored dependencies.

Reviewers

/cc @yiraeChristineKim

Definition of Done

  • Code is reviewed.
  • Code is tested.
  • Documentation is updated.
  • All checks and tests pass.
  • Approved by at least one reviewer.
  • Merged into the main/master branch.

Summary by CodeRabbit

  • New Features
    • Added a Hypershift add-on proxy endpoint registration (v1alpha1) for hcp.ocm.io.
    • Introduced an HTTPS proxy Service and exposed the manager proxy port on 9443.
    • Added TLS support for the proxy via a mounted TLS secret.
  • Bug Fixes
    • Updated RBAC permissions to support required proxy impersonation and read-only cluster discovery (users/groups/serviceaccounts; managed clusters and API server access).

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kurwang, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository: stolostron/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e6a36d59-9112-4ff3-803d-d1ba8b64684a

📥 Commits

Reviewing files that changed from the base of the PR and between 4bcb8d2 and 0771686.

📒 Files selected for processing (7)
  • config/rbac/role.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-apiservice.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-clusterrole.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-clusterrolebinding.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-service.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-manager-deployment.yaml
  • pkg/templates/rbac_gen.go

Walkthrough

Changes

HCP proxy integration

Layer / File(s) Summary
Proxy endpoint and TLS wiring
pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-apiservice.yaml, pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-service.yaml, pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-manager-deployment.yaml
Registers the hcp.ocm.io/v1alpha1 APIService, routes traffic through the proxy Service, and adds the manager’s TLS mount and port.
Proxy and operator RBAC
pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-clusterrole.yaml, pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-clusterrolebinding.yaml, config/rbac/role.yaml, pkg/templates/rbac_gen.go
Adds proxy read and impersonation permissions, binds them to the manager ServiceAccount, and updates operator RBAC annotations and rules.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant APIService
  participant ProxyService
  participant ManagerDeployment
  APIService->>ProxyService: Route hcp.ocm.io/v1alpha1 requests on port 443
  ProxyService->>ManagerDeployment: Forward TCP traffic to port 9443
  ManagerDeployment->>ManagerDeployment: Use mounted hcp-proxy TLS secret
Loading

Possibly related PRs

Suggested labels: lgtm, approved

Suggested reviewers: dislbenn, fxiang1

🚥 Pre-merge checks | ✅ 10
✅ Passed checks (10 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding HCP proxy templates and wiring needed for the proxy to work.
Description check ✅ Passed The description follows the template well and includes purpose, issue, changes made, checklist, notes, reviewers, and DoD.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The diff changes only RBAC/templates; no *_test.go or suite.go files were modified, so there are no Ginkgo titles to check.
Test Structure And Quality ✅ Passed No Go test files were changed in this PR; only templates, RBAC YAML, and a generated comment file were modified.
No-Weak-Crypto ✅ Passed Touched files are RBAC/manifests only; scan found no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret comparisons.
Container-Privileges ✅ Passed No changed manifest enables privileged mode, host networking/PID/IPC, SYS_ADMIN, or allowPrivilegeEscalation; the Deployment hardens the container.
No-Sensitive-Data-In-Logs ✅ Passed Changed files are RBAC/templates only; scans found no log statements or sensitive-data exposure in the touched files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-manager-deployment.yaml (2)

68-76: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Enforce non-root execution.

runAsNonRoot and runAsUser remain commented out, so the container identity is determined by the image default. Set runAsNonRoot: true and use a compatible non-root UID.

As per path instructions, Kubernetes/OpenShift workloads must set securityContext: runAsNonRoot.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-manager-deployment.yaml`
around lines 68 - 76, Update the deployment’s securityContext to enforce
non-root execution by enabling runAsNonRoot: true and setting runAsUser to a
compatible non-root UID, rather than leaving both fields commented out. Preserve
the existing conditional seccompProfile configuration.

Source: Path instructions


127-130: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

Add CPU and memory limits.

This container defines requests only. Add both CPU and memory limits to prevent unbounded resource consumption.

As per path instructions, resource limits are required on every container.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-manager-deployment.yaml`
around lines 127 - 130, Update the container resource specification under
resources in the hypershift-addon-manager deployment to add both cpu and memory
limits alongside the existing requests. Use appropriate bounded values
consistent with the chart’s resource conventions, ensuring every container
defines CPU and memory limits.

Source: Path instructions

pkg/templates/rbac_gen.go (1)

1-3: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add the required Apache 2.0 copyright header.

This Go file has no copyright/license header before the generated-code marker.

As per path instructions, **/*.go: “Copyright header required: Apache 2.0 with "Red Hat, Inc." or "stolostron contributors".”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/templates/rbac_gen.go` around lines 1 - 3, Add the required Apache 2.0
copyright header naming “Red Hat, Inc.” or “stolostron contributors” before the
generated-code marker in the generated Go file, while preserving the existing
“Code generated by go generate; DO NOT EDIT.” notice.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-clusterrole.yaml`:
- Line 4: Define one shared DNS-safe, lowercase, hyphenated name template for
the HCP proxy RBAC objects, then reuse it for the ClusterRole name,
ClusterRoleBinding metadata.name, and roleRef.name. Update both
hypershift-addon-hcp-proxy-clusterrole.yaml:4 and
hypershift-addon-hcp-proxy-clusterrolebinding.yaml:4-8; preserve the existing
object relationships while eliminating colons and uppercase characters.
- Around line 21-23: The RBAC roles currently grant impersonation on bare
userextras instead of concrete subresources. Update the source RBAC annotation
and generated output in
pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-clusterrole.yaml
(lines 21-23), config/rbac/role.yaml (lines 624-629), and
pkg/templates/rbac_gen.go (line 258) so every affected role lists each supported
userextras/<key> resource explicitly, including userextras/scopes, and
regenerate the generated files from the updated source.

In
`@pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-manager-deployment.yaml`:
- Around line 61-64: Update the hypershift-addon-manager deployment container
around the hcp-proxy-tls volume to require the TLS Secret instead of allowing an
absent mount. Add HTTPS liveness/readiness probes targeting the proxy’s actual
health endpoint on port 9443, and enforce non-root execution through the
container security context so API aggregation only receives ready TLS-backed
traffic.

---

Outside diff comments:
In
`@pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-manager-deployment.yaml`:
- Around line 68-76: Update the deployment’s securityContext to enforce non-root
execution by enabling runAsNonRoot: true and setting runAsUser to a compatible
non-root UID, rather than leaving both fields commented out. Preserve the
existing conditional seccompProfile configuration.
- Around line 127-130: Update the container resource specification under
resources in the hypershift-addon-manager deployment to add both cpu and memory
limits alongside the existing requests. Use appropriate bounded values
consistent with the chart’s resource conventions, ensuring every container
defines CPU and memory limits.

In `@pkg/templates/rbac_gen.go`:
- Around line 1-3: Add the required Apache 2.0 copyright header naming “Red Hat,
Inc.” or “stolostron contributors” before the generated-code marker in the
generated Go file, while preserving the existing “Code generated by go generate;
DO NOT EDIT.” notice.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: stolostron/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1c6ac871-155b-4508-82b8-12daa17d4785

📥 Commits

Reviewing files that changed from the base of the PR and between 4a0c665 and 3999e6e.

📒 Files selected for processing (7)
  • config/rbac/role.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-apiservice.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-clusterrole.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-clusterrolebinding.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-service.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-manager-deployment.yaml
  • pkg/templates/rbac_gen.go

@dislbenn

Copy link
Copy Markdown
Collaborator

@kurwang @yiraeChristineKim There are some coderabbit comments that need to be addressed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
config/rbac/role.yaml (1)

13-16: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Limit wildcard access on Services and ServiceAccounts.

config/rbac/role.yaml grants * verbs on core services and serviceaccounts, which opens the operator to arbitrary service-routing and service-identity changes across the cluster. The RBAC generation source references narrower annotations for these resources; keep the generated/committed rules to the minimal verbs actually required and regenerate the RBAC manifests from //go:generate go run pkg/templates/rbac.go.

Also applies to: 79-84

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config/rbac/role.yaml` around lines 13 - 16, Update the RBAC generation
source and committed rules for core services and serviceaccounts to use the
narrow verbs required by their annotations instead of wildcard access.
Regenerate config/rbac/role.yaml using the existing pkg/templates/rbac.go
go:generate command, ensuring both affected resource rule blocks retain only the
minimal required verbs.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-clusterrolebinding.yaml`:
- Around line 4-8: Quote the Helm template expressions used for the RBAC names
in both metadata.name and roleRef.name within the hypershift-addon-hcp-proxy
ClusterRoleBinding, preserving the existing colon-separated rendered values as
valid YAML strings.

---

Outside diff comments:
In `@config/rbac/role.yaml`:
- Around line 13-16: Update the RBAC generation source and committed rules for
core services and serviceaccounts to use the narrow verbs required by their
annotations instead of wildcard access. Regenerate config/rbac/role.yaml using
the existing pkg/templates/rbac.go go:generate command, ensuring both affected
resource rule blocks retain only the minimal required verbs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: stolostron/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 21eb1513-a687-48bd-b3fe-ed92a63d248c

📥 Commits

Reviewing files that changed from the base of the PR and between 3999e6e and 4bcb8d2.

📒 Files selected for processing (7)
  • config/rbac/role.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-apiservice.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-clusterrole.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-clusterrolebinding.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-service.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-manager-deployment.yaml
  • pkg/templates/rbac_gen.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-hcp-proxy-apiservice.yaml
  • pkg/templates/charts/toggle/hypershift/templates/hypershift-addon-manager-deployment.yaml

@kurwang

kurwang commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@dislbenn
coderabbit comments should be addressed in the pr now thanks!

Signed-off-by: kurwang <kurwang@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud

Copy link
Copy Markdown

@dislbenn

Copy link
Copy Markdown
Collaborator

/lgtm

@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dislbenn, kurwang, yiraeChristineKim

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot
openshift-merge-bot Bot merged commit 4fd486a into stolostron:main Jul 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants