{{- if and .Values.hubble.enabled .Values.hubble.metrics.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: hubble-metrics
  namespace: {{ .Release.Namespace }}
  labels:
    k8s-app: hubble
  annotations:
    {{- with .Values.hubble.metrics.serviceAnnotations }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
    prometheus.io/scrape: "true"
    prometheus.io/port: {{ .Values.hubble.metrics.port | quote }}
spec:
  clusterIP: None
  type: ClusterIP
  ports:
  - name: hubble-metrics
    port: {{ .Values.hubble.metrics.port }}
    protocol: TCP
    targetPort: hubble-metrics
  selector:
    k8s-app: cilium
{{- end }}

{{- if and .Values.hubble.enabled .Values.hubble.metrics.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: hubble-metrics
  namespace: {{ .Release.Namespace }}
  labels:
    k8s-app: hubble
  annotations:
    {{- with .Values.hubble.metrics.serviceAnnotations }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
    {{- if not .Values.hubble.metrics.serviceMonitor.enabled }}
    prometheus.io/scrape: "true"
    prometheus.io/port: {{ .Values.hubble.metrics.port | quote }}
    {{- end }}
spec:
  clusterIP: None
  type: ClusterIP
  ports:
  - name: hubble-metrics
    port: {{ .Values.hubble.metrics.port }}
    protocol: TCP
    targetPort: hubble-metrics
  selector:
    k8s-app: cilium
{{- end }}

Fix Hubble Service when ServiceMonitor is being used
helm: Fix Hubble Service when ServiceMonitor is being used

Hubble Service manifest includes "prometheus.io" annotations even when
ServiceMonitor manifest is being used. This patch makes the Services
different when ServiceMonitor is used or not, in the same way than in
other components.

Signed-off-by: Juha Tiensyrjä <b58c5a58db16fbf480f6b0f098cba4532222df6d@gmail.com>
