-
Notifications
You must be signed in to change notification settings - Fork 6
/
rbac.cue
64 lines (61 loc) · 1.73 KB
/
rbac.cue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package tenant
import (
rbacv1 "k8s.io/api/rbac/v1"
)
// This binding grants full access to all objects within the specified namespace.
// With this role, a tenant can't install a Kubernetes CRD controller, but it can use
// any namespaced custom resource if its definition exists.
// Access is denied to any global objects like crds, cluster roles bindings, namespaces, etc.
// To grant the namespace admin role, set 'tenant.spec.role: "namespace-admin"' (default value).
#RoleBinding: rbacv1.#RoleBinding & {
_spec: #TenantSpec
apiVersion: "rbac.authorization.k8s.io/v1"
kind: "RoleBinding"
metadata: {
name: "flux-\(_spec.name)"
namespace: _spec.namespace
labels: _spec.labels
annotations: _spec.annotations
}
roleRef: {
apiGroup: "rbac.authorization.k8s.io"
kind: "ClusterRole"
name: "cluster-admin"
}
subjects: [
{
kind: "User"
name: "flux:\(_spec.namespace):\(_spec.name)"
},
{
kind: "ServiceAccount"
name: "flux-\(_spec.name)"
namespace: _spec.namespace
},
]
}
// This binding grants full access to all objects in the cluster
// including non-namespaced objects like crds, namespaces, etc.
// To grant the cluster admin role, set 'tenant.spec.role: "cluster-admin"'.
#ClusterRoleBinding: rbacv1.#ClusterRoleBinding & {
_spec: #TenantSpec
apiVersion: "rbac.authorization.k8s.io/v1"
kind: "ClusterRoleBinding"
metadata: {
name: "flux-\(_spec.name)"
labels: _spec.labels
annotations: _spec.annotations
}
roleRef: {
apiGroup: "rbac.authorization.k8s.io"
kind: "ClusterRole"
name: "cluster-admin"
}
subjects: [
{
kind: "ServiceAccount"
name: "flux-\(_spec.name)"
namespace: _spec.namespace
},
]
}