{{- if .Values.metrics.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ printf "%s-metrics" (include "certmanager.controller.fullname" .) | trunc 63 | trimSuffix "-" }}
  namespace: {{ .Release.Namespace | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: controller
spec:
  type: ClusterIP
  selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
    app.kubernetes.io/component: controller
  ports:
    - name: controller
      port: {{ .Values.controller.containerPort }}
      protocol: TCP
      targetPort: {{ .Values.metrics.serviceMonitor.targetPort }}
{{- end }}
