Skip to content

Commit 6c6165d

Browse files
committed
Enable copying role and clusterRole snippets
1 parent 5f71889 commit 6c6165d

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

content/en/docs/reference/access-authn-authz/rbac.md

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,7 @@ a role cluster-wide, use a ClusterRole.
7878
Here's an example Role in the "default" namespace that can be used to grant read access to
7979
{{< glossary_tooltip text="pods" term_id="pod" >}}:
8080

81-
```yaml
82-
apiVersion: rbac.authorization.k8s.io/v1
83-
kind: Role
84-
metadata:
85-
namespace: default
86-
name: pod-reader
87-
rules:
88-
- apiGroups: [""] # "" indicates the core API group
89-
resources: ["pods"]
90-
verbs: ["get", "watch", "list"]
91-
```
81+
{{% code_sample file="access/simple-role.yaml" %}}
9282

9383
#### ClusterRole example
9484

@@ -106,20 +96,7 @@ Here is an example of a ClusterRole that can be used to grant read access to
10696
{{< glossary_tooltip text="secrets" term_id="secret" >}} in any particular namespace,
10797
or across all namespaces (depending on how it is [bound](#rolebinding-and-clusterrolebinding)):
10898

109-
```yaml
110-
apiVersion: rbac.authorization.k8s.io/v1
111-
kind: ClusterRole
112-
metadata:
113-
# "namespace" omitted since ClusterRoles are not namespaced
114-
name: secret-reader
115-
rules:
116-
- apiGroups: [""]
117-
#
118-
# at the HTTP level, the name of the resource for accessing Secret
119-
# objects is "secrets"
120-
resources: ["secrets"]
121-
verbs: ["get", "watch", "list"]
122-
```
99+
{{% code_sample file="access/simple-clusterrole.yaml" %}}
123100

124101
The name of a Role or a ClusterRole object must be a valid
125102
[path segment name](/docs/concepts/overview/working-with-objects/names#path-segment-names).
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
# "namespace" omitted since ClusterRoles are not namespaced
5+
name: secret-reader
6+
rules:
7+
- apiGroups: [""]
8+
#
9+
# at the HTTP level, the name of the resource for accessing Secret
10+
# objects is "secrets"
11+
resources: ["secrets"]
12+
verbs: ["get", "watch", "list"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
namespace: default
5+
name: pod-reader
6+
rules:
7+
- apiGroups: [""] # "" indicates the core API group
8+
resources: ["pods"]
9+
verbs: ["get", "watch", "list"]

0 commit comments

Comments
 (0)