feat(helm): add podLabels for controller and UI pod templates#2237
feat(helm): add podLabels for controller and UI pod templates#2237elihai-risk wants to merge 4 commits into
Conversation
|
Thanks so much for the contribution, you'll need to pass DCO in order to merge, you can click the job to see which commits aren't signed correctly |
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds support for configuring additional labels on the controller and UI pod templates via a new global podLabels value plus per-component overrides, along with helm-unittest coverage.
Changes:
- Introduces
podLabels(global) andcontroller.podLabels/ui.podLabelsvalues. - Renders the configured labels into controller/UI Deployment pod template labels.
- Adds helm-unittest tests validating default/no-op and basic merging/override behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| helm/kagent/values.yaml | Adds new values for global + per-component pod template labels. |
| helm/kagent/templates/controller-deployment.yaml | Renders merged pod labels into the controller pod template. |
| helm/kagent/templates/ui-deployment.yaml | Renders merged pod labels into the UI pod template. |
| helm/kagent/tests/pod-labels_test.yaml | Adds unit tests for default behavior and override scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| {{- include "kagent.controller.selectorLabels" . | nindent 8 }} | ||
| {{- with .Values.controller.podLabels | default .Values.podLabels }} | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} |
| labels: | ||
| {{- include "kagent.ui.selectorLabels" . | nindent 8 }} | ||
| {{- with .Values.ui.podLabels | default .Values.podLabels }} | ||
| {{- toYaml . | nindent 8 }} | ||
| {{- end }} |
| # -- Additional labels to add to the controller pod template | ||
| # (overrides the global `podLabels` when set) | ||
| podLabels: {} |
| - it: should merge global podLabels into the controller pod template | ||
| template: controller-deployment.yaml | ||
| set: | ||
| podLabels: | ||
| team: platform | ||
| cost-center: ai | ||
| asserts: |
Add a global `podLabels` value plus per-component `controller.podLabels` and `ui.podLabels` overrides, merged into the pod template labels of the controller and UI Deployments (mirroring the existing podAnnotations pattern). Motivation: clusters commonly enforce admission policies (e.g. OPA Gatekeeper required-labels) that validate labels on the *pod template*, not on Deployment metadata. Agent pods already support this via controller.agentDeployment.podLabels (kagent-dev#1534); this closes the gap for the controller and UI pods, which currently render only selector labels and cannot pass such policies without forking the chart. Includes helm-unittest coverage (default no-op, global merge, per- component override, selector labels intact). Signed-off-by: Elihai Blomberg <elihai.blomberg@riskified.com>
90ae6fd to
fa6c57e
Compare
Address review feedback: emitting podLabels after the selector labels allowed overriding selector keys (duplicate YAML keys, last-wins), which could invalidate the Deployment (matchLabels/template mismatch). Build one merged map instead - global podLabels, then component podLabels (per-key override), then selector labels last so they can never be overridden. Clarify the values.yaml docs accordingly and add selector-protection tests (7 tests total). Signed-off-by: Elihai Blomberg <elihai.blomberg@riskified.com>
|
Thanks for the review! Pushed a follow-up addressing the feedback:
DCO is fixed as well (all commits signed off). |
What
Adds a global
podLabelsvalue plus per-componentcontroller.podLabels/ui.podLabelsoverrides, merged into the pod template labels of the controller and UI Deployments — mirroring the existingpodAnnotationspattern (component | default global).Why
Many clusters enforce admission policies (e.g. OPA Gatekeeper
required-labels, cost/ownership label policies) that validate labels on the pod template, not on Deployment metadata. Today:controller.agentDeployment.podLabels(feat: add --default-agent-pod-labels flag for global agent pod labels #1534) ✅We hit this deploying kagent 0.9.11 in a Gatekeeper-enforced cluster: the controller/UI Deployments were denied admission and we had to vendor the chart just for these two label blocks. This PR closes the gap upstream.
Notes
podLabels: {}); selector labels always take precedence by ordering.agent-nodeselector_test.yamlfailure on main is unrelated).🤖 Generated with Claude Code