svc.yaml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. {{- /*
  2. Copyright VMware, Inc.
  3. SPDX-License-Identifier: APACHE-2.0
  4. */}}
  5. {{- if eq .Values.architecture "replication" }}
  6. apiVersion: v1
  7. kind: Service
  8. metadata:
  9. name: {{ include "postgresql.v1.readReplica.fullname" . }}
  10. namespace: {{ .Release.Namespace | quote }}
  11. labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  12. app.kubernetes.io/component: read
  13. {{- if or .Values.commonAnnotations .Values.readReplicas.service.annotations }}
  14. {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.readReplicas.service.annotations .Values.commonAnnotations ) "context" . ) }}
  15. annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
  16. {{- end }}
  17. spec:
  18. type: {{ .Values.readReplicas.service.type }}
  19. {{- if or (eq .Values.readReplicas.service.type "LoadBalancer") (eq .Values.readReplicas.service.type "NodePort") }}
  20. externalTrafficPolicy: {{ .Values.readReplicas.service.externalTrafficPolicy | quote }}
  21. {{- end }}
  22. {{- if and (eq .Values.readReplicas.service.type "LoadBalancer") (not (empty .Values.readReplicas.service.loadBalancerSourceRanges)) }}
  23. loadBalancerSourceRanges: {{ .Values.readReplicas.service.loadBalancerSourceRanges }}
  24. {{- end }}
  25. {{- if and (eq .Values.readReplicas.service.type "LoadBalancer") (not (empty .Values.readReplicas.service.loadBalancerIP)) }}
  26. loadBalancerIP: {{ .Values.readReplicas.service.loadBalancerIP }}
  27. {{- end }}
  28. {{- if and .Values.readReplicas.service.clusterIP (eq .Values.readReplicas.service.type "ClusterIP") }}
  29. clusterIP: {{ .Values.readReplicas.service.clusterIP }}
  30. {{- end }}
  31. {{- if .Values.readReplicas.service.sessionAffinity }}
  32. sessionAffinity: {{ .Values.readReplicas.service.sessionAffinity }}
  33. {{- end }}
  34. {{- if .Values.readReplicas.service.sessionAffinityConfig }}
  35. sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.readReplicas.service.sessionAffinityConfig "context" $) | nindent 4 }}
  36. {{- end }}
  37. ports:
  38. - name: tcp-postgresql
  39. port: {{ include "postgresql.v1.readReplica.service.port" . }}
  40. targetPort: tcp-postgresql
  41. {{- if and (or (eq .Values.readReplicas.service.type "NodePort") (eq .Values.readReplicas.service.type "LoadBalancer")) (not (empty .Values.readReplicas.service.nodePorts.postgresql)) }}
  42. nodePort: {{ .Values.readReplicas.service.nodePorts.postgresql }}
  43. {{- else if eq .Values.readReplicas.service.type "ClusterIP" }}
  44. nodePort: null
  45. {{- end }}
  46. {{- if .Values.readReplicas.service.extraPorts }}
  47. {{- include "common.tplvalues.render" (dict "value" .Values.readReplicas.service.extraPorts "context" $) | nindent 4 }}
  48. {{- end }}
  49. {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.readReplicas.podLabels .Values.commonLabels ) "context" . ) }}
  50. selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
  51. app.kubernetes.io/component: read
  52. {{- end }}