Skip to content

Commit bf122c7

Browse files
add yaml embeds to multi-ns
1 parent a4d80b4 commit bf122c7

File tree

1 file changed

+9
-83
lines changed

1 file changed

+9
-83
lines changed

content/operate/kubernetes/re-clusters/multi-namespace.md

Lines changed: 9 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -26,68 +26,20 @@ Before configuring a multi-namespace deployment, you must have a running [Redis
2626

2727
## Create role and role binding for managed namespaces
2828

29-
Both the operator and the RedisEnterpriseCluster (REC) resource need access to each namespace the REC will manage. For each **managed** namespace, create a `role.yaml` and `role_binding.yaml` file within the managed namespace, as shown in the examples below.
29+
Both the operator and the RedisEnterpriseCluster (REC) resource need access to each namespace the REC will manage. For each **managed** namespace, create a `consumer_role.yaml` and `consumer_role_binding.yaml` file within the managed namespace, as shown in the examples below.
3030

3131
{{<note>}}These will need to be reapplied each time you [upgrade]({{< relref "/operate/kubernetes/upgrade/upgrade-redis-cluster" >}}). {{</note>}}
3232

3333
Replace `<rec-namespace>` with the namespace the REC resides in.
3434
Replace `<service-account-name>` with your own value (defaults to the REC name).
3535

36-
`role.yaml` example:
36+
`consumer_role.yaml` example:
3737

38-
```yaml
39-
kind: Role
40-
apiVersion: rbac.authorization.k8s.io/v1
41-
metadata:
42-
name: redb-role
43-
labels:
44-
app: redis-enterprise
45-
rules:
46-
- apiGroups:
47-
- app.redislabs.com
48-
resources: ["redisenterpriseclusters", "redisenterpriseclusters/status", "redisenterpriseclusters/finalizers",
49-
"redisenterprisedatabases", "redisenterprisedatabases/status", "redisenterprisedatabases/finalizers",
50-
"redisenterpriseremoteclusters", "redisenterpriseremoteclusters/status",
51-
"redisenterpriseremoteclusters/finalizers",
52-
"redisenterpriseactiveactivedatabases", "redisenterpriseactiveactivedatabases/status",
53-
"redisenterpriseactiveactivedatabases/finalizers"]
54-
verbs: ["delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"]
55-
- apiGroups: [""]
56-
resources: ["secrets"]
57-
verbs: ["update", "get", "read", "list", "listallnamespaces", "watch", "watchlist",
58-
"watchlistallnamespaces", "create","patch","replace","delete","deletecollection"]
59-
- apiGroups: [""]
60-
resources: ["endpoints"]
61-
verbs: ["get", "list", "watch"]
62-
- apiGroups: [""]
63-
resources: ["events"]
64-
verbs: ["create"]
65-
- apiGroups: [""]
66-
resources: ["services"]
67-
verbs: ["get", "watch", "list", "update", "patch", "create", "delete"]
68-
```
38+
{{<embed-yaml "k8s/multi-ns_role.md" "consumer_role.yaml">}}
6939

70-
`role_binding.yaml` example:
40+
`consumer_role_binding.yaml` example:
7141

72-
```yaml
73-
kind: RoleBinding
74-
apiVersion: rbac.authorization.k8s.io/v1
75-
metadata:
76-
name: redb-role
77-
labels:
78-
app: redis-enterprise
79-
subjects:
80-
- kind: ServiceAccount
81-
name: redis-enterprise-operator
82-
namespace: <rec-namespace>
83-
- kind: ServiceAccount
84-
name: <service-account-name>
85-
namespace: <rec-namespace>
86-
roleRef:
87-
kind: Role
88-
name: redb-role
89-
apiGroup: rbac.authorization.k8s.io
90-
```
42+
{{<embed-yaml "k8s/multi-ns_role_binding.md" "consumer_role_binding.yaml">}}
9143

9244
{{<note>}}
9345
**Alternative approach**: Instead of creating individual `Role` objects for each namespace, you can create a single `ClusterRole` and bind it with multiple `RoleBinding` objects. This reduces the number of objects and simplifies role management.
@@ -101,8 +53,8 @@ To use this approach:
10153
Apply the files, replacing `<managed-namespace>` with your own values:
10254

10355
```sh
104-
kubectl apply -f role.yaml -n <managed-namespace>
105-
kubectl apply -f role_binding.yaml -n <managed-namespace>
56+
kubectl apply -f consumer_role.yaml -n <managed-namespace>
57+
kubectl apply -f consumer_role_binding.yaml -n <managed-namespace>
10658
```
10759

10860
{{<note>}}
@@ -128,37 +80,11 @@ Only configure the operator to watch a namespace after the namespace is created
12880

12981
`operator_cluster_role.yaml` example:
13082

131-
```yaml
132-
apiVersion: rbac.authorization.k8s.io/v1
133-
kind: ClusterRole
134-
metadata:
135-
name: redis-enterprise-operator-consumer-ns
136-
labels:
137-
app: redis-enterprise
138-
rules:
139-
- apiGroups: [""]
140-
resources: ["namespaces"]
141-
verbs: ["list", "watch"]
142-
```
83+
{{<embed-yaml "k8s/multi-ns_operator_cluster_role.md" "operator_cluster_role.yaml">}}
14384

14485
`operator_cluster_role_binding.yaml` example:
14586

146-
```yaml
147-
kind: ClusterRoleBinding
148-
apiVersion: rbac.authorization.k8s.io/v1
149-
metadata:
150-
name: redis-enterprise-operator-consumer-ns
151-
labels:
152-
app: redis-enterprise
153-
subjects:
154-
- kind: ServiceAccount
155-
name: redis-enterprise-operator
156-
namespace: <rec-namespace>
157-
roleRef:
158-
kind: ClusterRole
159-
name: redis-enterprise-operator-consumer-ns
160-
apiGroup: rbac.authorization.k8s.io
161-
```
87+
{{<embed-yaml "k8s/multi-ns_operator_cluster_role_binding.md" "operator_cluster_role_binding.yaml">}}
16288

16389
2. Apply the files.
16490

0 commit comments

Comments
 (0)