Skip to content

feat(chart): apply commonLabels to all rendered resources - #739

Merged
undera merged 2 commits into
mainfrom
feat/chart-common-labels
Aug 10, 2026
Merged

feat(chart): apply commonLabels to all rendered resources#739
undera merged 2 commits into
mainfrom
feat/chart-common-labels

Conversation

@undera

@undera undera commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Supersedes #730 — carries @ashutoshbhardwaj007's original commit and adds the templating that makes the value do something.

Problem

commonLabels was declared in values.yaml but referenced by no template, so setting it produced no labels anywhere. dashboard.persistence.labels has the same defect: documented in values.yaml, used by nothing.

Change

  • commonLabels merged into the helm-dashboard.labels helper, which every resource already includes
  • Deployment pod template gets them too — but not spec.selector.matchLabels, which is immutable; folding them in there would break helm upgrade on existing releases
  • ClusterRole and ClusterRoleBinding had no labels at all, so they now get the standard block
  • dashboard.persistence.labels wired into the PVC
  • README rows for commonLabels, dashboard.persistence.labels and dashboard.persistence.annotations

Verification

helm lint clean. With commonLabels set, all 8 rendered resources carry them (ServiceAccount, PVC, ClusterRole, ClusterRoleBinding, Service, Deployment metadata + pod template, Ingress, test Pod) while spec.selector renders byte-identical to main.

Rendered with defaults, the only diff against main is the new label block on ClusterRole/ClusterRoleBinding. Keys containing dots and values like "1.0" or "" round-trip correctly through toYaml.

Closes #730

🤖 Generated with Claude Code

ashutoshbhardwaj007 and others added 2 commits August 10, 2026 13:53
## What this PR does

Adds `commonLabels` support to the helm-dashboard chart, allowing users
to define a set of labels that are applied to all chart-managed resources.

## Why

Teams running helm-dashboard in shared or multi-tenant clusters commonly
need to attach labels to all resources for:

- Cost allocation and chargeback (e.g. `team:`, `env:`, `cost-center:`)
- Network policy targeting
- Label-based selectors and queries (e.g. in Prometheus, Grafana, kubectl)
- Compliance and audit requirements

Currently the chart only supports labels on the PersistentVolumeClaim
(`dashboard.persistence.labels`). There is no way to label the
Deployment, Service, ServiceAccount, Ingress, or pod template without
forking the chart.

## Changes

- Add `commonLabels: {}` to `values.yaml`
- Apply the helper to all chart-managed resources:
  - Deployment (metadata + pod template)
  - Service
  - ServiceAccount
  - Ingress

## Usage

```yaml
commonLabels:
  team: platform
  env: production
  cost-center: infra
```

## References

- Similar implementation in prometheus-community charts:
  prometheus-community/helm-charts#6608
The commonLabels value was declared but never referenced by any template,
so setting it had no effect. Merge it into the helm-dashboard.labels
helper, which every resource already includes, and into the Deployment
pod template.

Pod selector labels are deliberately left alone: spec.selector is
immutable, so folding commonLabels in there would break helm upgrade on
existing releases.

ClusterRole and ClusterRoleBinding carried no labels at all; they now get
the standard label block, which is the only change to the default render.

Also wires up dashboard.persistence.labels, documented in values.yaml but
likewise referenced by no template, and adds the missing README rows.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 28.42%. Comparing base (4432071) to head (87bba91).
⚠️ Report is 56 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #739      +/-   ##
==========================================
+ Coverage   21.92%   28.42%   +6.49%     
==========================================
  Files          14       15       +1     
  Lines        2239     2565     +326     
==========================================
+ Hits          491      729     +238     
- Misses       1701     1764      +63     
- Partials       47       72      +25     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@undera
undera marked this pull request as ready for review August 10, 2026 13:17
@undera
undera merged commit 25122a4 into main Aug 10, 2026
4 checks passed
@undera
undera deleted the feat/chart-common-labels branch August 10, 2026 13:17
@ashutoshbhardwaj007

ashutoshbhardwaj007 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Thanks for improving on my MR and taking it forward with #739. Appreciate it!

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.

3 participants