apiVersion: v1
kind: Service
metadata:
  name: {{ include "databasus.fullname" . }}-service
  namespace: {{ include "databasus.namespace" . }}
  labels:
    {{- include "databasus.labels" . | nindent 4 }}
  {{- with .Values.service.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  type: {{ .Values.service.type }}
  ports:
    - port: {{ .Values.service.port }}
      targetPort: {{ .Values.service.targetPort }}
      protocol: TCP
      name: http
  selector:
    {{- include "databasus.selectorLabels" . | nindent 4 }}
---
{{- if .Values.service.headless.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "databasus.fullname" . }}-headless
  namespace: {{ include "databasus.namespace" . }}
  labels:
    {{- include "databasus.labels" . | nindent 4 }}
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - port: {{ .Values.service.port }}
      targetPort: {{ .Values.service.targetPort }}
      protocol: TCP
      name: http
  selector:
    {{- include "databasus.selectorLabels" . | nindent 4 }}
{{- end }}
