apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: {{ .Release.Name }}-dashboard-resources
rules:
- apiGroups:
  - cozystack.io
  resources:
  - workloadmonitors
  resourceNames:
  - {{ .Release.Name }}
  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
---
apiVersion: cozystack.io/v1alpha1
kind: WorkloadMonitor
metadata:
  name: {{ $.Release.Name }}
  namespace: {{ $.Release.Namespace }}
spec:
  replicas: 1
  minReplicas: 1
  kind: virtual-machine
  type: virtual-machine
  selector:
    app.kubernetes.io/instance: {{ .Release.Name }}
  version: {{ $.Chart.Version }}
