-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccess.yaml
159 lines (157 loc) · 3.56 KB
/
access.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#https://docs.portworx.com/portworx-backup-on-prem/configure/namespace-access
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: user1
namespace: ns1
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: user1-clusterrole
rules:
- apiGroups: ["*"]
resources: ["namespaces", "clusterrolebindings", "persistentvolumes", "clusterroles", "nodes", "storageclasses"]
verbs: ["get", "list", "watch", "create"]
- apiGroups: ["stork.libopenstorage.org"]
resources: ["schedulepolicies"]
verbs: ["create", "delete", "deletecollection", "get", "list", "patch", "update", "watch"]
- apiGroups: ["stork.libopenstorage.org"] # for controller support
resources: ["*"]
verbs: ["list", "get", "watch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotclasses"]
verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: user1-clusterrolebinding
subjects:
- kind: ServiceAccount
name: user1
namespace: ns1
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: user1-clusterrole
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: ns1-role
namespace: ns1
rules:
- apiGroups: ["", "extensions", "apps"]
resources: ["*"]
verbs: ["*"]
- apiGroups: ["batch"]
resources:
- jobs
- cronjobs
verbs: ["*"]
- apiGroups:
- stork.libopenstorage.org
resources: ["*"]
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: ns1-rolebinding
namespace: ns1
subjects:
- kind: ServiceAccount
name: user1
namespace: ns1
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: ns1-role
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: ks-role
namespace: kube-system
rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: ks-rolebinding
namespace: kube-system
subjects:
- kind: ServiceAccount
name: user1
namespace: ns1
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: ks-role
---
apiVersion: v1
kind: Secret
metadata:
name: user1-token
namespace: ns1
annotations:
kubernetes.io/service-account.name: user1
type: kubernetes.io/service-account-token
---
#kubectl get secret user1-token -n ns1 -o "jsonpath={.data.token}" | base64 -d
#kubectl get secret user1-token -n ns1 -o "jsonpath={.data['ca\.crt']}"
---
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: <certificate>
server: https://<cluster-IP>:6443
name: cluster.local
contexts:
- context:
cluster: cluster.local
namespace: <namespace-name>
user: <service-account-name>
name: <service-account>@cluster.local
current-context: <service-account>@cluster.local
kind: Config
preferences: {}
users:
- name: <service-account>
user:
token: <service-account-token>
client-key-data: <certificate>
---
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: LS0tLSJQ0FURS0tLS0tCTkJnq..................aTXHWlFBYU5aTUZjd0==
server: https://x.x.x.x:6443
name: cluster.local
contexts:
- context:
cluster: cluster.local
namespace: ns1
user: user1
name: [email protected]
current-context: [email protected]
kind: Config
preferences: {}
users:
- name: user1
user:
token: ABgHtLSJQ0FURSOpha0tCTkJnq..................aTXHWlFBYU5aTUZjd0
client-key-data: LS0tLSJQ0FURS0tLS0tCTkJnq..................aTXHWlFBYU5aTUZjd0==