{{- if and .Values.dataCoordinator.enabled .Values.cluster.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ template "milvus.datacoord.fullname" . }}
  labels:
{{ include "milvus.labels" . | indent 4 }}
{{- if .Values.dataCoordinator.service.labels }}
{{ toYaml .Values.dataCoordinator.service.labels | indent 4 }}
{{- end }}
    component: "datacoord"
{{- with .Values.dataCoordinator.service.annotations }}
  annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
  type: ClusterIP
  {{- if .Values.dataCoordinator.service.clusterIP }}
  clusterIP: {{ .Values.dataCoordinator.service.clusterIP }}
  {{- end }}
  ports:
    - name: datacoord
      port: {{ .Values.dataCoordinator.service.port }}
      protocol: TCP
      targetPort: datacoord
    {{- if .Values.metrics.enabled }}
    - name: metrics
      protocol: TCP
      port: 9091
      targetPort: metrics
    {{- end }}
  selector:
{{ include "milvus.matchLabels" . | indent 4 }}
    component: "datacoord"
{{- end }}