ACM-31165: Test and validate network policies for Infrastructure Operator components - #10670
ACM-31165: Test and validate network policies for Infrastructure Operator components#10670shay23bra wants to merge 1 commit into
Conversation
|
Skipping CI for Draft Pull Request. |
|
@shay23bra: This pull request references ACM-31165 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. 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: shay23bra 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 |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe change adds restricted network policies for infrastructure-operator, assisted-service, and image-service pods. The controller gains RBAC permissions, reconciliation wiring, policy constructors, and a diagnostic reason constant. Manager and OLM manifests package the infrastructure-operator policy. ChangesNetwork policy controls
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant AgentServiceConfigController
participant KubernetesAPI
participant AssistedServicePods
participant ImageServicePods
AgentServiceConfigController->>KubernetesAPI: Reconcile assisted-service NetworkPolicy
KubernetesAPI->>AssistedServicePods: Enforce assisted-service ingress and egress
AgentServiceConfigController->>KubernetesAPI: Reconcile image-service NetworkPolicy when enabled
KubernetesAPI->>ImageServicePods: Enforce image-service ingress and egress
🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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/assisted-service-networkpolicy.yaml`:
- Around line 80-87: Update the PostgreSQL egress rule in the NetworkPolicy to
support the documented external database configuration by adding a narrowly
scoped namespaceSelector or ipBlock for the permitted external PostgreSQL
destination, while preserving the existing assisted-service pod access on port
5432.
In `@config/manager/infrastructure-operator-networkpolicy.yaml`:
- Around line 26-29: Constrain the ingress peers for the listed NetworkPolicy
ports by adding explicit from rules: in
config/manager/infrastructure-operator-networkpolicy.yaml lines 26-29, allow
9443 only from kube-apiserver; in
config/manager/assisted-service-networkpolicy.yaml lines 36-43, restrict 8090,
8091, and 9443 to the intended agent, controller, and webhook peers; and in
config/manager/assisted-image-service-networkpolicy.yaml lines 28-33, restrict
8080 and 8081 to the intended node or ingress 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: 0be4370e-801e-44be-a610-9e65c2d9f3dc
📒 Files selected for processing (4)
config/manager/assisted-image-service-networkpolicy.yamlconfig/manager/assisted-service-networkpolicy.yamlconfig/manager/infrastructure-operator-networkpolicy.yamlconfig/manager/kustomization.yaml
carbonin
left a comment
There was a problem hiding this comment.
Wouldn't it make more sense to deploy these network policy objects when we deploy the workloads from the infrastructure operator code?
c0f86bd to
5d5adce
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10670 +/- ##
==========================================
+ Coverage 44.61% 45.45% +0.83%
==========================================
Files 423 425 +2
Lines 73421 75166 +1745
==========================================
+ Hits 32755 34164 +1409
- Misses 37725 38059 +334
- Partials 2941 2943 +2
🚀 New features to boost your workflow:
|
5d5adce to
9e399e2
Compare
There was a problem hiding this comment.
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 `@internal/controller/controllers/agentserviceconfig_controller.go`:
- Around line 858-890: Update networkPolicyDefaultEgress in
internal/controller/controllers/agentserviceconfig_controller.go to exclude
fd00:ec2::254/128 from the IPv6 443 IPBlock alongside the existing IPv4 IMDS
exclusion; apply the same IPv6 Except entry in
deploy/olm-catalog/manifests/infrastructure-operator-networkpolicy.yaml lines
51-60. Also update config/manager/infrastructure-operator-networkpolicy.yaml
with the same exclusion so every generated and manifest-defined 443 egress rule
blocks both IMDS addresses.
🪄 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: 1aeb7d1e-9e48-4df8-b9c9-5f09acd379cc
📒 Files selected for processing (5)
api/v1beta1/agentserviceconfig_types.goconfig/manager/infrastructure-operator-networkpolicy.yamlconfig/manager/kustomization.yamldeploy/olm-catalog/manifests/infrastructure-operator-networkpolicy.yamlinternal/controller/controllers/agentserviceconfig_controller.go
🚧 Files skipped from review as they are similar to previous changes (1)
- config/manager/infrastructure-operator-networkpolicy.yaml
9e399e2 to
b2725b0
Compare
b2725b0 to
798241d
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 `@deploy/olm-catalog/manifests/infrastructure-operator-networkpolicy.yaml`:
- Around line 50-60: Update the HTTPS egress ipBlock rules in the infrastructure
network policy and its regenerated bundle to exclude the IPv6 metadata endpoints
fd00:ec2::254/128 and fd20:ce::254/128 from the ::/0 block, while preserving the
existing IPv4 metadata exclusion and registry HTTPS access.
- Around line 14-17: Remove the all-port same-namespace ingress rule under the
NetworkPolicy’s ingress configuration, or replace it with explicit source and
port allow-list entries limited to the required ports. Regenerate the OLM bundle
so the generated manifest reflects the restricted policy.
- Around line 41-60: The network policy’s Kubernetes API egress rule only
permits pods labeled component: apiserver and does not cover external spoke
APIs. Update the infrastructure operator network policy to allow supported
HyperShift API service endpoints on TCP/6443 and add the approved spoke-cluster
CIDR rules, or place equivalent exceptions in the reconciled policies that own
those endpoints.
- Around line 26-29: Update the webhook ingress rule in the NetworkPolicy to
restrict TCP port 9443 sources using the OpenShift
policy-group.network.openshift.io/host-network namespace selector. Preserve the
existing kube-apiserver webhook port rule while adding the selector under its
from configuration, rather than allowing ingress from all 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: 89fe1072-2d4a-49c2-ab18-cba34f5064ab
📒 Files selected for processing (5)
api/v1beta1/agentserviceconfig_types.goconfig/manager/infrastructure-operator-networkpolicy.yamlconfig/manager/kustomization.yamldeploy/olm-catalog/manifests/infrastructure-operator-networkpolicy.yamlinternal/controller/controllers/agentserviceconfig_controller.go
🚧 Files skipped from review as they are similar to previous changes (4)
- config/manager/infrastructure-operator-networkpolicy.yaml
- config/manager/kustomization.yaml
- api/v1beta1/agentserviceconfig_types.go
- internal/controller/controllers/agentserviceconfig_controller.go
798241d to
ea607aa
Compare
|
/retest |
|
@shay23bra The operator also deploys the webhook as a seperate deployment, so we need a network policy for it as well |
Create NetworkPolicies for assisted-service and assisted-image-service dynamically via AgentServiceConfig reconciliation, consistent with how the operator manages other resources. The infrastructure-operator's own NetworkPolicy is static YAML in config/manager/ and deploy/olm-catalog/manifests/. Ingress restricted to known ports, egress to DNS, K8s API, spoke clusters, and HTTPS. IPv4 and IPv6 supported.
ea607aa to
b28cecc
Compare
|
/lgtm |
|
/override ci/prow/edge-e2e-ai-operator-disconnected-capi |
|
@gamli75: Overrode contexts on behalf of gamli75: ci/prow/edge-e2e-ai-operator-disconnected-capi 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 kubernetes-sigs/prow repository. |
|
/override ci/prow/edge-e2e-ai-operator-ztp |
|
@shay23bra: Overrode contexts on behalf of shay23bra: ci/prow/edge-e2e-ai-operator-ztp 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 kubernetes-sigs/prow repository. |
|
/override ci/prow/edge-e2e-ai-operator-ztp-capi |
|
@shay23bra: Overrode contexts on behalf of shay23bra: ci/prow/edge-e2e-ai-operator-ztp-capi 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 kubernetes-sigs/prow repository. |
|
/retest |
|
/retest |
|
/override ci/prow/edge-e2e-ai-operator-disconnected-capi |
|
/override ci/prow/edge-e2e-ai-operator-ztp |
|
/override ci/prow/edge-e2e-ai-operator-ztp-capi |
|
@shay23bra: Overrode contexts on behalf of shay23bra: ci/prow/edge-e2e-ai-operator-disconnected-capi 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 kubernetes-sigs/prow repository. |
|
@shay23bra: Overrode contexts on behalf of shay23bra: ci/prow/edge-e2e-ai-operator-ztp 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 kubernetes-sigs/prow repository. |
|
@shay23bra: Overrode contexts on behalf of shay23bra: ci/prow/edge-e2e-ai-operator-ztp-capi 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 kubernetes-sigs/prow repository. |
|
/retest ci/prow/edge-subsystem-aws |
|
/override ci/prow/edge-e2e-ai-operator-ztp-capi |
|
@shay23bra: Overrode contexts on behalf of shay23bra: ci/prow/edge-e2e-ai-operator-disconnected-capi, ci/prow/edge-e2e-ai-operator-ztp, ci/prow/edge-e2e-ai-operator-ztp-capi 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 kubernetes-sigs/prow repository. |
|
/test ci/prow/edge-subsystem-aws |
|
/test edge-subsystem-aws |
|
@shay23bra: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
Summary
Adds NetworkPolicies for Infrastructure Operator components:
config/manager/, since it's deployed by the backplane-operatorIngress restricted to known ports, egress to DNS, K8s API, spoke clusters (6443), and HTTPS (443). IPv4 and IPv6 supported.
Test results (kind + Calico)
Related
Summary by CodeRabbit