-
Notifications
You must be signed in to change notification settings - Fork 214
/
Copy pathnamesspace-role-rolebinding-deployment
63 lines (61 loc) · 1.38 KB
/
namesspace-role-rolebinding-deployment
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
...
apiVersion: v1
kind: Namespace
metadata:
name: mynamespace
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: developer-acces
namespace: mynamespace
rules:
- apiGroups: [""] #it indicate the API group
resources: ["pod"]
verbs: ["get","watch","list","create"]
- apiGroups: ["","extensions","apps"]
resources: ["deployment"]
verbs: ["get","list","watch","create","delete"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: developer-RoleBinding
namespace: mynamespace
subjects:
- kind: User
name: peter
namespace: mynamespace
apiGroup: rbac.authorization.k8s.io
- kind: User
name: sonja
namespace: mynamespace
apiGroup: rbac.authorization.k8s.io
roleRef: #specific the binding to a role/Clusterrole
kind: Role
name: developer-access
apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: mynamespace
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: k8s-demo
image: nginx
ports:
- name: nginx-port
containerPort: 8080