{{- if and .Values.query.enabled .Values.query.serviceGrpc.additionalHeadless }}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "common.names.fullname" . }}-query-grpc-headless
  namespace: {{ .Release.Namespace | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: query
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  annotations:
    {{- if .Values.commonAnnotations }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
    {{- end }}
    {{- if .Values.query.serviceGrpc.annotations }}
    {{- include "common.tplvalues.render" (dict "value" .Values.query.serviceGrpc.annotations "context" $) | nindent 4 }}
    {{- end }}
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - port: {{ .Values.query.serviceGrpc.ports.grpc }}
      targetPort: grpc
      protocol: TCP
      name: grpc
    {{- if .Values.query.serviceGrpc.extraPorts }}
    {{- include "common.tplvalues.render" (dict "value" .Values.query.serviceGrpc.extraPorts "context" $) | nindent 4 }}
    {{- end }}
  selector:
    {{- if .Values.query.serviceGrpc.labelSelectorsOverride }}
    {{- include "common.tplvalues.render" (dict "value" .Values.query.serviceGrpc.labelSelectorsOverride "context" $) | nindent 4 }}
    {{- else }}
    {{- include "common.labels.matchLabels" . | nindent 4 }}
    app.kubernetes.io/component: query
    {{- end }}
{{- end }}
