{{- if .Values.metrics.service.create }}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "app.fullname" . }}-metrics
  namespace: {{ .Release.Namespace }}
  labels:
    app.kubernetes.io/name: {{ include "app.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
    k8s-app: {{ include "app.name" . }}
    helm.sh/chart: {{ include "chart.name-version" . }}
    control-plane: controller
spec:
  selector:
    app.kubernetes.io/name: {{ include "app.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: Helm
    k8s-app: {{ include "app.name" . }}
{{- range $key, $value := .Values.deployment.labels }}
    {{ $key }}: {{ $value | quote }}
{{- end }}
  type: {{ .Values.metrics.service.type }}
  ports:
  - name: metricsport
    port: 8080
    targetPort: 8080
    protocol: TCP
{{- end }}