Skip to content

Conversation

@liouk
Copy link
Member

@liouk liouk commented Jan 23, 2026

This PR adds network policies to the authentication operator, oauth-server and oauth-apiserver. For each component, there are two policies:

  • one to allow all Ingress/Egress known traffic for each component
  • one to deny all other Ingress/Egress traffic for each component

All known and required connections must be reflected to respective allow rules.

Note that, in case of pods that require traffic to/from hostNetwork pods (such as the kube-apiserver), we need to allow all ingress/egress TCP traffic; NetworkPolicies do not affect pods on hostNetwork, but we still need a rule to allow ingress/egress from/to them.

In some cases there might be some overlap in the policy rules, but this is intentional for the sake of documentation/future reference.

@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 Jan 23, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jan 23, 2026
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Jan 23, 2026

@liouk: This pull request references CNTRLPLANE-2610 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 epic to target the "4.22.0" version, but no target version was set.

Details

In response to this:

This PR adds network policies to the authentication operator, oauth-server and oauth-apiserver. For each component, there are two policies:

  • one to allow all Ingress/Egress known traffic for each component
  • one to deny all other Ingress/Egress traffic for each component

All known and required connections must be reflected to respective allow rules.

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
Copy link

coderabbitai bot commented Jan 23, 2026

Walkthrough

This pull request introduces Kubernetes NetworkPolicy resources for OpenShift authentication components across multiple namespaces. It adds default-deny-all policies and component-specific traffic rules for oauth-apiserver, oauth-openshift, and authentication-operator, along with code registration and corresponding test output files.

Changes

Cohort / File(s) Summary
NetworkPolicy Manifests (Bindata)
bindata/oauth-apiserver/networkpolicy_*, bindata/oauth-openshift/networkpolicy_*
Added four NetworkPolicy YAML files: two default-deny-all policies for openshift-oauth-apiserver and openshift-authentication namespaces; two component-specific policies (oauth-apiserver-networkpolicy and oauth-server-networkpolicy) with defined Ingress/Egress rules.
NetworkPolicy Manifests (Manifests Directory)
manifests/0000_10_networkpolicy_*.yaml
Added two new manifest files: authentication-operator-networkpolicy and default-deny-all policy for openshift-authentication-operator namespace with corresponding Ingress/Egress rules.
Operator Code Registration
pkg/cmd/mom/output_resources_command.go, pkg/operator/starter.go
Added entries to ExactResources list and expanded static resource provisioning to register four new NetworkPolicy resources (oauth-apiserver, oauth-server, and two default-deny-all policies).
Test Data - NetworkPolicy Resources
test-data/apply-configuration/overall/*/networkpolicies/*.yaml
Added metadata and body YAML files for NetworkPolicy resources across openshift-authentication and openshift-oauth-apiserver namespaces, mirroring bindata manifest structure.
Test Data - Event Records
test-data/apply-configuration/overall/*/events/*-body-authentication-operator.*.yaml, test-data/apply-configuration/overall/*/events/*-metadata-authentication-operator.*.yaml
Added and removed event manifests documenting NetworkPolicy creation events and configuration observations; includes deletions of obsolete oauthAPIServer/oauthServer config observation events and metadata name field updates.
Test Data - Certificate Signing Request
test-data/apply-configuration/overall/minimal-cluster/*/certificatesigningrequests/d52a-body-system-COLON-openshift-COLON-openshift-authenticator-.yaml
Updated CSR request payload (base64 string change); no signature or field structure changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
test-data/apply-configuration/overall/minimal-cluster/expected-output/Management/Create/namespaces/openshift-oauth-apiserver/networking.k8s.io/networkpolicies/bd95-body-oauth-apiserver-networkpolicy.yaml (1)

31-57: Duplicate ingress rule appears unnecessary.

The ingress rule at lines 55-57 is identical to the rule at lines 31-34 (both allow port 8443 TCP from any source without a from selector). While the PR notes intentional overlap for documentation, this particular duplication doesn't add documentation value since they're identical rules.

Consider removing the duplicate:

♻️ Suggested change
   - from:
     - namespaceSelector:
         matchLabels:
           kubernetes.io/metadata.name: openshift-authentication-operator
       podSelector:
         matchLabels:
           app: authentication-operator
     ports:
     - port: 8443
       protocol: TCP
-  - ports:
-    - port: 8443
-      protocol: TCP
   podSelector:

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

@openshift-ci openshift-ci bot requested a review from ibihim January 23, 2026 10:41
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 23, 2026
@liouk
Copy link
Member Author

liouk commented Jan 23, 2026

/jira refresh

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Jan 23, 2026

@liouk: This pull request references CNTRLPLANE-2610 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.

@liouk liouk force-pushed the network-policies branch 3 times, most recently from 9711c7b to d058feb Compare January 23, 2026 16:21
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Jan 28, 2026

@liouk: This pull request references CNTRLPLANE-2610 which is a valid jira issue.

Details

In response to this:

This PR adds network policies to the authentication operator, oauth-server and oauth-apiserver. For each component, there are two policies:

  • one to allow all Ingress/Egress known traffic for each component
  • one to deny all other Ingress/Egress traffic for each component

All known and required connections must be reflected to respective allow rules.

Note that, in case of pods that require traffic to/from hostNetwork pods (such as the kube-apiserver), we need to allow all ingress/egress TCP traffic; NetworkPolicies do not affect pods on hostNetwork, but we still need a rule to allow ingress/egress from/to them

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.

@liouk liouk changed the title WIP: CNTRLPLANE-2610: Create network policies for AUTH components CNTRLPLANE-2610: Create network policies for AUTH components Jan 28, 2026
@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 Jan 28, 2026
@liouk
Copy link
Member Author

liouk commented Jan 28, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Jan 29, 2026

@liouk: This pull request references CNTRLPLANE-2610 which is a valid jira issue.

Details

In response to this:

This PR adds network policies to the authentication operator, oauth-server and oauth-apiserver. For each component, there are two policies:

  • one to allow all Ingress/Egress known traffic for each component
  • one to deny all other Ingress/Egress traffic for each component

All known and required connections must be reflected to respective allow rules.

Note that, in case of pods that require traffic to/from hostNetwork pods (such as the kube-apiserver), we need to allow all ingress/egress TCP traffic; NetworkPolicies do not affect pods on hostNetwork, but we still need a rule to allow ingress/egress from/to them.

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.

@liouk
Copy link
Member Author

liouk commented Jan 29, 2026

@coderabbitai help

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@kaleemsiddiqu
Copy link

/retest

@liouk
Copy link
Member Author

liouk commented Jan 29, 2026

I'd like a review from a member of each of the auth and network policy feature teams -- holding until we get both.

Holding PR until we get:

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 29, 2026
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Jan 29, 2026

@liouk: This pull request references CNTRLPLANE-2610 which is a valid jira issue.

Details

In response to this:

This PR adds network policies to the authentication operator, oauth-server and oauth-apiserver. For each component, there are two policies:

  • one to allow all Ingress/Egress known traffic for each component
  • one to deny all other Ingress/Egress traffic for each component

All known and required connections must be reflected to respective allow rules.

Note that, in case of pods that require traffic to/from hostNetwork pods (such as the kube-apiserver), we need to allow all ingress/egress TCP traffic; NetworkPolicies do not affect pods on hostNetwork, but we still need a rule to allow ingress/egress from/to them.

In some cases there might be some overlap in the policy rules, but this is intentional for the sake of documentation/future reference.

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.

Comment on lines 45 to 46
libraryoutputresources.ExactResource("networking.k8s.io", "v1", "networkpolicies", "openshift-authentication-operator", "authentication-operator-networkpolicy"),
libraryoutputresources.ExactResource("networking.k8s.io", "v1", "networkpolicies", "openshift-authentication-operator", "default-deny-all"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Does MOM need to also know the manifests for deploying the cluster-authentication-operator itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually good point, I don't believe OM needs these operator manifests.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@bindata/oauth-openshift/networkpolicy_oauth-server.yaml`:
- Around line 44-68: The NetworkPolicy in networkpolicy_oauth-server.yaml
currently uses a wide namespaceSelector: {} allowing ingress to port 6443 from
any namespace and an egress rule with only ports: - protocol: TCP (no `to`)
permitting all TCP egress; tighten or document this: replace namespaceSelector:
{} with a scoped namespaceSelector/podSelector or ipBlock that targets known
oauth-proxy/sidecar namespaces or pods (reference the ingress block targeting
port 6443), and restrict the egress rule (the egress entry listing ports with
protocol: TCP) by adding specific `to:` destinations (podSelector,
namespaceSelector or ipBlock) for kube-apiserver and configured IDPs;
alternatively, if the broad scope is intentional, add an explicit comment in the
manifest near the ingress (port 6443) and the TCP-only egress rule explaining
the rationale and approved clients/endpoints.
🧹 Nitpick comments (1)
bindata/oauth-apiserver/networkpolicy_oauth-apiserver.yaml (1)

77-80: Egress rule allows all TCP ports to any destination.

This rule permits unrestricted TCP egress, which is quite permissive. The comment indicates this is for kube-apiserver communication, but kube-apiserver typically runs on port 6443. Consider whether this could be tightened to specific ports (e.g., 6443 for API server) to reduce attack surface, or document why unrestricted TCP is required.

Copy link
Contributor

@everettraven everettraven left a comment

Choose a reason for hiding this comment

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

This LGTM in general.

We should probably run payload jobs for a sanity check that this won't cause component readiness issues and payload build failures.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 3, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 3, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: everettraven, liouk

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

@liouk
Copy link
Member Author

liouk commented Feb 3, 2026

We should probably run payload jobs for a sanity check that this won't cause component readiness issues and payload build failures.

Indeed -- I intend to get this reviewed and tested by QE first before running a payload job, to avoid having to repeat it unnecessarily.

@dusk125
Copy link

dusk125 commented Feb 3, 2026

lgtm as well!

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 6, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 6, 2026

New changes are detected. LGTM label has been removed.

@liouk
Copy link
Member Author

liouk commented Feb 6, 2026

Pushed changes to better align with the "Egress to the APIServer" guidance.

annotations:
include.release.openshift.io/self-managed-high-availability: "true"
include.release.openshift.io/single-node-developer: "true"
include.release.openshift.io/ibm-cloud-managed: "true"
Copy link

@dusk125 dusk125 Feb 6, 2026

Choose a reason for hiding this comment

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

Cesar warned against having these applied in hypershift since they already do their own network policies in the hosted control planes. I would suggest removing this include.release.openshift.io/ibm-cloud-managed: "true".

annotations:
include.release.openshift.io/self-managed-high-availability: "true"
include.release.openshift.io/single-node-developer: "true"
include.release.openshift.io/ibm-cloud-managed: "true"
Copy link

Choose a reason for hiding this comment

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

@liouk liouk force-pushed the network-policies branch 2 times, most recently from 37dd6ce to af9a504 Compare February 12, 2026 10:51
@liouk
Copy link
Member Author

liouk commented Feb 12, 2026

Pushed fixes as per comments from @dusk125 and also more alignment with guidance (allow all ingress to metrics, not just prometheus pods).

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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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.

5 participants