Skip to content

Add RBAC support for k8s_leader_elector extension (#4802)#4891

Open
gyanranjanpanda wants to merge 1 commit intoopen-telemetry:mainfrom
gyanranjanpanda:feat/4802-k8s-leader-elector
Open

Add RBAC support for k8s_leader_elector extension (#4802)#4891
gyanranjanpanda wants to merge 1 commit intoopen-telemetry:mainfrom
gyanranjanpanda:feat/4802-k8s-leader-elector

Conversation

@gyanranjanpanda
Copy link
Copy Markdown

Changes Made

This PR adds automatic RBAC generation support for the k8s_leader_elector extension, addressing issue #4802.

  • internal/controllers/opentelemetrycollector_controller.go: Updated operator Kubebuilder markers to request get, list, watch, create, update, patch, delete on coordination.k8s.io leases.
  • internal/components/extensions/helpers.go: Registered the k8s_leader_elector extension to be detected during parsing.
  • internal/components/extensions/k8sleaderelector.go: Added the RBAC policy generator giving the OpenTelemetryCollector service account permissions to participate in leader election via leases.
  • .chloggen/issue_4802.yaml: Added the changelog entry.

What Was Tested

  • Unit tests: Validated the ClusterRole construction in internal/manifests/collector/rbac_test.go and logic checking the presence of all 7 required verbs.
  • E2E Validation: Added chainsaw-test.yaml end-to-end framework test cases for the k8s_leader_elector.

Validation Results

  • The operator correctly assigns permissions down to the auto-generated ClusterRole whenever the collector configuration explicitly defines the k8s_leader_elector extension. E2E pipeline and unit tests have verified this automatically.

@gyanranjanpanda gyanranjanpanda requested a review from a team as a code owner March 23, 2026 17:08
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Mar 23, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: gyanranjanpanda / name: Gyan ranjan (14d499b)

@gyanranjanpanda gyanranjanpanda force-pushed the feat/4802-k8s-leader-elector branch 4 times, most recently from 9e1a54e to 535f216 Compare March 23, 2026 17:26
@gyanranjanpanda gyanranjanpanda force-pushed the feat/4802-k8s-leader-elector branch 2 times, most recently from f52e31e to de7d719 Compare March 24, 2026 14:26
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

E2E Test Results

 32 files  249 suites   2h 6m 41s ⏱️
 96 tests  96 ✅ 0 💤 0 ❌
253 runs  253 ✅ 0 💤 0 ❌

Results for commit 14d499b.

♻️ This comment has been updated with latest results.

defaultPort int32
}{
{"health_check", "__health_check", 13133},
{"k8s_leader_elector", "__k8s_leader_elector", 0},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think you want this here, since it causes a bunch of port and config tests to be run (and fail). I'd just remove it, the other tests are sufficient.

@swiatekm
Copy link
Copy Markdown
Contributor

It looks like your E2E tests are failing as well @gyanranjanpanda.

@gyanranjanpanda gyanranjanpanda force-pushed the feat/4802-k8s-leader-elector branch from de7d719 to 199469c Compare March 27, 2026 11:38
@gyanranjanpanda gyanranjanpanda force-pushed the feat/4802-k8s-leader-elector branch from 199469c to 14d499b Compare March 27, 2026 12:43
@gyanranjanpanda
Copy link
Copy Markdown
Author

could @swiatekm check it now

Copy link
Copy Markdown
Contributor

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for the contribution!

@swiatekm swiatekm requested a review from a team March 27, 2026 15:19
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