Skip to content

Add NetworkPolicy for the Keycloak namespace#135

Open
p-rog wants to merge 22 commits into
validatedpatterns:mainfrom
p-rog:network-policy
Open

Add NetworkPolicy for the Keycloak namespace#135
p-rog wants to merge 22 commits into
validatedpatterns:mainfrom
p-rog:network-policy

Conversation

@p-rog
Copy link
Copy Markdown
Collaborator

@p-rog p-rog commented May 20, 2026

Adds network isolation for the keycloak-system namespace using the default-deny + per-pod allow pattern (same approach as Vault in PR #18).

Depends on rhbk-chart PR #10 (merged) which adds the NetworkPolicy templates to the wrapper chart.

Changes:

  • Add overrides/values-keycloak-network-policy.yaml with per-pod rules for keycloak, postgresql-db, rhbk-operator, and realm import job
  • Enable via extraValueFiles in values-hub.yaml for the rh-keycloak application

Per-pod rules:

  • Keycloak egress: DNS, PostgreSQL (5432), JGroups clustering (7800/57800), Kubernetes API, SPIRE OIDC (443)
  • PostgreSQL: ingress from keycloak and realm import pods only (5432), egress DNS only
  • Operator: egress DNS, Kubernetes API, Keycloak management (9000), Keycloak HTTPS (8443)
  • Realm import job: egress DNS, PostgreSQL, Kubernetes API, Keycloak HTTPS

The operator-managed keycloak-network-policy (ingress for keycloak pods) is left untouched.

Tested on OCP 4.21 — Keycloak login, OIDC from ACS/qtodo, SPIFFE federated auth, JGroups clustering, operator reconciliation, and realm import job all verified working with policies applied.

Przemyslaw Roguski and others added 22 commits April 9, 2026 19:04
…ft.io/ingress: triggers OVN-K's special ACL handling for host-network traffic
…snwers on both an internal hostname (for back-channel) and an external hostname (for browser redirects)
@p-rog p-rog requested review from minmzzhang, mlorenzofr and sabre1041 and removed request for minmzzhang and sabre1041 May 20, 2026 15:38
Copy link
Copy Markdown
Collaborator

@mlorenzofr mlorenzofr left a comment

Choose a reason for hiding this comment

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

It works well

Quick question, now that I'm reviewing it: Do we want to add the keycloak app to the NetworkPolicy (pod keycloak-0 / label app=keycloak)?

@p-rog
Copy link
Copy Markdown
Collaborator Author

p-rog commented May 21, 2026

Quick question, now that I'm reviewing it: Do we want to add the keycloak app to the NetworkPolicy (pod keycloak-0 / label app=keycloak)?

The keycloak pod ingress is already handled by the operator-managed keycloak-network-policy. The RHBK operator creates and maintains it automatically (ports 8443, 7800/57800, 9000). I decided not to duplicate or override it since the operator would revert any changes. Our keycloak-egress-network-policy covers only the egress side which the operator doesn't manage.

@p-rog p-rog closed this May 21, 2026
@p-rog p-rog reopened this May 21, 2026
@p-rog p-rog requested review from minmzzhang and sabre1041 May 21, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants