CNTRLPLANE-2916: conditionally create openshift-ingress network policy based on route labeling - #7872
Conversation
… based on route labeling The openshift-ingress NetworkPolicy was previously created unconditionally for every hosted cluster. This policy allows traffic from the management cluster's default ingress controller into the HCP namespace. However, when routes are labeled for the HCP router (LabelHCPRoutes=true), the management cluster's default ingress controller does not serve them, making the policy unnecessary. This includes: - AWS/GCP private or PublicAndPrivate clusters - Clusters using KAS Route with dedicated DNS hostname - ARO HCP (which uses shared ingress with its own policy) This change guards the policy creation behind !LabelHCPRoutes(hcp) and deletes the policy when it is no longer needed (e.g., a cluster transitioning from public to private endpoints). Ref: CNTRLPLANE-2916
Add TestReconcileNetworkPolicies_OpenshiftIngressPolicy with 10 table- driven test cases covering the conditional creation/deletion of the openshift-ingress NetworkPolicy across platforms: - AWS public (create), private (delete), PublicAndPrivate (create) - AWS public with KAS Route+hostname (delete) - GCP PublicAndPrivate (create), private (delete) - IBM Cloud (create - always uses management ingress) - Agent with KAS LB (create), with KAS Route+hostname (delete) - KubeVirt with KAS LB (create) Deletion tests pre-create the policy in the fake client and verify it is removed after reconciliation. Ref: CNTRLPLANE-2916
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@enxebre: This pull request references CNTRLPLANE-2916 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
Skipping CI for Draft Pull Request. |
|
@enxebre: This pull request references CNTRLPLANE-2916 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: enxebre The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/auto-cc |
|
/test verify |
|
/lgtm |
|
Scheduling tests matching the |
|
/verified by units @enxebre |
|
@enxebre: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Test Resultse2e-aws
e2e-aks
|
|
/retest-required |
ac2f829
into
openshift:main
…gress NetworkPolicy Reverts the revert PR openshift#8662 to re-apply the original PR openshift#7872 behavior: conditionally create or delete the openshift-ingress NetworkPolicy based on whether routes are labeled for the HCP router (LabelHCPRoutes). The OVN-Kubernetes port group race that prompted the revert is being addressed via PR openshift#8689 (--hcp-egress-block-cidrs flag), making the blanket always-create workaround unnecessary. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
What this PR does / why we need it:
The
openshift-ingressNetworkPolicy was previously created unconditionally for every hosted cluster. This policy allows traffic from the management cluster's default ingress controller into the HCP namespace, but it is only needed when routes are actually served by the management cluster's default router.When routes are labeled for the HCP router (
LabelHCPRoutes(hcp)returnstrue), the management cluster's default ingress controller does not serve them. This includes:shared-ingressnetwork policy)This change:
!hyperutil.LabelHCPRoutes(hcp)DeleteIfNeededwhenLabelHCPRoutesreturnstrue(handles existing clusters transitioning to private endpoints)Which issue(s) this PR fixes:
Fixes CNTRLPLANE-2916
Special notes for your reviewer:
DeleteIfNeededis safe for non-existent resources (returns(false, nil)— no error, no-op)TestReconcileNetworkPolicies_GCP_PrivateRoutertest continues to pass without modificationmake lint-fixpasses clean,make testpasses (exit code 2 is from pre-existingcovdatatool issue unrelated to this change)Checklist:
🤖 Generated with Claude Code via
/jira:solve [CNTRLPLANE-2916](https://issues.redhat.com/browse/CNTRLPLANE-2916) enxebre