Skip to content

OCPSTRAT-3578: Add NetworkPolicy manifests for openshift-cluster-samples-operator namespace - #703

Open
aroyoredhat wants to merge 1 commit into
openshift:mainfrom
aroyoredhat:network-policy-HPSTRAT-766
Open

OCPSTRAT-3578: Add NetworkPolicy manifests for openshift-cluster-samples-operator namespace#703
aroyoredhat wants to merge 1 commit into
openshift:mainfrom
aroyoredhat:network-policy-HPSTRAT-766

Conversation

@aroyoredhat

@aroyoredhat aroyoredhat commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements tailored NetworkPolicy resources for the openshift-cluster-samples-operator namespace per HPSTRAT-104 / OCPSTRAT-3578.

This satisfies:

  • CIS Kube benchmark 5.3.2 ("Ensure that all Namespaces have Network Policies defined")
  • Red Hat ProdSec guidance on control plane network hardening for OCP 5.0

Policies added

Policy Purpose
default-deny Namespace-wide deny-all for both ingress and egress (podSelector: {})
allow-to-dns All pods can reach openshift-dns on port 5353 (TCP + UDP)
allow-egress-to-api-server Operator pods get unrestricted egress (API server is host-networked, IP/port cannot be targeted by NetworkPolicy)
allow-ingress-to-metrics Operator pods accept inbound TCP on port 60000 (Prometheus scraping)

Notes

  • Health-check probes from the kubelet are not affected by NetworkPolicy
  • The operator requires unrestricted egress because it communicates with the Kubernetes API server (host-networked) and external container registries for ImageStream imports
  • All policies carry the standard capability.openshift.io/name: openshift-samples and release inclusion annotations

Test plan

  • Deploy to a cluster with OVN-Kubernetes and verify the operator starts and reconciles successfully
  • Confirm ImageStream imports continue to work
  • Confirm Prometheus can scrape metrics on port 60000
  • Verify oc get networkpolicy -n openshift-cluster-samples-operator shows all four policies
  • Run CIS benchmark scan and confirm 5.3.2 passes for this namespace

…mespace

Implements tailored network policies per HPSTRAT-104/HPSTRAT-766 to restrict
ingress and egress traffic to only necessary communication, satisfying CIS
Kube benchmark 5.3.2 for this namespace.

Policies added:
- default-deny: namespace-wide deny-all for ingress and egress
- allow-to-dns: egress to openshift-dns on port 5353 (TCP+UDP)
- allow-egress-to-api-server: unrestricted egress for operator pods
  (API server is host-networked, cannot be targeted by NetworkPolicy)
- allow-ingress-to-metrics: TCP port 60000 for Prometheus scraping

Co-authored-by: Cursor <cursoragent@cursor.com>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 4, 2026
@openshift-ci-robot

openshift-ci-robot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@aroyoredhat: This pull request references HPSTRAT-766 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 feature to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

Implements tailored NetworkPolicy resources for the openshift-cluster-samples-operator namespace per HPSTRAT-104 / HPSTRAT-766.

This satisfies:

  • CIS Kube benchmark 5.3.2 ("Ensure that all Namespaces have Network Policies defined")
  • Red Hat ProdSec guidance on control plane network hardening for OCP 5.0

Policies added

Policy Purpose
default-deny Namespace-wide deny-all for both ingress and egress (podSelector: {})
allow-to-dns All pods can reach openshift-dns on port 5353 (TCP + UDP)
allow-egress-to-api-server Operator pods get unrestricted egress (API server is host-networked, IP/port cannot be targeted by NetworkPolicy)
allow-ingress-to-metrics Operator pods accept inbound TCP on port 60000 (Prometheus scraping)

Notes

  • Health-check probes from the kubelet are not affected by NetworkPolicy
  • The operator requires unrestricted egress because it communicates with the Kubernetes API server (host-networked) and external container registries for ImageStream imports
  • All policies carry the standard capability.openshift.io/name: openshift-samples and release inclusion annotations

Test plan

  • Deploy to a cluster with OVN-Kubernetes and verify the operator starts and reconciles successfully
  • Confirm ImageStream imports continue to work
  • Confirm Prometheus can scrape metrics on port 60000
  • Verify oc get networkpolicy -n openshift-cluster-samples-operator shows all four policies
  • Run CIS benchmark scan and confirm 5.3.2 passes for this namespace

Made with Cursor

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.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Walkthrough

The manifest adds default-deny ingress and egress rules for the operator namespace. It then permits DNS resolution, operator access to the Kubernetes API server, and Prometheus access to the operator metrics endpoint.

Changes

Operator namespace network controls

Layer / File(s) Summary
Namespace isolation baseline
manifests/011-network-policy.yaml
Adds default-deny ingress and egress coverage for all pods in the operator namespace.
Required traffic exceptions
manifests/011-network-policy.yaml
Allows DNS egress on TCP and UDP port 5353, unrestricted API-server egress for the operator pod, and metrics ingress on TCP port 60000.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
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 PR adds only manifests/011-network-policy.yaml; the repository uses Go Test functions and contains no changed Ginkgo It, Describe, Context, or When titles.
Test Structure And Quality ✅ Passed The PR changes only manifests/011-network-policy.yaml; the repository has no Ginkgo tests or Ginkgo constructs, so these test-quality requirements are not applicable.
Microshift Test Compatibility ✅ Passed PR adds only a Kubernetes NetworkPolicy manifest file (YAML), not Ginkgo e2e tests. The MicroShift Test Compatibility check applies only when new tests are added.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR changes only manifests/011-network-policy.yaml and adds no Ginkgo e2e tests, so the SNO multi-node compatibility check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed The PR adds only four NetworkPolicy resources. It does not add or modify replicas, affinity, topology spread, node selectors, tolerations, or disruption budgets.
Ote Binary Stdout Contract ✅ Passed The PR adds only manifests/011-network-policy.yaml; it introduces no OTE binary, suite setup, initializer, or process-level stdout/logging code.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The patch adds only one YAML NetworkPolicy manifest; it adds no Ginkgo e2e tests, IPv4 assumptions, or external connectivity requirements.
No-Weak-Crypto ✅ Passed The PR adds only a NetworkPolicy manifest. Its 88 added lines contain no weak algorithms, custom crypto, or secret/token comparisons.
Container-Privileges ✅ Passed The added file contains only four NetworkPolicy resources and no privileged, host namespace, SYS_ADMIN, root, or allowPrivilegeEscalation settings.
No-Sensitive-Data-In-Logs ✅ Passed The only change is a NetworkPolicy YAML manifest; it contains no logging calls, log output, credentials, tokens, PII, session IDs, or customer data.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the addition of NetworkPolicy manifests for the openshift-cluster-samples-operator namespace.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci
openshift-ci Bot requested review from fbm3307 and mfrancisc August 4, 2026 20:08
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aroyoredhat

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-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 4, 2026
@aroyoredhat aroyoredhat changed the title HPSTRAT-766: Add NetworkPolicy manifests for openshift-cluster-samples-operator namespace OCPSTRAT-3578: Add NetworkPolicy manifests for openshift-cluster-samples-operator namespace Aug 4, 2026
@openshift-ci-robot

openshift-ci-robot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@aroyoredhat: This pull request references OCPSTRAT-3578 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 feature to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

Implements tailored NetworkPolicy resources for the openshift-cluster-samples-operator namespace per HPSTRAT-104 / HPSTRAT-766.

This satisfies:

  • CIS Kube benchmark 5.3.2 ("Ensure that all Namespaces have Network Policies defined")
  • Red Hat ProdSec guidance on control plane network hardening for OCP 5.0

Policies added

Policy Purpose
default-deny Namespace-wide deny-all for both ingress and egress (podSelector: {})
allow-to-dns All pods can reach openshift-dns on port 5353 (TCP + UDP)
allow-egress-to-api-server Operator pods get unrestricted egress (API server is host-networked, IP/port cannot be targeted by NetworkPolicy)
allow-ingress-to-metrics Operator pods accept inbound TCP on port 60000 (Prometheus scraping)

Notes

  • Health-check probes from the kubelet are not affected by NetworkPolicy
  • The operator requires unrestricted egress because it communicates with the Kubernetes API server (host-networked) and external container registries for ImageStream imports
  • All policies carry the standard capability.openshift.io/name: openshift-samples and release inclusion annotations

Test plan

  • Deploy to a cluster with OVN-Kubernetes and verify the operator starts and reconciles successfully
  • Confirm ImageStream imports continue to work
  • Confirm Prometheus can scrape metrics on port 60000
  • Verify oc get networkpolicy -n openshift-cluster-samples-operator shows all four policies
  • Run CIS benchmark scan and confirm 5.3.2 passes for this namespace

Made with Cursor

Summary by CodeRabbit

  • Security
  • Added default-deny network traffic controls for the cluster samples operator namespace.
  • Allowed required DNS and API-server egress.
  • Allowed Prometheus metrics access on TCP port 60000.

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.

@aroyoredhat

Copy link
Copy Markdown
Contributor Author

/jira refresh

@openshift-ci-robot

openshift-ci-robot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@aroyoredhat: This pull request references OCPSTRAT-3578 which is a valid jira issue.

Details

In response to this:

/jira refresh

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.

@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@aroyoredhat: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants