Skip to content

Commit 0e95d56

Browse files
authored
Kh add roles example (#10)
* add test service account
1 parent 13277fe commit 0e95d56

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

test-yaml/busy-box.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Pod
33
metadata:
44
name: my-busybox
5-
namespace: default
5+
namespace: psp-test
66
spec:
77
containers:
88
- name: my-busybox-container

test-yaml/roles.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
kind: ServiceAccount
2+
apiVersion: v1
3+
metadata:
4+
name: psp-test-sa
5+
namespace: psp-test
6+
---
7+
kind: Role
8+
apiVersion: rbac.authorization.k8s.io/v1
9+
metadata:
10+
name: pod-creator-role
11+
namespace: psp-test
12+
rules:
13+
- apiGroups: [""]
14+
resources: ["pods"]
15+
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
16+
---
17+
kind: RoleBinding
18+
apiVersion: rbac.authorization.k8s.io/v1
19+
metadata:
20+
name: pod-creator-rolebinding
21+
namespace: psp-test
22+
roleRef:
23+
apiGroup: rbac.authorization.k8s.io
24+
kind: Role
25+
name: pod-creator-role
26+
subjects:
27+
# Example: A specific service account in my-namespace
28+
- kind: ServiceAccount # Omit apiGroup
29+
name: psp-test-sa
30+
namespace: psp-test
31+
---
32+
kind: Role
33+
apiVersion: rbac.authorization.k8s.io/v1
34+
metadata:
35+
name: psp-adopter-role
36+
namespace: psp-test
37+
rules:
38+
- apiGroups: ['policy']
39+
resources: ['podsecuritypolicies']
40+
resourceNames: ['pod-security-policy-test']
41+
verbs: ['use']
42+
---
43+
apiVersion: rbac.authorization.k8s.io/v1
44+
kind: RoleBinding
45+
metadata:
46+
name: psp-adopter-rolebinding
47+
namespace: psp-test
48+
roleRef:
49+
apiGroup: rbac.authorization.k8s.io
50+
kind: Role
51+
name: psp-adopter-role
52+
subjects:
53+
# Example: A specific service account in my-namespace
54+
- kind: ServiceAccount # Omit apiGroup
55+
name: psp-test-sa
56+
namespace: psp-test

0 commit comments

Comments
 (0)