Skip to content

Commit df4d4d4

Browse files
MINOR: haproxy: add service name override (#382)
* haproxy: add service name override Signed-off-by: Konstantin Kelemen <konstantin@kel.mn> * update httproute and ingress templates Signed-off-by: Konstantin Kelemen <konstantin@kel.mn> * MINOR: haproxy: centralise and quote the service name override The service.name fallback was spelled out at all four references to the Service (service.yaml, both ingress.yaml API branches, httproute.yaml), so any template added later would silently regress to the fullname and the two ingress branches had to be kept in sync by hand. Move it into a haproxy.serviceName helper alongside the existing name helpers. Quote the rendered name as well. Kubernetes parses manifests with YAML 1.1 semantics, so a valid DNS-1035 Service name such as "on", "off", "yes" or "no" was coerced to a boolean and the object rejected with "cannot unmarshal !!bool into string". Signed-off-by: Dinko Korunic <dkorunic@haproxy.com> * MINOR: haproxy: document the service.name default and rename caveat The comment claimed the default was .Release.Name, but the Service is named after haproxy.fullname, ie. "<release>-haproxy". It also used a trailing comment where the rest of the block documents keys above them. Add the caveat that renaming the Service of an existing release replaces it rather than updating it in place: the ClusterIP changes and, with type LoadBalancer, the cloud provider provisions a new load balancer with a new external address. Signed-off-by: Dinko Korunic <dkorunic@haproxy.com> * MINOR: haproxy: add CI values file for the service name override Nothing under haproxy/ci/ set service.name, so the consistency between the Service and the Ingress backend it is referenced from was never asserted by local-test.sh or the integration-test.sh ci scenario. httpRoute is left disabled: install_charts.sh only brings up the Gateway API CRDs for the charts that need cloud-provider-kind, and httproute.yaml has no .Capabilities.APIVersions gate, so enabling it here would break ct install. That path is still rendered offline by local-test.sh. Signed-off-by: Dinko Korunic <dkorunic@haproxy.com> --------- Signed-off-by: Konstantin Kelemen <konstantin@kel.mn> Signed-off-by: Dinko Korunic <dkorunic@haproxy.com> Co-authored-by: Dinko Korunic <dkorunic@haproxy.com>
1 parent 67ac692 commit df4d4d4

6 files changed

Lines changed: 23 additions & 4 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: Deployment
2+
service:
3+
name: haproxy-custom-svc
4+
ingress:
5+
enabled: true

haproxy/templates/_helpers.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ Create the name of the service account to use
8888
{{- end }}
8989
{{- end }}
9090

91+
{{/*
92+
Create the name of the service to use
93+
*/}}
94+
{{- define "haproxy.serviceName" -}}
95+
{{- default (include "haproxy.fullname" .) .Values.service.name }}
96+
{{- end }}
97+
9198
{{/*
9299
Create includes name
93100
*/}}

haproxy/templates/httproute.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ spec:
3434
{{- toYaml . | nindent 8 }}
3535
{{- end }}
3636
backendRefs:
37-
- name: {{ $fullName }}
37+
- name: {{ include "haproxy.serviceName" $ | quote }}
3838
port: {{ $svcPort }}
3939
{{- end }}
4040
{{- end }}

haproxy/templates/ingress.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ spec:
4343
backend:
4444
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
4545
service:
46-
name: {{ $fullName }}
46+
name: {{ include "haproxy.serviceName" $ | quote }}
4747
port:
4848
number: {{ $svcPort }}
4949
{{- else }}
50-
serviceName: {{ $fullName }}
50+
serviceName: {{ include "haproxy.serviceName" $ | quote }}
5151
servicePort: {{ $svcPort }}
5252
{{- end }}
5353
{{- end }}

haproxy/templates/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
apiVersion: v1
1818
kind: Service
1919
metadata:
20-
name: {{ include "haproxy.fullname" . }}
20+
name: {{ include "haproxy.serviceName" . | quote }}
2121
namespace: {{ include "haproxy.namespace" . }}
2222
labels:
2323
{{- include "haproxy.labels" . | nindent 4 }}

haproxy/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,13 @@ PodDisruptionBudget:
492492
## Service configuration
493493
## ref: https://kubernetes.io/docs/concepts/services-networking/service/
494494
service:
495+
## Service name override
496+
## Defaults to the chart fullname, ie. "<release>-haproxy"
497+
## NOTE: renaming the Service of an existing release replaces it, so the
498+
## ClusterIP changes and, with type LoadBalancer, the cloud provider tears down
499+
## the old load balancer and provisions a new one with a new external address
500+
name: ""
501+
495502
type: ClusterIP # can be 'ClusterIP', 'NodePort', 'LoadBalancer'
496503

497504
## Service ClusterIP

0 commit comments

Comments
 (0)