{{- if .Values.rbac.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ include "opencost.fullname" . }}
  labels: {{- include "opencost.labels" . | nindent 4 }}
  {{- with .Values.annotations }}
  annotations: {{- toYaml . | nindent 4 }}
  {{- end }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ include "opencost.fullname" . }}
subjects:
  - kind: ServiceAccount
    name: {{ template "opencost.serviceAccountName" . }}
    namespace: {{ include "opencost.namespace" . }}
{{- end }}
