{{- if and .Values.rbac.create .Values.clusterAgent.enabled .Values.clusterAgent.metricsProvider.enabled -}}
apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
  name: v1beta1.external.metrics.k8s.io
  labels:
    app: "{{ template "datadog.fullname" . }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    heritage: {{ .Release.Service | quote }}
    release: {{ .Release.Name | quote }}
spec:
  service:
    name: {{ template "datadog.clusterAgent.fullname" . }}-metrics-api
    namespace: {{ .Release.Namespace }}
  version: v1beta1
  insecureSkipTLSVerify: true
  group: external.metrics.k8s.io
  groupPriorityMinimum: 100
  versionPriority: 100
  priority: 100
{{- end -}}
