-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsa.yaml
65 lines (64 loc) · 1.28 KB
/
sa.yaml
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
65
#Create Service Accounts
#New SA - cluster level
apiVersion: v1
kind: ServiceAccount
metadata:
name: read-sa
---
#New SA - ns level
apiVersion: v1
kind: ServiceAccount
metadata:
name: read-sa-ns
---
#New Role - cluster level
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: read-only-clu
rules:
- apiGroups: ["", "extensions", "apps"]
resources: ["pods"]
verbs: ["get", "list", "watch"]
---
#New Role - ns level
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: read-only-ns
namespace: ns1
rules:
- apiGroups: ["", "extensions", "apps"]
resources: ["pods"]
verbs: ["get", "list", "watch"]
---
#Binding the role to the sa - cluster
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: read-cluster-pods
subjects:
- kind: ServiceAccount
name: read-sa
apiGroup: ""
namespace: default
roleRef:
kind: ClusterRole
name: read-only-clu
apiGroup: rbac.authorization.k8s.io
---
#Binding the role to the sa -NS1
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-ns1-pods
namespace: ns1
subjects:
- kind: ServiceAccount
name: read-sa-ns
apiGroup: ""
namespace: default
roleRef:
kind: Role
name: read-only-ns
apiGroup: rbac.authorization.k8s.io