Skip to content

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

Open
aroyoredhat wants to merge 3 commits 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 3 commits 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

Summary by CodeRabbit

  • New Features
    • Added namespace-wide default-deny network policies to strengthen traffic controls.
    • Allowed required DNS, API server, and registry communication for the operator.
    • Enabled Prometheus metrics access on TCP port 60000.
    • Restricted network access to explicitly permitted traffic, improving isolation and reducing unintended connectivity.

…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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 44246443-7e8c-4b30-9e5d-9ea327e6f715

📥 Commits

Reviewing files that changed from the base of the PR and between b477e0b and bc94de5.

📒 Files selected for processing (1)
  • manifests/011-network-policy.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • manifests/011-network-policy.yaml

Walkthrough

The manifest adds default-deny ingress and egress rules for the operator namespace. It allows DNS egress, unrestricted operator egress, and Prometheus metrics ingress.

Changes

Namespace network controls

Layer / File(s) Summary
Default-deny and DNS rules
manifests/011-network-policy.yaml
Adds default-deny ingress and egress rules. Allows TCP and UDP DNS egress to openshift-dns.
Operator connectivity
manifests/011-network-policy.yaml
Allows unrestricted egress from the operator pod. Allows Prometheus ingress on TCP port 60000 from openshift-monitoring.

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

Suggested reviewers: fbm3307, mfrancisc

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the addition of NetworkPolicy manifests for the openshift-cluster-samples-operator namespace.
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 changes only a NetworkPolicy YAML name; no Ginkgo tests or test titles were added or modified.
Test Structure And Quality ✅ Passed The PR changes only manifests/011-network-policy.yaml. The repository contains no Ginkgo test code, so this check is not applicable.
Microshift Test Compatibility ✅ Passed The pull request changes only manifests/011-network-policy.yaml and adds no Ginkgo e2e tests, so the MicroShift test compatibility check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The commit changes only manifests/011-network-policy.yaml; no Ginkgo e2e tests or multi-node assumptions were added.
Topology-Aware Scheduling Compatibility ✅ Passed The PR adds only NetworkPolicy resources; bounded diff scans found no replicas, affinity, topology spread, node selectors, tolerations, or PDB scheduling constraints.
Ote Binary Stdout Contract ✅ Passed The PR changes only a YAML NetworkPolicy name; it adds no OTE binary, suite setup, stdout write, or logging configuration code.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The pull request changes only a NetworkPolicy YAML manifest and adds no Ginkgo e2e tests, IPv4 assumptions, or external connectivity requirements.
No-Weak-Crypto ✅ Passed The PR adds only a NetworkPolicy YAML manifest; scans of all added lines found no MD5, SHA1, DES, RC4, Blowfish, ECB, custom crypto, or secret comparisons.
Container-Privileges ✅ Passed The PR adds only NetworkPolicy resources to 011-network-policy.yaml. NetworkPolicies do not contain container specifications, security contexts, or privileged settings. None of the flagged items (p...
No-Sensitive-Data-In-Logs ✅ Passed The complete PR diff changes only a NetworkPolicy name; it adds no logging code or log content and contains no sensitive-data indicators.
✨ 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.

aroyoredhat and others added 2 commits August 5, 2026 08:05
- Rename allow-egress-to-api-server to allow-operator-egress to
  accurately reflect that the policy is unrestricted egress (not
  limited to the API server alone)
- Scope metrics ingress to only openshift-monitoring namespace
  instead of allowing from anywhere

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@openshift-ci

openshift-ci Bot commented Aug 6, 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