# infrastructure/longhorn/adopt/longhorn-adopt-rbac.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: longhorn-helm-adopt
  namespace: longhorn-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: longhorn-helm-adopt
rules:
  - apiGroups: [""]
    resources:
      - configmaps
      - services
      - serviceaccounts
      - secrets
    verbs: ["get", "list", "watch", "patch", "update"]
  - apiGroups: ["apps"]
    resources:
      - deployments
      - daemonsets
    verbs: ["get", "list", "watch", "patch", "update"]
  - apiGroups: ["batch"]
    resources:
      - jobs
    verbs: ["get", "list", "watch", "patch", "update"]
  - apiGroups: ["rbac.authorization.k8s.io"]
    resources:
      - roles
      - rolebindings
      - clusterroles
      - clusterrolebindings
    verbs: ["get", "list", "watch", "patch", "update"]
  - apiGroups: ["apiextensions.k8s.io"]
    resources:
      - customresourcedefinitions
    verbs: ["get", "list", "watch", "patch", "update"]
  - apiGroups: ["scheduling.k8s.io"]
    resources:
      - priorityclasses
    verbs: ["get", "list", "watch", "patch", "update"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: longhorn-helm-adopt
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: longhorn-helm-adopt
subjects:
  - kind: ServiceAccount
    name: longhorn-helm-adopt
    namespace: longhorn-system
