From c221fa3eee95bdaab61e102053fec04bf37df50a Mon Sep 17 00:00:00 2001 From: Phillip Boushy Date: Wed, 7 Aug 2024 09:42:39 -0600 Subject: [PATCH] Fix helm chart service name when using custom release name (#20832) - created new template fleet.servicename - reference in all locations that contain service name Resolves #20830. # Checklist for submitter If some of the following don't apply, delete the relevant line. - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Manual QA for all new/changed functionality --- charts/fleet/templates/_helpers.tpl | 5 +++++ charts/fleet/templates/ingress.yaml | 5 +++-- charts/fleet/templates/service.yaml | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/charts/fleet/templates/_helpers.tpl b/charts/fleet/templates/_helpers.tpl index f6c41ef3fb..fd0cfffbf9 100644 --- a/charts/fleet/templates/_helpers.tpl +++ b/charts/fleet/templates/_helpers.tpl @@ -23,6 +23,11 @@ If release name contains chart name it will be used as a full name. {{- end }} {{- end }} +{{- define "fleet.servicename" -}} +{{- $fullName := include "fleet.fullname" . -}} +{{- printf "%s-service" $fullName }} +{{- end }} + {{/* Create chart name and version as used by the chart label. */}} diff --git a/charts/fleet/templates/ingress.yaml b/charts/fleet/templates/ingress.yaml index 0a7326d995..1a3e758a29 100644 --- a/charts/fleet/templates/ingress.yaml +++ b/charts/fleet/templates/ingress.yaml @@ -1,5 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "fleet.fullname" . -}} +{{- $serviceName := include "fleet.servicename" . -}} {{- $svcPort := ternary .Values.fleet.listenPort .Values.fleet.servicePort (eq .Values.fleet.servicePort nil) -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} @@ -49,11 +50,11 @@ spec: backend: {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} service: - name: {{ $fullName }} + name: {{ $serviceName }} port: number: {{ $svcPort }} {{- else }} - serviceName: {{ $fullName }} + serviceName: {{ $serviceName }} servicePort: {{ $svcPort }} {{- end }} {{- end }} diff --git a/charts/fleet/templates/service.yaml b/charts/fleet/templates/service.yaml index 1a22e48fc0..fa1c13a94d 100644 --- a/charts/fleet/templates/service.yaml +++ b/charts/fleet/templates/service.yaml @@ -1,3 +1,4 @@ +{{- $serviceName := include "fleet.servicename" . -}} apiVersion: v1 kind: Service metadata: @@ -6,7 +7,7 @@ metadata: chart: fleet heritage: {{ .Release.Service }} release: {{ .Release.Name }} - name: fleet + name: {{ $serviceName }} namespace: {{ .Release.Namespace }} spec: {{- if .Values.gke.ingress.useGKEIngress }}