Skip to content

ACM-31164: Test and validate network policies for Image Based components - #847

Open
shay23bra wants to merge 1 commit into
openshift:mainfrom
shay23bra:ACM-31164-network-policy
Open

ACM-31164: Test and validate network policies for Image Based components#847
shay23bra wants to merge 1 commit into
openshift:mainfrom
shay23bra:ACM-31164-network-policy

Conversation

@shay23bra

@shay23bra shay23bra commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a NetworkPolicy for the image-based-install-operator pod, following the ACM 5.0 DDR pattern (Create-Once + Operand Ownership)
  • Restricts ingress to only the ports the operator listens on (8080 metrics, 9443 webhook, 8000 image server)
  • Restricts egress to DNS, Kubernetes API, spoke cluster APIs (port 6443), and HTTPS (port 443)

NetworkPolicy Details

Ingress:

  • Same-namespace traffic (podSelector: {})
  • OpenShift router → port 8000 (image server)
  • Monitoring → port 8080 (metrics, exposed via ServiceMonitor on OCP)
  • Any → port 9443 (webhook, called by kube-apiserver)
  • Any → port 8000 (image server, called by Ironic/BMC)

Egress:

  • DNS (openshift-dns, port 5353)
  • Kubernetes API (port 6443)
  • Spoke cluster API servers (0.0.0.0/0, port 6443)
  • HTTPS (0.0.0.0/0, port 443, excluding AWS metadata)

Test plan

  • Deploy NetworkPolicy on cluster with IBIO installed
  • Verify IBIO pod remains healthy (no restarts, no network errors)
  • Verify webhook (port 9443) responds from inside and outside namespace
  • Verify image server (port 8000) responds from inside and outside namespace
  • Verify random ports are blocked from inside and outside namespace
  • Verify egress to DNS and Kubernetes API works
  • Verify metrics endpoint (port 8080) is scrapable via ServiceMonitor on OCP
  • Run end-to-end image-based installation flow on OCP

Test results (kind + Calico)

=== SUMMARY: 13 passed, 0 failed ===

Ingress allowed:  9443 (webhook), 8000 (image server), 8081 (health) ✓
Ingress blocked:  random ports denied from inside and outside namespace ✓
Cross-namespace:  8000 and 9443 reachable from default namespace ✓
Egress:           DNS resolution and Kubernetes API reachable ✓
Pod health:       running, all containers ready, no restarts, no network errors ✓

Note: metrics port 8080 binds to localhost in the manager — reachable via ServiceMonitor/Service on OCP, not via pod IP directly.

Related

Summary by CodeRabbit

  • New Features
    • Added a Kubernetes NetworkPolicy for the image-based installation operator to restrict and allow required ingress/egress traffic.
  • Chores
    • Included the new NetworkPolicy in the manager deployment configuration.
    • Updated the bundle metadata timestamp in the ClusterServiceVersion manifest.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 19, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@shay23bra: This pull request references ACM-31164 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 task to target either version "5.0." or "openshift-5.0.", but it targets "ACM 5.0.0" instead.

Details

In response to this:

Summary

  • Adds a NetworkPolicy for the image-based-install-operator pod, following the ACM 5.0 DDR pattern (Create-Once + Operand Ownership)
  • Restricts ingress to only the ports the operator listens on (8080 metrics, 9443 webhook, 8000 image server)
  • Restricts egress to DNS, Kubernetes API, spoke cluster APIs (port 6443), and HTTPS (port 443)

NetworkPolicy Details

Ingress:

  • Same-namespace traffic (podSelector: {})
  • OpenShift router → port 8000 (image server)
  • Monitoring → port 8080 (metrics)
  • Any → port 9443 (webhook, called by kube-apiserver)
  • Any → port 8000 (image server, called by Ironic/BMC)

Egress:

  • DNS (openshift-dns, port 5353)
  • Kubernetes API (port 6443)
  • Spoke cluster API servers (0.0.0.0/0, port 6443)
  • HTTPS (0.0.0.0/0, port 443, excluding AWS metadata)

Test plan

  • Deploy NetworkPolicy on OCP cluster with IBIO installed
  • Verify IBIO pod remains healthy (no restarts, no network errors)
  • Verify webhook (port 9443) responds from outside namespace
  • Verify image server (port 8000) responds from outside namespace
  • Verify metrics endpoint (port 8080) is scrapable
  • Verify random ports are blocked
  • Run end-to-end image-based installation flow

Related

  • Jira: ACM-31164
  • Epic: ACM-31152 (network policies for all ACM components)
  • DDR: ACM-DDR-XXX (Enablement for NetworkPolicies by ACM Operators)
  • Also addresses: ACM-36702

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 Jul 19, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 19, 2026
@openshift-ci

openshift-ci Bot commented Jul 19, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shay23bra
Once this PR has been reviewed and has the lgtm label, please assign gamli75 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@coderabbitai

coderabbitai Bot commented Jul 19, 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: 42ab03fe-f45e-4e21-8e22-fa49cb15d1c1

📥 Commits

Reviewing files that changed from the base of the PR and between bfd7e38 and 1a23edb.

📒 Files selected for processing (4)
  • bundle/manifests/image-based-install-operator-networkpolicy.yaml
  • bundle/manifests/image-based-install-operator.clusterserviceversion.yaml
  • config/manager/image-based-install-operator-networkpolicy.yaml
  • config/manager/kustomization.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • bundle/manifests/image-based-install-operator.clusterserviceversion.yaml
  • config/manager/kustomization.yaml
  • config/manager/image-based-install-operator-networkpolicy.yaml

Walkthrough

Adds and registers a Kubernetes NetworkPolicy for the image-based install operator, defining ingress and egress access for DNS, monitoring, API, HTTPS, and selected ports. Bundles the policy and updates the ClusterServiceVersion creation timestamp.

Changes

Operator network policy

Layer / File(s) Summary
Define and register network policy
config/manager/image-based-install-operator-networkpolicy.yaml, config/manager/kustomization.yaml
Defines ingress and egress rules for operator pods and adds the NetworkPolicy to manager resources.
Bundle policy and metadata
bundle/manifests/image-based-install-operator-networkpolicy.yaml, bundle/manifests/image-based-install-operator.clusterserviceversion.yaml
Adds the NetworkPolicy to the bundle and updates the CSV createdAt annotation timestamp.

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

Suggested reviewers: leo8a, tsorya

🚥 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 is relevant to the main change: adding network policies for Image Based components, though it emphasizes testing/validation rather than the change itself.
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 No Ginkgo tests were added or modified; the PR only changes YAML manifests, so there are no test titles to evaluate.
Test Structure And Quality ✅ Passed PR only changes YAML manifests; no Ginkgo test files or test logic changed, so these test-quality criteria don’t apply.
Microshift Test Compatibility ✅ Passed No new Ginkgo tests were added; the PR only changes YAML/CSV manifests, so MicroShift compatibility is not implicated.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo/e2e test code was added; the PR only changes YAML manifests, so the SNO compatibility check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed Changes only add a NetworkPolicy/kustomization and update a CSV timestamp; no affinity, nodeSelector, topology spread, toleration, or replica logic was introduced.
Ote Binary Stdout Contract ✅ Passed PASS: PR only changes YAML manifests and a CSV timestamp; no Go entrypoints or suite setup were modified, so no new stdout writes were introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the PR only changes manifests and kustomization, so this IPv4/external-connectivity test check is not applicable.
No-Weak-Crypto ✅ Passed PASS: The modified YAML/CSV files contain no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret-comparison logic.
Container-Privileges ✅ Passed PASS: Touched manifests add only a NetworkPolicy; no privileged/root/host* or SYS_ADMIN settings were introduced, and existing securityContext stays false.
No-Sensitive-Data-In-Logs ✅ Passed Only NetworkPolicy/CSV manifest changes were added; no logging code or sensitive data appears in the diff.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
bundle/manifests/image-based-install-operator-networkpolicy.yaml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

bundle/manifests/image-based-install-operator.clusterserviceversion.yaml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

config/manager/image-based-install-operator-networkpolicy.yaml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

  • 1 others

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: 2

🤖 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 `@config/manager/image-based-install-operator-networkpolicy.yaml`:
- Around line 17-18: Update the ingress rule in the network policy to add
explicit port restrictions, allowing same-namespace pods to reach only the
documented operator service ports and excluding the manager health endpoint on
8081. Preserve the existing podSelector scope while configuring the allowed
ports in the policy’s ports section.
- Around line 35-38: Restrict the TCP/9443 ingress rule in the image-based
install operator network policy to kube-apiserver traffic by adding the
platform-appropriate API-server source CIDR or selector under from. Preserve
port 9443 and the existing webhook ingress intent while preventing access from
all other sources.
🪄 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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 11b550e5-21c1-43b0-8b94-c68da4b7a283

📥 Commits

Reviewing files that changed from the base of the PR and between 6621941 and a3cc0b7.

📒 Files selected for processing (2)
  • config/manager/image-based-install-operator-networkpolicy.yaml
  • config/manager/kustomization.yaml

Comment on lines +17 to +18
- from:
- podSelector: {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Restrict same-namespace ingress to the intended ports.

This rule allows every pod in the namespace to reach every port on the operator, including the manager health endpoint on 8081. Add explicit port rules so the policy actually limits ingress to the documented service ports.

🤖 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/manager/image-based-install-operator-networkpolicy.yaml` around lines
17 - 18, Update the ingress rule in the network policy to add explicit port
restrictions, allowing same-namespace pods to reach only the documented operator
service ports and excluding the manager health endpoint on 8081. Preserve the
existing podSelector scope while configuring the allowed ports in the policy’s
ports section.

Comment on lines +35 to +38
# Webhook calls from kube-apiserver
- ports:
- protocol: TCP
port: 9443

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Scope webhook ingress to the API-server source.

A rule with ports but no from permits TCP/9443 from all sources, not just the kube-apiserver described by the comment. Restrict it using the platform-appropriate API-server source CIDR or selector.

🤖 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/manager/image-based-install-operator-networkpolicy.yaml` around lines
35 - 38, Restrict the TCP/9443 ingress rule in the image-based install operator
network policy to kube-apiserver traffic by adding the platform-appropriate
API-server source CIDR or selector under from. Preserve port 9443 and the
existing webhook ingress intent while preventing access from all other sources.

@shay23bra
shay23bra marked this pull request as ready for review July 20, 2026 08:34
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 20, 2026
@openshift-ci
openshift-ci Bot requested review from leo8a and tsorya July 20, 2026 08:34
@giladravid16

Copy link
Copy Markdown
Contributor

@shay23bra A few things:

  1. You need to run make bundle
  2. The ipBlocks you used also block all ipv6 network, I'm not sure if they're even needed
  3. I think some rules that are not needed since they are part of a larger rule, for example the Kubernetes API egress rule is also allowed by the Spoke cluster API servers egress rule (unless ipBlock knows to block service and pod ips)

@shay23bra

Copy link
Copy Markdown
Contributor Author

@giladravid16

Good catches, thanks!

  1. Done.
  2. Good point - added ::/0 for IPv6 dual-stack support.
    Regarding whether ipBlock is needed at all: we need it for spoke cluster APIs (port 6443) and external HTTPS (port 443) since those destinations are outside the cluster with unpredictable IPs. A namespaceSelector/podSelector rule can't match external hosts.
  3. You're right, removed redundant rules.

@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

🤖 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 `@config/manager/image-based-install-operator-networkpolicy.yaml`:
- Around line 46-54: Restrict the TCP/6443 egress rule in the image-based
install operator NetworkPolicy by removing the unrestricted IPv6 ::/0 entry and
replacing it with the applicable Kubernetes and spoke API-server IPv6 CIDRs or
the approved egress path. If dynamic addresses require broad access, document
the security trade-off and add coverage proving the permitted destinations
remain constrained.
🪄 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: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ecde0169-7142-4ccd-8431-85041cf96e24

📥 Commits

Reviewing files that changed from the base of the PR and between a3cc0b7 and bfd7e38.

📒 Files selected for processing (2)
  • bundle/manifests/image-based-install-operator.clusterserviceversion.yaml
  • config/manager/image-based-install-operator-networkpolicy.yaml

Comment thread config/manager/image-based-install-operator-networkpolicy.yaml
@shay23bra

Copy link
Copy Markdown
Contributor Author

/retest

@shay23bra
shay23bra force-pushed the ACM-31164-network-policy branch from bfd7e38 to 165cff5 Compare July 23, 2026 11:28
Add per-component NetworkPolicy restricting ingress and egress traffic
for the image-based-install-operator pod, following the ACM 5.0 DDR
pattern.

Ingress restricted to known ports (8080 metrics, 9443 webhook, 8000
image server). Egress restricted to DNS, K8s API, spoke clusters, and
HTTPS. IPv4 and IPv6 supported.
@shay23bra
shay23bra force-pushed the ACM-31164-network-policy branch from 165cff5 to 1a23edb Compare July 23, 2026 11:29
@shay23bra

Copy link
Copy Markdown
Contributor Author

/retest

@shay23bra

Copy link
Copy Markdown
Contributor Author

/retest-required

@openshift-ci

openshift-ci Bot commented Jul 26, 2026

Copy link
Copy Markdown

@shay23bra: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-ibio-v4v6 1a23edb link true /test e2e-ibio-v4v6
ci/prow/ibio-reinstall-v4v6 1a23edb link false /test ibio-reinstall-v4v6

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

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.

3 participants