{{- if .Values.external }}
apiVersion: v1
kind: Service
metadata:
  name: {{ .Release.Name }}-external-write
spec:
  type: {{ ternary "LoadBalancer" "ClusterIP" .Values.external }}
  {{- if .Values.external }}
  externalTrafficPolicy: Local
  allocateLoadBalancerNodePorts: false
  {{- end }}
  ports:
  - name: postgres
    port: 5432
  selector:
    cnpg.io/cluster: {{ .Release.Name }}
    role: primary
{{- end }}
