apiVersion: v1
kind: Service
metadata:
  name: {{ include "linkace.fullname" . }}
  labels:
    {{- include "linkace.labels" . | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  ports:
    - port: {{ .Values.service.port }}
      targetPort: http
      protocol: TCP
      name: http
  selector:
    {{- include "linkace.selectorLabels" . | nindent 4 }}

{{- if .Values.database.enabled }}
---
apiVersion: v1
kind: Service
metadata:
  name: {{ include "linkace.fullname" . }}-mariadb
  labels:
    {{- include "linkace.labels" . | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  ports:
    - port: {{ .Values.database.port }}
      targetPort: mariadb
      protocol: TCP
      name: mariadb
  selector:
    {{- include "linkace.selectorLabels" . | nindent 4 }}
{{- end }}

{{- if .Values.redis.enabled }}
---
apiVersion: v1
kind: Service
metadata:
  name: {{ include "linkace.fullname" . }}-redis
  labels:
    {{- include "linkace.labels" . | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  ports:
    - port: {{ .Values.redis.port }}
      targetPort: redis
      protocol: TCP
      name: redis
  selector:
    {{- include "linkace.selectorLabels" . | nindent 4 }}
{{- end }}
