text: {{- if and .Values.clusterChecksRunner.rbac.create .Values.clusterAgent.enabled .Values.datadog.clusterChecks.enabled .Values.clusterChecksRunner.enabled .Values.clusterChecksRunner.rbac.dedicated -}}
  apiVersion: {{ template "rbac.apiVersion" . }}
  kind: ClusterRoleBinding
  metadata:
    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 }}
    name: {{ template "datadog.fullname" . }}-cluster-checks
  roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: {{ template "datadog.fullname" . }}
  subjects:
    - kind: ServiceAccount
      name: {{ template "datadog.fullname" . }}-cluster-checks
      namespace: {{ .Release.Namespace }}
  ---
  apiVersion: v1
  kind: ServiceAccount
  metadata:
    labels:
      app: "{{ template "datadog.fullname" . }}"
      chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
      heritage: {{ .Release.Service | quote }}
      release: {{ .Release.Name | quote }}
      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 }}
    name: {{ template "datadog.fullname" . }}-cluster-checks
    {{- if .Values.clusterChecksRunner.rbac.serviceAccountAnnotations }}
    annotations: {{ toYaml .Values.clusterChecksRunner.rbac.serviceAccountAnnotations | nindent 4 }}
    {{- end }}
  {{- end -}}
  