{{- if and .Values.enabled.clusterMode}}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.appName.clusterMode -}}
---
apiVersion: v1
kind: Service
metadata:
  name: {{ $applicationName }}-headless
  namespace: {{ $namespace }}
  labels:
    {{- include "uavcloud-middleware.emqx.labels.standard" . | nindent 4 }}
spec:
  type: ClusterIP
  clusterIP: None
  selector:
    {{- include "uavcloud-middleware.emqx.labels.matchLabels" . | nindent 4 }}
  ports:
    - name: mqtt
      port: {{ .Values.containerPort.mqtt }}
      protocol: TCP
      targetPort: {{ .Values.containerPort.mqtt }}
    - name: mqttssl
      port: {{ .Values.containerPort.mqttssl }}
      protocol: TCP
      targetPort: {{ .Values.containerPort.mqttssl }}
    - name: mgmt
      port: {{ .Values.containerPort.mgmt }}
      protocol: TCP
      targetPort: {{ .Values.containerPort.mgmt }}
    - name: websocket
      port: {{ .Values.containerPort.websocket }}
      protocol: TCP
      targetPort: {{ .Values.containerPort.websocket }}
    - name: wss
      port: {{ .Values.containerPort.wss }}
      protocol: TCP
      targetPort: {{ .Values.containerPort.wss }}
    - name: dashboard
      port: {{ .Values.containerPort.dashboard }}
      protocol: TCP
      targetPort: {{ .Values.containerPort.dashboard }}
    - name: ekka
      port: 4370
      protocol: TCP
      targetPort: 4370
---
{{- end }}
