{{- if or .Values.ruler.sidecar.enabled .Values.alertmanager.sidecar.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ template "cortex.fullname" . }}-clusterrolebinding
  labels:
  {{- include "cortex.labels" . | nindent 4 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ template "cortex.fullname" . }}-clusterrole
subjects:
  - kind: ServiceAccount
    name: {{ template "cortex.serviceAccountName" . }}
    namespace: {{ .Release.Namespace }}
{{- end }}
