{{- if and .Values.starrocksOperator.enabled .Values.global.rbac.create }}
{{- if .Values.starrocksOperator.watchNamespace }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: {{ template "operator.name" . }}-operator
  namespace: {{ template "operator.namespace" . }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: {{ template "operator.name" . }}-operator
subjects:
- kind: ServiceAccount
  name: {{ template  "operator.serviceAccountName" . }}
  namespace: {{ template  "operator.namespace" . }}
{{- end }}
{{- end }}
