blob: 6ddd55b7bbe5edab16709a7644de506d18ba51ac [file] [log] [blame]
Giorgi Lekveishvili8c99d622023-05-30 14:40:50 +04001apiVersion: v1
2kind: Service
3metadata:
4 name: {{ include "postgresql.primary.fullname" . }}
5 namespace: {{ .Release.Namespace | quote }}
6 labels: {{- include "common.labels.standard" . | nindent 4 }}
7 {{- if .Values.commonLabels }}
8 {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
9 {{- end }}
10 app.kubernetes.io/component: primary
11 {{- if or .Values.commonAnnotations .Values.primary.service.annotations }}
12 annotations:
13 {{- if .Values.commonAnnotations }}
14 {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
15 {{- end }}
16 {{- if .Values.primary.service.annotations }}
17 {{- include "common.tplvalues.render" (dict "value" .Values.primary.service.annotations "context" $) | nindent 4 }}
18 {{- end }}
19 {{- end }}
20spec:
21 type: {{ .Values.primary.service.type }}
22 {{- if or (eq .Values.primary.service.type "LoadBalancer") (eq .Values.primary.service.type "NodePort") }}
23 externalTrafficPolicy: {{ .Values.primary.service.externalTrafficPolicy | quote }}
24 {{- end }}
25 {{- if and (eq .Values.primary.service.type "LoadBalancer") (not (empty .Values.primary.service.loadBalancerSourceRanges)) }}
26 loadBalancerSourceRanges: {{ .Values.primary.service.loadBalancerSourceRanges }}
27 {{- end }}
28 {{- if and (eq .Values.primary.service.type "LoadBalancer") (not (empty .Values.primary.service.loadBalancerIP)) }}
29 loadBalancerIP: {{ .Values.primary.service.loadBalancerIP }}
30 {{- end }}
31 {{- if and .Values.primary.service.clusterIP (eq .Values.primary.service.type "ClusterIP") }}
32 clusterIP: {{ .Values.primary.service.clusterIP }}
33 {{- end }}
34 {{- if .Values.primary.service.sessionAffinity }}
35 sessionAffinity: {{ .Values.primary.service.sessionAffinity }}
36 {{- end }}
37 {{- if .Values.primary.service.sessionAffinityConfig }}
38 sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.primary.service.sessionAffinityConfig "context" $) | nindent 4 }}
39 {{- end }}
40 ports:
41 - name: tcp-postgresql
42 port: {{ template "postgresql.service.port" . }}
43 targetPort: tcp-postgresql
44 {{- if and (or (eq .Values.primary.service.type "NodePort") (eq .Values.primary.service.type "LoadBalancer")) (not (empty .Values.primary.service.nodePorts.postgresql)) }}
45 nodePort: {{ .Values.primary.service.nodePorts.postgresql }}
46 {{- else if eq .Values.primary.service.type "ClusterIP" }}
47 nodePort: null
48 {{- end }}
49 {{- if .Values.primary.service.extraPorts }}
50 {{- include "common.tplvalues.render" (dict "value" .Values.primary.service.extraPorts "context" $) | nindent 4 }}
51 {{- end }}
52 selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
53 app.kubernetes.io/component: primary