Skip to content

OIDC access fails for sub-tenant clusters due to missing Cilium egress rule #3486

Open

Description

@overhovnik

Bug: OIDC access fails for sub-tenant clusters due to missing Cilium egress rule

OIDC authentication does not work for sub-tenant clusters because the generated CiliumClusterwideNetworkPolicy does not include the required egress rule to the root tenant ingress.

Environment

  • Cozystack version: v1.6
  • Provider OnPrem
  • CNI: Cilium
  • Authentication provider: Keycloak via ingress-nginx in tenant-root

Description

OIDC works correctly for regular tenants, but fails for sub-tenant clusters.

The failing traffic is blocked by Cilium:

Policy verdict log:
local EP ID 3825, remote ID 34520,
egress, action deny, match none

10.0.9.72:42279 -> 10.0.0.179:443 TCP SYN

The destination identity is the central ingress-nginx service:

k8s:io.kubernetes.pod.namespace=tenant-root
k8s:cozystack.io/service=ingress
k8s:app.kubernetes.io/name=ingress-nginx

The generated egress policy for a sub-tenant does not contain an allow rule for this endpoint.

Example:

Working tenant:

- toEndpoints:
  - matchLabels:
      cozystack.io/service: ingress
      k8s:io.kubernetes.pod.namespace: tenant-root

Sub-tenant:

- toEndpoints:
  - matchLabels:
      cozystack.io/service: ingress
      k8s:io.kubernetes.pod.namespace: tenant-kube3

As a result, traffic to the root ingress is denied by Cilium.

Root cause

The tenant egress policy template derives parent tenants from the namespace name:

$parts := splitList "-" .Release.Namespace

This does not match the actual Cozystack tenant hierarchy.

Example:

tenant-root
└── tenant-kube3
    └── tenant-kube3-tenant3

The parent relationship is stored in the Tenant CR, not encoded completely in the namespace name.

For tenant-kube3-tenant3, the template generates rules for:

tenant-kube3
tenant-kube3-tenant3

but misses:

tenant-root

even though tenant-root provides the inherited ingress service.

Expected behavior

Sub-tenant clusters should receive the same inherited ingress egress permissions as regular tenants, including access to the root tenant ingress when it is used for shared services such as Keycloak/OIDC.

Suggested fix

Generate the egress rules based on the actual Tenant parent relationship instead of deriving parents from the namespace string. The generated policy should include inherited service namespaces up to tenant-root.

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug
    triage/needs-triageIndicates an issue needs triage by a maintainer
    on Jul 29, 2026
  2. dosubot commented on Jul 29, 2026

    @dosubot

    Hi overhovnik! I'm Dosu and I'm helping the Cozystack team.

    This is a known problem tracked in #2171, and a closely related duplicate was also filed as #2810 [1]. The root cause is the same splitList "-" logic you identified — it cannot reconstruct the full ancestor chain when tenant names don't encode the hierarchy.

    PR #2912 was merged to fix the namespace labeling side of this bug by replacing the split logic in namespace.yaml with a proper tenant.ancestorTenantLabels helper [2] [3]. However, the network policy template (packages/apps/tenant/templates/networkpolicy.yaml) still uses the old splitList "-" pattern in multiple places for computing ancestor namespaces in egress rules [4] — which is exactly the gap causing your OIDC failure.

    So the namespace labels are now correctly propagated, but networkpolicy.yaml was not updated with the same fix, leaving the egress rules incomplete for sub-tenants. This likely needs the same tenant.ancestorTenantLabels helper (or equivalent lookup-based approach) applied to the network policy template as well.

    A backport of #2912 to release-1.5 is also open as PR #3191 [5].

    Workaround: You can manually label the sub-tenant namespace with the missing ancestor label and, if needed, manually patch the CiliumClusterwideNetworkPolicy to include the root ingress endpoint:

    kubectl label namespace tenant-kube3-tenant3 tenant.cozystack.io/tenant-root=""

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about cozystack Share Dosu with your team

  3. added
    area/ciliumIssues or PRs related to Cilium (agent, operator, Gateway API, network policy, LB-IPAM)
    on Aug 19, 2026
  4. added
    area/tenantIssues or PRs related to the tenant chart and multi-tenancy
    triage/acceptedIndicates an issue is ready to be actively worked on
    priority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next release
    and removed
    triage/needs-triageIndicates an issue needs triage by a maintainer
    on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ciliumIssues or PRs related to Cilium (agent, operator, Gateway API, network policy, LB-IPAM)area/tenantIssues or PRs related to the tenant chart and multi-tenancykind/bugCategorizes issue or PR as related to a bugpriority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next releasetriage/acceptedIndicates an issue is ready to be actively worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions