{{- if .Values.enabled }}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.appName -}}
---
apiVersion: v1
kind: Service
metadata:
  name: {{ $applicationName }}
  namespace: {{ $namespace }}
  labels:
    {{- include "uavcloud-middleware.mongo.labels.standard" . | nindent 4 }}
spec:
  type: {{ .Values.global.middlewareService.type }}
  selector:
    {{- include "uavcloud-middleware.mongo.labels.matchLabels" . | nindent 4 }}
  ports:
    - port: 27017
      name: server-27017
      targetPort: 27017
      {{- if eq .Values.global.middlewareService.type "NodePort" }}
      nodePort: {{ .Values.nodePort.mongo }}
      {{- end }}
---
{{- end }}
