apiVersion: v1
kind: Service
metadata:
  name: {{ include "dragonfly.fullname" . }}
  namespace: {{ .Release.Namespace }}
  {{- with .Values.service.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
  labels:
    {{- with .Values.service.labels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
    {{- include "dragonfly.labels" . | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  {{- if and (eq .Values.service.type "LoadBalancer") (ne .Values.service.loadBalancerIP "") }}
  loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  {{- end }}
  {{- if and (eq .Values.service.type "ClusterIP") (ne .Values.service.clusterIP "") }}
  clusterIP: {{ .Values.service.clusterIP }}
  {{- end }}
  ports:
    - port: {{ .Values.service.port }}
      targetPort: dragonfly
      protocol: TCP
      name: dragonfly
  selector:
    {{- include "dragonfly.selectorLabels" . | nindent 4 }}
