# helm_charts_agent-apiservice.yaml
{{- if and .Values.clusterAgent.rbac.create .Values.clusterAgent.enabled .Values.clusterAgent.metricsProvider.enabled -}}
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
  name: v1beta1.external.metrics.k8s.io
  labels:
    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    app.kubernetes.io/name: "{{ template "datadog.fullname" . }}"
    app.kubernetes.io/instance: {{ .Release.Name | quote }}
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
spec:
  service:
    name: {{ template "datadog.fullname" . }}-cluster-agent-metrics-api
    namespace: {{ .Release.Namespace }}
{{- if semverCompare "^1.15-0" .Capabilities.KubeVersion.GitVersion }}
    port: {{ template "clusterAgent.metricsProvider.port" . }}
{{- end }}
  version: v1beta1
  insecureSkipTLSVerify: true
  group: external.metrics.k8s.io
  groupPriorityMinimum: 100
  versionPriority: 100
{{- end -}}