apiVersion: v1
kind: Service
metadata:
  name: {{ template "terracotta.fullname" . }}
  labels:
    app: {{ template "terracotta.name" . }}
    chart: {{ template "terracotta.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
  annotations:
    # see https://github.com/kubernetes/kubernetes/issues/39363 , to have dns entries available immediately
    service.alpha.kubernetes.io/tolerate-unready-endpoints: "{{ .Values.tolerateUnreadyEndpoints }}"
spec:
  type: {{ .Values.service.type }}
  {{- if .Values.service.clusterIP }}
  clusterIP: {{ .Values.service.clusterIP }}
  {{- end }}
  ports:
    - name: terracotta-port
      port: {{ .Values.service.terracottaPort }}
    - name: sync-port
      port: {{ .Values.service.syncPort }}
  selector:
    app: {{ template "terracotta.name" . }}
    release: "{{ .Release.Name }}"
