forked from quiccklabs/Labs_solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Implementing Role-Based Access Control with Google Kubernetes Engine
99 lines (32 loc) · 1.81 KB
/
Implementing Role-Based Access Control with Google Kubernetes Engine
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
export USER1=
export USER2=
export my_zone=us-central1-a
export my_cluster=standard-cluster-1
source <(kubectl completion bash)
gcloud container clusters get-credentials $my_cluster --zone $my_zone
git clone https://github.com/GoogleCloudPlatform/training-data-analyst
ln -s ~/training-data-analyst/courses/ak8s/v1.1 ~/ak8s
cd ~/ak8s/RBAC/
kubectl create -f ./my-namespace.yaml
kubectl apply -f ./my-pod.yaml --namespace=production
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user $USER1
kubectl apply -f pod-reader-role.yaml
sed -i "s/\[USERNAME_2_EMAIL\]/${USER2}/" username2-editor-binding.yaml
------------------------------------------------------------------------------------------------------------------------------------------------------
LOGIN -> USERNAME_2
export my_zone=us-central1-a
export my_cluster=standard-cluster-1
source <(kubectl completion bash)
gcloud container clusters get-credentials $my_cluster --zone $my_zone
git clone https://github.com/GoogleCloudPlatform/training-data-analyst
ln -s ~/training-data-analyst/courses/ak8s/v1.1 ~/ak8s
cd ~/ak8s/RBAC/
kubectl apply -f ./production-pod.yaml
------------------------------------------------------------------------------------------------------------------------------------------------------
LOGIN -> USER_NAME_1
kubectl apply -f username2-editor-binding.yaml
kubectl get rolebinding --namespace production
------------------------------------------------------------------------------------------------------------------------------------------------------
LOGIN -> USER_NAME_2
kubectl apply -f ./production-pod.yaml
------------------------------------------------------------------------------------------------------------------------------------------------------