apiVersion: v1
kind: Namespace
metadata:
  name: backup
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: backupsession-creator
  namespace: backup
  labels:
    app: backupsession-creator
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: backup-listener
  labels:
    app: backup-listener
rules:
  - apiGroups: ["formol.desmojim.fr"]
    resources: ["backupsessions", "backupconfigurations"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["formol.desmojim.fr"]
    resources: ["backupsessions/status"]
    verbs: ["update"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: backupsession-creator
  labels:
    app: backupsession-creator
rules:
  - apiGroups: ["formol.desmojim.fr"]
    resources: ["backupsessions"]
    verbs: ["get", "list", "create", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: backupsession-creator
  labels:
    app: backupsession-creator
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: backupsession-creator
subjects:
  - name: backupsession-creator
    namespace: backup
    kind: ServiceAccount

---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: backup-listener
  labels:
    app: backup-listener
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: backup-listener
subjects:
  - name: default
    namespace: default
    kind: ServiceAccount

