blob: e86926fa49a9fd9d0b6b3ad1baf1c8c432edfc21 [file] [log] [blame]
Sketch🕴️620d57b2025-07-31 22:31:14 +04001{{- /*
2Copyright Broadcom, Inc. All Rights Reserved.
3SPDX-License-Identifier: APACHE-2.0
4*/}}
5
6apiVersion: v1
7kind: Service
8metadata:
9 name: {{ template "common.names.fullname" . }}
10 namespace: {{ include "common.names.namespace" . | quote }}
11 labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
12 annotations:
13 {{- if or .Values.service.annotations .Values.commonAnnotations }}
14 {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.service.annotations .Values.commonAnnotations ) "context" . ) }}
15 {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
16 {{- end }}
17 {{- if and .Values.metrics.enabled .Values.metrics.service.annotations }}
18 {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.service.annotations "context" $) | nindent 4 }}
19 {{- end }}
20spec:
21 type: {{ .Values.service.type }}
22 {{- if and .Values.service.clusterIP (eq .Values.service.type "ClusterIP") }}
23 clusterIP: {{ .Values.service.clusterIP }}
24 {{- end }}
25 {{- if .Values.service.sessionAffinity }}
26 sessionAffinity: {{ .Values.service.sessionAffinity }}
27 {{- end }}
28 {{- if .Values.service.sessionAffinityConfig }}
29 sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.service.sessionAffinityConfig "context" $) | nindent 4 }}
30 {{- end }}
31 {{- if or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") }}
32 externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
33 {{- end }}
34 {{- if and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerSourceRanges)) }}
35 loadBalancerSourceRanges: {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
36 {{- end }}
37 {{- if and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerIP)) }}
38 loadBalancerIP: {{ .Values.service.loadBalancerIP }}
39 {{- end }}
40 {{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerClass }}
41 loadBalancerClass: {{ .Values.service.loadBalancerClass }}
42 {{- end }}
43 ports:
44 {{- if .Values.containerPorts.http }}
45 - name: http
46 port: {{ .Values.service.ports.http }}
47 targetPort: {{ .Values.service.targetPort.http }}
48 {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.http)) }}
49 nodePort: {{ .Values.service.nodePorts.http }}
50 {{- end }}
51 {{- end }}
52 {{- if .Values.containerPorts.https }}
53 - name: https
54 port: {{ .Values.service.ports.https }}
55 targetPort: {{ .Values.service.targetPort.https }}
56 {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.https)) }}
57 nodePort: {{ .Values.service.nodePorts.https }}
58 {{- end }}
59 {{- end }}
60 {{- if .Values.metrics.enabled }}
61 - name: metrics
62 port: {{ .Values.metrics.service.port }}
63 targetPort: metrics
64 {{- end }}
65 {{- if .Values.service.extraPorts }}
66 {{- include "common.tplvalues.render" (dict "value" .Values.service.extraPorts "context" $) | nindent 4 }}
67 {{- end }}
68 {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.podLabels .Values.commonLabels ) "context" . ) }}
69 selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}