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.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [ ] 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
This commit is contained in:
Phillip Boushy 2024-08-07 09:42:39 -06:00 committed by GitHub
parent 90f0414e21
commit c221fa3eee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 3 deletions

View file

@ -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.
*/}}

View file

@ -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 }}

View file

@ -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 }}