Skip to content

Operator leader-election event recording fails with namespace-scoped RBAC #7299

Done

Description

@AmitThakkar

Summary

With namespace-scoped RBAC and workload namespaces excluding the operator namespace, the operator logs a forbidden error when recording its leader-election event.

Leader election succeeds, and the operator remains healthy. Recording the informational event fails.

Environment

  • ToolHive operator/chart: v0.58.0
  • Operator namespace: toolhive-system
  • Workload namespace: mcp-workloads

Relevant Helm values

operator:
  rbac:
    scope: namespace
    allowedNamespaces:
      - mcp-workloads

Steps to reproduce

  1. Install the operator with the configuration above.
  2. Start or restart the operator.
  3. Check its logs after it acquires the leader-election lease.

Actual behavior

The operator successfully acquires its lease, then logs:

events is forbidden:
User "system:serviceaccount:toolhive-system:toolhive-operator" cannot create resource "events" in API group "" in the namespace "toolhive-system"

The rejected event has:

  • Kind: Lease
  • Reason: LeaderElection
  • Message: became leader

The chart's leader-election Role grants create and patch for events.k8s.io/events, but the rejected request targets core-group ""/events.

Expected behavior

The default leader-election RBAC and the API used by its event recorder should match, including when the operator namespace is excluded from allowedNamespaces.

Investigation

The v0.69.0 chart values still appear to grant only events.k8s.io/events in operator.leaderElectionRole.rules. We have not tested that version.

Related PR #5243 and issue #5339 concern event API-group permissions, but this appears to involve the operator's own leader-election recorder.

Questions

  • Is this a known issue, and is there a released fix?
  • Should the leader-election Role grant core-group event permissions as well, or should its recorder use events.k8s.io?
  • Is overriding operator.leaderElectionRole.rules to include
    apiGroups: [""], resources: ["events"], and
    verbs: ["create", "patch"] the recommended workaround?

Impact

The operator remains running and leader election succeeds. The observed impact is a rejected leader-election event and an error in the logs.

Activity

  1. added
    kubernetes
    on Nov 25, 2026
  2. added
    needs-triage
    on Nov 25, 2026
  3. pcbeingused333 commented on Nov 26, 2026

    @pcbeingused333
    Contributor

    I'd like to work on this. The leader-election lock uses controller-runtime's GetEventRecorderFor, which writes core API group events, while the chart's leader-election Role grants event permissions only in events.k8s.io. I'd add a create and patch rule for core-group events alongside the existing rule and add a Helm unit test for namespace-scoped RBAC with the operator namespace outside allowedNamespaces. Could you assign this issue to me?

  4. removed
    needs-triage
    on Nov 26, 2026
  5. jhrozek commented on Nov 26, 2026

    @jhrozek
    Contributor

    Assigned to you @pcbeingused333

  6. added a commit that references this issue on Nov 27, 2026
    7d1ef06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

kubernetes

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions