Skip to content

Commit 994e911

Browse files
jsonmp-k8EItanyaclaude
authored
fix(helm): use fullname in selector labels to prevent mismatch on upgrade (#47)
* fix(helm): use fullname in selector labels to prevent mismatch on upgrade Use kagent.fullname instead of kagent.name in selectorLabels so that changing nameOverride does not alter the app.kubernetes.io/name selector label. Deployment spec.selector.matchLabels is immutable in Kubernetes, so any label change causes a Service/Deployment selector mismatch after helm upgrade, leaving the Service with zero endpoints. With this fix, both the old config (fullnameOverride: kagent-tools) and the new config (nameOverride: tools) resolve to the same fullname "kagent-tools" for the default release name, keeping selectors stable across upgrades. Fixes kagent-dev/kagent#1427 Signed-off-by: Jaison Paul <paul.jaison@gmail.com> * fix(e2e): update label selectors to match fullname-based selector labels Update E2E tests to use app.kubernetes.io/instance label selector instead of app.kubernetes.io/name since the PR changes selectorLabels to use kagent.fullname. The fullname template returns the release name (kagent-tools-e2e), so the tests now use app.kubernetes.io/instance=<releaseName> which remains stable and matches the updated selector labels in the Helm chart. This fixes the E2E test failures where pods weren't being found because the label selector no longer matched after the selectorLabels change. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io> --------- Signed-off-by: Jaison Paul <paul.jaison@gmail.com> Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io> Co-authored-by: Eitan Yarmush <eitan.yarmush@solo.io> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 4c2b7a5 commit 994e911

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

helm/kagent-tools/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
4343
Selector labels
4444
*/}}
4545
{{- define "kagent.selectorLabels" -}}
46-
app.kubernetes.io/name: {{ include "kagent.name" . }}
46+
app.kubernetes.io/name: {{ include "kagent.fullname" . }}
4747
app.kubernetes.io/instance: {{ .Release.Name }}
4848
{{- end }}
4949

helm/kagent-tools/tests/deployment_test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,5 @@ tests:
171171
- equal:
172172
path: spec.template.spec.topologySpreadConstraints[0].labelSelector.matchLabels
173173
value:
174-
app.kubernetes.io/name: kagent-tools
174+
app.kubernetes.io/name: RELEASE-NAME
175175
app.kubernetes.io/instance: RELEASE-NAME

test/e2e/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func InstallKAgentTools(namespace string, releaseName string) {
224224
defer cancel()
225225

226226
output, err := commands.NewCommandBuilder("kubectl").
227-
WithArgs("get", "pods", "-n", namespace, "-l", "app.kubernetes.io/name=kagent-tools", "-o", "jsonpath={.items[*].status.phase}").
227+
WithArgs("get", "pods", "-n", namespace, "-l", "app.kubernetes.io/instance="+releaseName, "-o", "jsonpath={.items[*].status.phase}").
228228
Execute(ctx)
229229

230230
if err != nil {

test/e2e/k8s_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var _ = Describe("KAgent Tools Kubernetes E2E Tests", Ordered, func() {
5656

5757
log.Info("Checking if kagent-tools pods are running", "namespace", namespace)
5858
output, err := commands.NewCommandBuilder("kubectl").
59-
WithArgs("get", "pods", "-n", namespace, "-l", "app.kubernetes.io/name=kagent-tools", "-o", "json").
59+
WithArgs("get", "pods", "-n", namespace, "-l", "app.kubernetes.io/instance="+releaseName, "-o", "json").
6060
Execute(ctx)
6161

6262
Expect(err).ToNot(HaveOccurred())
@@ -70,7 +70,7 @@ var _ = Describe("KAgent Tools Kubernetes E2E Tests", Ordered, func() {
7070

7171
log.Info("Checking if kagent-tools service is accessible", "namespace", namespace)
7272
output, err := commands.NewCommandBuilder("kubectl").
73-
WithArgs("get", "svc", "-n", namespace, "-l", "app.kubernetes.io/name=kagent-tools", "-o", "json").
73+
WithArgs("get", "svc", "-n", namespace, "-l", "app.kubernetes.io/instance="+releaseName, "-o", "json").
7474
Execute(ctx)
7575

7676
Expect(err).ToNot(HaveOccurred())

0 commit comments

Comments
 (0)