Skip to content
Merged
Changes from 7 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
048ad85
ADR: Tailored NetworkPolicies for RHDH Install Methods
rm3l Jun 1, 2026
c6504fa
add minor changes
rm3l Jun 1, 2026
c1b7ff6
Clarify boundary between base and user-managed policies
rm3l Jun 1, 2026
52429fe
Replace em dashes with clear punctuation, fix broken link, add OCPSTR…
rm3l Jun 1, 2026
2e426f7
minor style update
rm3l Jun 1, 2026
2b9e946
Rename Implementation approach to Key design principles
rm3l Jun 1, 2026
9025e54
update
rm3l Jun 1, 2026
7c16b8d
Clarify effect on existing deployments when upgrading
rm3l Jun 1, 2026
8b001d4
clarify the effect on sidecar containers like Lighstpeed
rm3l Jun 1, 2026
734221b
Include known plugin registries in base egress, add policy templates …
rm3l Jun 1, 2026
194fb85
Clarify ingress and egress risks, add ingress-only alternative, menti…
rm3l Jun 1, 2026
99ce818
Add OCP 5+ NetworkPolicy requirement to problem statement
rm3l Jun 2, 2026
0a116f3
Add ANP/BANP as alternative considered, explain why standard NetworkP…
rm3l Jun 8, 2026
4fcaeba
Clarify that policies cover all RHDH-managed pods, not just the backend
rm3l Jun 8, 2026
e9e30ee
Acknowledge HTTPS egress trade-off, clarify per-component policy gran…
rm3l Jun 8, 2026
cc346d6
Remove disable toggle, base NetworkPolicies are always present
rm3l Jun 8, 2026
ecf4f86
Call out existing Orchestrator podSelector: {} as breaking change
rm3l Jun 8, 2026
21ac184
Add concrete upgrade mitigation strategies to negative consequence
rm3l Jun 8, 2026
ce56b70
Add positive consequences for OCP 5+ alignment, no CRD changes, and p…
rm3l Jun 8, 2026
e82f042
Merge branch 'main' into RHDHPLAN-1032--add-tailored-networkpolicies-…
rm3l Jun 18, 2026
836730b
Clarify ANP/BANP rejection for Helm and Operator paths separately
rm3l Jun 18, 2026
6152111
Add context about RHDH's plugin-driven unpredictable egress patterns
rm3l Jun 18, 2026
6c4bf37
Simplify disconnected environments section to focus on CIDR difference
rm3l Jun 18, 2026
210f513
fixup! Clarify ANP/BANP rejection for Helm and Operator paths separately
rm3l Jun 18, 2026
51d7834
Adopt three-part policy taxonomy and update ANP/BANP alternative
rm3l Jun 18, 2026
598cd57
Fix accuracy issues across the ADR
rm3l Jun 18, 2026
bc69c6c
Simplify context section and fix accuracy across the ADR
rm3l Jun 18, 2026
e8148e4
Merge remote-tracking branch 'upstream/main' into RHDHPLAN-1032--add-…
rm3l Jun 25, 2026
e12c94e
Specify label selectors for NetworkPolicy pod scoping
rm3l Jun 25, 2026
174a857
Update ANP/BANP alternative with OCP team clarification
rm3l Jul 2, 2026
5546a2a
Merge remote-tracking branch 'upstream/main' into RHDHPLAN-1032--add-…
rm3l Jul 2, 2026
f3491da
Restructure Context section and refine ADR wording
rm3l Jul 2, 2026
bbe713d
Add NetworkPolicy examples with pod label selectors
rm3l Jul 2, 2026
4ce76c8
Add metrics port 9464 ingress restriction per security recommendation
rm3l Jul 3, 2026
f7620bc
Merge remote-tracking branch 'upstream/main' into RHDHPLAN-1032--add-…
rm3l Jul 13, 2026
bbdf08a
Clarify examples as illustrative and add review process note
rm3l Jul 13, 2026
fcb3a0e
Merge remote-tracking branch 'upstream/main' into RHDHPLAN-1032--add-…
rm3l Jul 21, 2026
da22a17
Address team feedback on ADR structure and accuracy
rm3l Jul 21, 2026
636250e
Rename ADR 007 to 006 to match next available number
rm3l Jul 21, 2026
e786a8a
Replace OOTB acronym with full term
rm3l Jul 21, 2026
5087562
Merge branch 'main' into RHDHPLAN-1032--add-tailored-networkpolicies-…
rm3l Aug 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions decisions/007-network-policies-for-rhdh-install-methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# ADR: Tailored NetworkPolicies for RHDH Install Methods

## Context

**Problem**: RHDH deployments currently lack NetworkPolicies, leaving pod-to-pod communication unrestricted and exposing the deployment to unintended data leaks or lateral movement attacks.

The absence of NetworkPolicies in RHDH was identified as a risk in the OCP Threat Model ([OCPSTRAT-819](https://redhat.atlassian.net/browse/OCPSTRAT-819)). Today, the only NetworkPolicies shipped by RHDH are specific to the Orchestrator flavor; the base RHDH deployment (both Operator-managed operands and Helm chart) has no network traffic restrictions at all. This means:

- Any pod in the namespace (or cluster, depending on the network plugin) can reach RHDH pods and its dependencies (PostgreSQL, etc.) without restriction
- RHDH pods can make unrestricted egress connections, increasing the blast radius if compromised
- There is no defense-in-depth at the network layer for the most common deployment scenarios

Additionally, RHDH is supported across multiple Kubernetes platforms (OCP, EKS, AKS, GKE), each with different levels of default NetworkPolicy enforcement. OCP enforces NetworkPolicies out of the box, but other platforms may require users to configure a compatible CNI plugin.

Comment thread
rm3l marked this conversation as resolved.
Outdated
### Disconnected/airgapped environments

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How Airgap impacts on needs in defining NetworkPolicy?
To me it looks like another network (CIDR), local instead of external? Did I miss something?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right that from a NetworkPolicy perspective, airgap mostly means different CIDRs (internal mirrors instead of public endpoints). I actually wanted to highlight why default egress policies can't hardcode specific destinations, since in disconnected environments every endpoint (registries, SCM, auth, ...) would point to a different internal address. The policies themselves don't change structurally; it's the user-added allow rules that might differ. Let me clarify this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do not think we can hardcode specific destinations in non-airgap as well, CIDRs in cloud services tend to change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

well, I mean a user can point to static public IP address ranges if they want (even in connected use cases), but would have to supply their own policies to allow that. Anyway, that's exactly the point about Alternative 2 (CIDR-based egress restrictions), applicable to both connected and disconnected use cases.

In these environments, RHDH cannot reach public endpoints and instead relies on internal infrastructure. The egress traffic flows affected include:

- **OCI plugin installation**: RHDH may need to dynamically fetch plugins from container registries or NPM registries. In disconnected environments, this traffic targets an internal mirror registry rather than the public registry, and policies must allow egress to that mirror
- **Source control access**: Plugins like the Catalog backend fetch repository content (e.g., `catalog-info.yaml` files) from SCM providers. In disconnected environments, this is a local GitLab/Gitea/etc. instance rather than a public provider like GitHub.
- **Authentication providers**: OIDC/OAuth flows require egress to the identity provider. In disconnected environments, this is typically an internal Keycloak or RHSSO instance
- **Proxy endpoints**: The RHDH proxy may need to forward requests to arbitrary backend services configured by the user, many of which may be internal-only in disconnected setups
- **Custom scaffolder actions**: Software Templates may call internal CI/CD systems, artifact registries, or other internal APIs

Note that container image pulls (for the RHDH pod images themselves) happen at the container runtime level and are **not** affected by NetworkPolicies, which are only about pod-to-pod networking.

Since the specific internal endpoints vary per deployment, default egress policies cannot enumerate them. The policies must therefore either be broadly permissive on common ports (443, 8443, etc.) or provide a clear configuration surface for users to add their site-specific endpoints.

### Advanced deployment scenarios

These introduce additional traffic flows that policies must account for:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All of the plugins are "blackboxes" for installation, I think?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

WDYM by "blackboxes for installation"? During the install-dynamic-plugins init container execution?
This section is more about runtime traffic flows (pod-to-pod communication, egress to external endpoints), not plugin installation. Lightspeed, Orchestrator, and external database configurations each introduce distinct network traffic patterns that the base policies may need to take into account. Plugin installation (OCI/NPM fetching) is covered separately under the egress policies.

- **Lightspeed (enabled by default since RHDH 1.10)**: Lightspeed adds a sidecar container to the RHDH pod that needs egress to LLM inference endpoints. Since it is enabled by default, the base egress policies must accommodate this traffic.
Comment thread
rm3l marked this conversation as resolved.
Outdated
- **Orchestrator (opt-in)**: The Orchestrator flavor introduces cross-namespace traffic flows with OpenShift Serverless and Serverless Logic operators, and its SonataFlow components (Data Index, Job Service) connect back to RHDH's PostgreSQL. Users may also bring their own external SonataFlowPlatform, requiring egress to endpoints in a different namespace or outside the cluster.
- **External database**: RHDH supports connecting to an external PostgreSQL instance that may live outside of the cluster. Egress policies scoped to in-namespace pods would block this connection.

### Key constraints
- NetworkPolicies must not break existing RHDH functionality on any supported platform
- Deployment must not fail on clusters without NetworkPolicy-capable CNI plugins. But Kubernetes already handles this gracefully as policies will be created but not enforced
- The RHDH Operator itself is installed via OLM, and OLM NetworkPolicy support is still being backported (tracked separately in [RHDHPLAN-351](https://redhat.atlassian.net/browse/RHDHPLAN-351)). This ADR covers only the operands managed by the operator and the Helm chart resources
- Policies must be flexible enough for disconnected environments. Users must be able to allowlist their internal endpoints without modifying the default policies directly

## Decision

Add tailored NetworkPolicies to all RHDH install methods (both the operands managed by the RHDH Operator and the resources deployed by the Helm chart) to enforce least-privilege pod communication by default.

**Key design principles**:

- **Default deny with selective allow**: Apply a default-deny policy scoped to RHDH-labeled pods (not namespace-wide, since RHDH is a layered product that may share namespaces), then add specific allow rules for known traffic flows
Comment thread
rm3l marked this conversation as resolved.
Outdated
- **Ingress policies**: Allow inbound traffic only from expected sources:
- OpenShift Router / Ingress controller to the RHDH backend (for user access via Routes/Ingresses)
- Monitoring/metrics scrapers to the metrics endpoints
- Inter-pod communication between RHDH components (e.g., backend to PostgreSQL)
- **Egress policies**: Allow outbound traffic for:
- DNS resolution (cluster DNS service)
- Kubernetes API server access (for service discovery, CR watches, etc.)
- PostgreSQL, either in-namespace (podSelector-based) or external (user-configurable CIDR/port rule when the database lives outside the cluster)
- AI model endpoints for Lightspeed, either cluster-internal model servers or external LLM APIs
- Cross-namespace traffic to OpenShift Serverless and Serverless Logic namespaces when the Orchestrator flavor is enabled
Comment thread
rm3l marked this conversation as resolved.
Outdated
- Any additional egress (SCM providers, CI/CD systems, container registries, etc.) is left to the user to allow via their own additive NetworkPolicy resources, since these destinations are deployment-specific
- **Clear boundary between base and user-managed policies**: The base policies shipped by the Operator and Helm chart cover only the core traffic flows that are common to all RHDH deployments (DNS, API server, PostgreSQL, Lightspeed model endpoints, Orchestrator cross-namespace traffic). All deployment-specific egress (SCM providers, CI/CD systems, container registries, auth providers, internal mirrors, external SonataFlowPlatform endpoints, etc.) is the user's responsibility to allow.
- **User-extensible via additive policies**: This split is possible because Kubernetes NetworkPolicies are **additive**: once a default-deny policy selects a pod, any additional NetworkPolicy matching that pod can only add more allow rules, never remove existing ones. Users who need to allow additional site-specific traffic simply create their own NetworkPolicy resources in the same namespace. These compose naturally with the base policies without any CRD or Helm values change. The only configuration surface needed in the Operator CR and Helm values is a boolean to disable the base NetworkPolicies entirely (for clusters without enforcement or for debugging)
Comment thread
rm3l marked this conversation as resolved.
Outdated
- **Documentation**: Clear documentation is essential to make this approach work in practice. Users need to understand which base policies are shipped, what traffic they allow and deny, how to create additional NetworkPolicies for their site-specific needs, and how to troubleshoot connectivity issues caused by policies. Documentation should also clarify the requirement for a NetworkPolicy-capable CNI plugin on non-OCP platforms and provide guidance for common scenarios (disconnected environments, external databases, custom plugins reaching additional endpoints)
- **Label-scoped policies**: Since RHDH is a layered product deployed into potentially shared namespaces, policies use `podSelector` with RHDH-specific labels rather than namespace-wide selectors, following the OCP best practice for layered products

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To make it implementation ready, need to mention what exactly labels we're going to use.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's an implementation detail, no? Each install method (Operator, Helm chart) already applies its own labels to the pods it manages. The ADR's design principle is that policies must use RHDH-specific label selectors (not namespace-wide podSelector: {}). The exact label keys and values will be determined during implementation and may differ between install methods.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe the values are stable (even if not the same for Chart and Operator) and have to be specified and known outside of implementation so to me it is definitely a part of decision.

- **Operator vs. OLM boundary**: The RHDH Operator manages NetworkPolicies for its operands (RHDH pods, PostgreSQL, etc.) directly. NetworkPolicies for the operator pod itself are out of scope here and will be handled via OLM once support is fully backported ([RHDHPLAN-351](https://redhat.atlassian.net/browse/RHDHPLAN-351))

## Alternatives considered

### Alternative 1: Namespace-wide default deny
- **Approach**: Apply a blanket default-deny policy with `podSelector: {}` covering all pods in the namespace
- **Rejected because**: RHDH is a layered product that may be deployed into shared namespaces (including `openshift-operators`). A namespace-wide deny would break other workloads not managed by RHDH. The OCP NetworkPolicy best practices explicitly recommend label-scoped policies for layered products.

### Alternative 2: Egress restrictions by specific destination CIDRs
- **Approach**: Lock down egress to only known CIDRs for external services (e.g., GitHub IP ranges, specific registry IPs)
- **Rejected because**: RHDH integrates with a wide variety of user-configured external services (SCMs, CI/CD, auth providers, plugin registries, internal mirrors). NetworkPolicies cannot use DNS names, only CIDRs. Maintaining an accurate CIDR list is impractical and would break frequently. Port-based egress rules combined with user-configurable overrides provide a better balance of security and usability.

### Alternative 3: Expose custom NetworkPolicy rules in the Operator CR
- **Approach**: Add fields like `spec.networkPolicies.additionalEgressRules[]` and `spec.networkPolicies.additionalIngressRules[]` to the Backstage CR schema, allowing users to declare custom allow rules through the Operator's configuration surface
- **Rejected because**: The Backstage CR currently has no such fields, and since NetworkPolicies are additive, users can achieve the same result by creating their own NetworkPolicy resources directly in the namespace. No CRD schema change is needed. Adding these fields would increase the API surface and maintenance burden of the Operator for no functional benefit over user-managed policies. Note: the upstream Backstage Helm chart already provides a [`networkPolicy`](https://github.com/redhat-developer/rhdh-chart/blob/release-1.10/charts/backstage/vendor/backstage/charts/backstage/values.yaml#L392-L428) section in `values.yaml` with `ingressRules.customRules[]`, `egressRules.customRules[]`, and a `denyConnectionsToExternal` toggle. This existing Helm mechanism is sufficient for Helm-based deployments and does not need to be replicated in the Operator CR.

### Alternative 4: Rely solely on documentation and leave NetworkPolicies to the user
- **Approach**: Document recommended NetworkPolicies without shipping them
- **Rejected because**: This puts the burden on every deployer to understand RHDH traffic patterns and write correct policies. Most users would not implement them, leaving deployments unprotected. Shipping sensible defaults with the ability to customize is a better security posture.

## Consequences

### Positive
- ✅ Enforces least-privilege network access by default, reducing the attack surface for RHDH deployments
- ✅ Addresses the risk identified in the OCP Threat Model ([OCPSTRAT-819](https://redhat.atlassian.net/browse/OCPSTRAT-819))
- ✅ Works transparently on OCP, which enforces NetworkPolicies out of the box. No user action required
- ✅ Does not break deployments on clusters without NetworkPolicy enforcement (policies are created but simply not enforced by Kubernetes)
- ✅ Configurable. Users can extend, customize, or disable policies to fit their environment (airgapped, proxied, etc.)

### Negative
- ❌ Users must create their own additional NetworkPolicies for site-specific egress (SCMs, CI/CD, registries, auth providers, etc.). The base policies do not cover these, which requires awareness and documentation
- ❌ Users on non-OCP platforms must ensure their CNI plugin supports NetworkPolicy enforcement. Otherwise, policies exist but provide no actual protection, which requires clear documentation to avoid a false sense of security
- ❌ Adds complexity to the Operator and Helm chart codebases. Policies must be kept in sync with any changes to RHDH pod labels, ports, or component architecture, and must account for optional features (Lightspeed sidecars, Orchestrator cross-namespace flows, external databases)
- ❌ Requires testing across all supported platforms (OCP, EKS, AKS, GKE) and across deployment variants (with/without Lightspeed, Orchestrator, external database) to validate that policies do not inadvertently block legitimate traffic

### Neutral
- ⚖️ Existing deployments without NetworkPolicies continue to work. Adding policies is additive and does not change behavior on clusters without enforcement
Comment thread
rm3l marked this conversation as resolved.
Outdated
- ⚖️ The Orchestrator-specific NetworkPolicies already in place will need to be reconciled with the new base policies to avoid duplication or conflicts
- ⚖️ OLM-managed NetworkPolicies for the operator pod itself remain out of scope until OLM support is backported ([RHDHPLAN-351](https://redhat.atlassian.net/browse/RHDHPLAN-351))
- ⚖️ The RHDH must-gather should be updated to collect NetworkPolicies in place, so as to help troubleshoot potential connectivity failures caused by overly restrictive or misconfigured policies

## References

- [Kubernetes NetworkPolicy documentation](https://kubernetes.io/docs/concepts/services-networking/network-policies/)
- [OpenShift NetworkPolicy documentation](https://docs.openshift.com/container-platform/4.18/networking/network_security/network_policy/about-network-policy.html)
- [Best Practices for developing Network Policies](https://docs.google.com/document/d/1CDoGSRd-h8VT4PMrK_83Ro0YzYPjORbkxtfTJU1sN6Q/edit?tab=t.0)
- [OCPSTRAT-819: Protect from unintended data leaks / attacks via tailored Network Policies](https://redhat.atlassian.net/browse/OCPSTRAT-819)
- [RHDHPLAN-1032: Add tailored NetworkPolicies to the Install Methods](https://redhat.atlassian.net/browse/RHDHPLAN-1032)
- [RHDHPLAN-351: NetworkPolicies for the RHDH Operator itself (OLM-managed)](https://redhat.atlassian.net/browse/RHDHPLAN-351)