svc.yaml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  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. annotations:
  12. {{- if .Values.commonAnnotations }}
  13. {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  14. {{- end }}
  15. {{- if .Values.primary.service.annotations }}
  16. {{- include "common.tplvalues.render" (dict "value" .Values.primary.service.annotations "context" $) | nindent 4 }}
  17. {{- end }}
  18. spec:
  19. type: {{ .Values.primary.service.type }}
  20. {{- if or (eq .Values.primary.service.type "LoadBalancer") (eq .Values.primary.service.type "NodePort") }}
  21. externalTrafficPolicy: {{ .Values.primary.service.externalTrafficPolicy | quote }}
  22. {{- end }}
  23. {{- if and (eq .Values.primary.service.type "LoadBalancer") (not (empty .Values.primary.service.loadBalancerSourceRanges)) }}
  24. loadBalancerSourceRanges: {{ .Values.primary.service.loadBalancerSourceRanges }}
  25. {{- end }}
  26. {{- if and (eq .Values.primary.service.type "LoadBalancer") (not (empty .Values.primary.service.loadBalancerIP)) }}
  27. loadBalancerIP: {{ .Values.primary.service.loadBalancerIP }}
  28. {{- end }}
  29. {{- if and .Values.primary.service.clusterIP (eq .Values.primary.service.type "ClusterIP") }}
  30. clusterIP: {{ .Values.primary.service.clusterIP }}
  31. {{- end }}
  32. {{- if .Values.primary.service.sessionAffinity }}
  33. sessionAffinity: {{ .Values.primary.service.sessionAffinity }}
  34. {{- end }}
  35. {{- if .Values.primary.service.sessionAffinityConfig }}
  36. sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.primary.service.sessionAffinityConfig "context" $) | nindent 4 }}
  37. {{- end }}
  38. ports:
  39. - name: tcp-postgresql
  40. port: {{ template "postgresql.service.port" . }}
  41. targetPort: tcp-postgresql
  42. {{- if and (or (eq .Values.primary.service.type "NodePort") (eq .Values.primary.service.type "LoadBalancer")) (not (empty .Values.primary.service.nodePorts.postgresql)) }}
  43. nodePort: {{ .Values.primary.service.nodePorts.postgresql }}
  44. {{- else if eq .Values.primary.service.type "ClusterIP" }}
  45. nodePort: null
  46. {{- end }}
  47. {{- if .Values.primary.service.extraPorts }}
  48. {{- include "common.tplvalues.render" (dict "value" .Values.primary.service.extraPorts "context" $) | nindent 4 }}
  49. {{- end }}
  50. selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
  51. app.kubernetes.io/component: primary