svc.yaml 2.9 KB

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