Skip to content

fix(litellm-operator): grant RBAC for LiteLLMTeam/LiteLLMVirtualKey - #4326

Merged
Tanguille merged 1 commit into
mainfrom
fix/litellm-operator-team-rbac
Aug 3, 2026
Merged

fix(litellm-operator): grant RBAC for LiteLLMTeam/LiteLLMVirtualKey#4326
Tanguille merged 1 commit into
mainfrom
fix/litellm-operator-team-rbac

Conversation

@Tanguille

Copy link
Copy Markdown
Owner

Summary

This is why tonight's LiteLLMModel omniroute changes (90s timeout in #4323/#4324, auto/smart in #4325) never actually reached the live litellm proxy despite the K8s CRs updating correctly and Flux reconciling clean.

litellm-operator 0.0.10 (bumped in #4318) added LiteLLMTeam and LiteLLMVirtualKey controllers without matching RBAC rules in the chart's ClusterRole. The manager blocks on all informer caches syncing at startup; litellmteams/litellmvirtualkeys time out (403 forbidden), the whole manager fails, and kubelet restarts the pod — 50 restarts observed over 171 minutes, i.e. it's been crashlooping continuously and never actually held leadership long enough to reconcile any LiteLLMModel change since the version bump.

Evidence

litellmteams.litellm.home-operations.com is forbidden: User
"system:serviceaccount:ai:litellm-operator" cannot list resource
"litellmteams" in API group "litellm.home-operations.com" at the cluster scope
...
"problem running manager","error":"failed to wait for litellmteam caches to sync"

kubectl get clusterrole litellm-operator-manager-role confirms litellmteams/litellmvirtualkeys are absent from the rules, while sibling resources (litellmmodels, litellmproxies, etc.) are present.

Fix

Standalone additive ClusterRole/ClusterRoleBinding granting the same verb pattern already used for litellmmodels (get/list/watch + CRUD + status). Checked helm show values for the chart — no rbac.rules/extraObjects extension point exists, so this can't be expressed as a HelmRelease values patch; drop this once upstream ships the missing rules.

Test plan

  • kustomize build kubernetes/apps/ai/litellm/app clean, ClusterRole/ClusterRoleBinding render without a namespace field
  • After rollout: operator pod stops restarting, kubectl -n ai logs deploy/litellm-operator shows no more cache-sync timeout
  • curl .../model/info on litellm shows omniroute's live config matching the CR (model: openai/auto/smart, timeout: 90)

0.0.10 added the LiteLLMTeam and LiteLLMVirtualKey controllers without
matching ClusterRole rules, so their informer caches never sync and
the manager crashloops on every startup (leader election lost ->
shutdown -> restart, 50 restarts observed over 171min). This silently
broke applyMode: api sync for every LiteLLMModel change since the
0.0.9->0.0.10 bump (#4318) — the K8s CRs updated fine but litellm's
live model config never picked them up.

Chart has no rbac.rules/extraObjects values extension point (checked
via helm show values), so this has to be a standalone additive
ClusterRole/ClusterRoleBinding rather than a HelmRelease values patch.
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Tanguille, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 9 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0fc4b8f5-404c-4e4e-b8e6-2152c6da1feb

📥 Commits

Reviewing files that changed from the base of the PR and between 18928af and be98d1e.

📒 Files selected for processing (2)
  • kubernetes/apps/ai/litellm/app/kustomization.yaml
  • kubernetes/apps/ai/litellm/app/rbac.yaml

Comment @coderabbitai help to get the list of available commands.

@deepsource-io

deepsource-io Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

DeepSource Code Review

We reviewed changes in 18928af...be98d1e on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Aug 3, 2026 9:39p.m. Review ↗
Shell Aug 3, 2026 9:39p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@tanguille-cluster

Copy link
Copy Markdown
@@ (root level) @@
# rbac.authorization.k8s.io/v1/ClusterRole/litellm-operator-team-rbac-patch
! + one document added:
+ apiVersion: rbac.authorization.k8s.io/v1
+ kind: ClusterRole
+ metadata:
+   name: litellm-operator-team-rbac-patch
+   labels:
+     kustomize.toolkit.fluxcd.io/name: litellm-operator
+     kustomize.toolkit.fluxcd.io/namespace: ai
+ rules:
+ - resources:
+   - litellmteams
+   - litellmvirtualkeys
+   apiGroups:
+   - litellm.home-operations.com
+   verbs:
+   - get
+   - list
+   - watch
+   - create
+   - update
+   - patch
+   - delete
+ - resources:
+   - litellmteams/status
+   - litellmvirtualkeys/status
+   apiGroups:
+   - litellm.home-operations.com
+   verbs:
+   - get
+   - update
+   - patch

@@ (root level) @@
# rbac.authorization.k8s.io/v1/ClusterRoleBinding/litellm-operator-team-rbac-patch
! + one document added:
+ apiVersion: rbac.authorization.k8s.io/v1
+ kind: ClusterRoleBinding
+ metadata:
+   name: litellm-operator-team-rbac-patch
+   labels:
+     kustomize.toolkit.fluxcd.io/name: litellm-operator
+     kustomize.toolkit.fluxcd.io/namespace: ai
+ roleRef:
+   name: litellm-operator-team-rbac-patch
+   apiGroup: rbac.authorization.k8s.io
+   kind: ClusterRole
+ subjects:
+ - name: litellm-operator
+   kind: ServiceAccount
+   namespace: ai

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

AI Automated Review

Analysis engine: omniroute@http://litellm.ai.svc.cluster.local/v1 (openai)

Recommendation: Approve

This PR correctly fixes a crashloop in litellm-operator caused by missing RBAC rules for new controllers (LiteLLMTeam, LiteLLMVirtualKey) introduced in chart version 0.0.10. The operator was unable to sync its informer caches (403 Forbidden on litellmteams/litellmvirtualkeys), lost leader election, and restarted continuously — 50 restarts over 171 minutes.

Change-by-change findings

kubernetes/apps/ai/litellm/app/rbac.yaml (new)

  • Adds an additive ClusterRole + ClusterRoleBinding granting the same verb pattern already used for litellmmodels (get/list/watch + CRUD + status subresource).
  • Binds to the existing litellm-operator ServiceAccount in namespace ai.
  • Named litellm-operator-team-rbac-patch to signal it's a temporary patch; comment documents the upstream version (0.0.10) and intent to drop once the chart includes the rules.
  • Uses the repo's schema reference (k8s-schemas.home-operations.com) for validation.

kubernetes/apps/ai/litellm/app/kustomization.yaml

  • Adds rbac.yaml to the resource list so the patch is applied alongside the HelmRelease.

Standards Compliance

  • Follows the repo's GitOps pattern: manifests under kubernetes/apps/<namespace>/<app>/app/, included via Kustomization.
  • Uses Conventional Commit title: fix(litellm-operator): grant RBAC for LiteLLMTeam/LiteLLMVirtualKey.
  • No secrets, no direct cluster edits, changes are small and focused.
  • The additive ClusterRole survives chart upgrades (HelmRelease manages the chart's own ClusterRole; this is a separate object).

Tool Harness Findings

No tool harness output present in corpus.

Unknowns or Needs Verification

  • The fix should be validated post-merge: operator pod stops restarting and kubectl -n ai logs deploy/litellm-operator shows no more cache-sync timeouts. This is covered by the PR's test plan.
  • Upstream chart release should be monitored to drop this patch when the missing rules are included.

Unaddressed required checks

The classifier marked these checks as required for this PR's risk profile, but the review above does not appear to discuss them:

  • review auth flow for regression
  • verify session token handling is correct

@Tanguille
Tanguille merged commit 9cd82c4 into main Aug 3, 2026
15 checks passed
@Tanguille
Tanguille deleted the fix/litellm-operator-team-rbac branch August 3, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant