{{- if .Values.varnish.enabled -}}
{{- $name := "varnish" -}}
{{- $data := dict "name" $name "Chart" .Chart "Release" .Release "Values" .Values -}}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "api.fullname" . }}-{{ $name }}
  labels:
    {{- include "api.labels" $data | nindent 4 }}
spec:
  type: {{ .Values.varnish.service.type }}
  ports:
    - port: {{ .Values.varnish.service.port }}
      targetPort: http
      protocol: TCP
      name: http
  selector:
    {{- include "api.selectorLabels" $data | nindent 4 }}
{{- end -}}
