You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: site/content/docs/main/rbac.md
+50-5Lines changed: 50 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -9,9 +9,9 @@ By default Velero runs with an RBAC policy of ClusterRole `cluster-admin`. This
9
9
10
10
For more information about RBAC and access control generally in Kubernetes, see the Kubernetes documentation about [access control][1], [managing service accounts][2], and [RBAC authorization][3].
11
11
12
-
## Set up Roles and RoleBindings
12
+
## Set up with restricted RBAC permissions
13
13
14
-
Here's a sample Role and RoleBinding pair.
14
+
Here's a sample of restricted permission setting.
15
15
16
16
```yaml
17
17
apiVersion: rbac.authorization.k8s.io/v1
@@ -28,23 +28,68 @@ rules:
28
28
- "*"
29
29
resources:
30
30
- "*"
31
-
```
32
-
33
-
```yaml
31
+
---
34
32
apiVersion: rbac.authorization.k8s.io/v1
35
33
kind: RoleBinding
36
34
metadata:
37
35
name: ROLEBINDING_NAME_HERE
36
+
namespace: YOUR_NAMESPACE_HERE
38
37
subjects:
39
38
- kind: ServiceAccount
40
39
name: YOUR_SERVICEACCOUNT_HERE
41
40
roleRef:
42
41
kind: Role
43
42
name: ROLE_NAME_HERE
44
43
apiGroup: rbac.authorization.k8s.io
44
+
---
45
+
apiVersion: rbac.authorization.k8s.io/v1
46
+
kind: ClusterRole
47
+
metadata:
48
+
name: velero-clusterrole
49
+
rules:
50
+
- apiGroups:
51
+
- ""
52
+
resources:
53
+
- persistentvolumes
54
+
- namespaces
55
+
verbs:
56
+
- '*'
57
+
- apiGroups:
58
+
- '*'
59
+
resources:
60
+
- '*'
61
+
verbs:
62
+
- list
63
+
- apiGroups:
64
+
- 'apiextensions.k8s.io'
65
+
resources:
66
+
- 'customresourcedefinitions'
67
+
verbs:
68
+
- get
69
+
---
70
+
apiVersion: rbac.authorization.k8s.io/v1
71
+
kind: ClusterRoleBinding
72
+
metadata:
73
+
name: velero-clusterrolebinding
74
+
roleRef:
75
+
apiGroup: rbac.authorization.k8s.io
76
+
kind: ClusterRole
77
+
name: velero-clusterrole
78
+
subjects:
79
+
- kind: ServiceAccount
80
+
name: YOUR_SERVICEACCOUNT_HERE
81
+
namespace: YOUR_NAMESPACE_HERE
45
82
```
46
83
84
+
You can add more permissions into the `Role` setting according to the need.
85
+
`velero-clusterrole`ClusterRole is verified to work in most cases.
86
+
`Namespaces`resource permission is needed to create namespace during restore. If you don't need that, the `create` permission can be removed, but `list` and `get` permissions of `Namespaces` resource is still needed, because Velero needs to know whether the namespace it's assigned exists in the cluster.
87
+
`PersistentVolumes`resource permission is needed for back up and restore volumes. If that is not needed, it can be removed too.
88
+
`CustomResourceDefinitions`resource permission is needed to backup CR instances' CRD. It's better to keep them.
89
+
It's better to have the `list` permission for all resources, because Velero needs to read some resources during backup, for example, `ClusterRoles` is listed for backing `ServiceAccount` up, and `VolumeSnapshotContent` for CSI `PersistentVolumeClaim`. If you just enable `list` permissions for the resources you want to back up and restore, it's possible that backup or restore end with failure.
0 commit comments