apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: {{ .Release.Name }}-dashboard-resources
rules:
- apiGroups:
  - ""
  resources:
  - services
  resourceNames:
  - rfs-{{ .Release.Name }}
  - rfrm-{{ .Release.Name }}
  - rfrs-{{ .Release.Name }}
  - "{{ .Release.Name }}-external-lb"
  verbs: ["get", "list", "watch"]
- apiGroups:
  - ""
  resources:
  - secrets
  resourceNames:
  - "{{ .Release.Name }}-auth"
  verbs: ["get", "list", "watch"]
- apiGroups:
  - cozystack.io
  resources:
  - workloadmonitors
  resourceNames:
  - {{ .Release.Name }}-redis
  - {{ .Release.Name }}-sentinel
  verbs: ["get", "list", "watch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: {{ .Release.Name }}-dashboard-resources
subjects:
{{ include "cozy-lib.rbac.subjectsForTenantAndAccessLevel" (list "use" .Release.Namespace) }}
roleRef:
  kind: Role
  name: {{ .Release.Name }}-dashboard-resources
  apiGroup: rbac.authorization.k8s.io
