You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- If you are using Kubernetes native ClusterRoleBinding or RoleBinding for authorization checks on the cluster, with the `kubeconfig` file pointing to the `apiserver` of your cluster for direct access, you can create one mapped to the Azure AD entity (service principal or user) that needs to access this cluster. Example:
- If you are using Kubernetes native ClusterRoleBinding or RoleBinding for authorization checks on the cluster, with the `kubeconfig` file pointing to the `apiserver` of your cluster for direct access, you can create one mapped to the Azure AD entity (service principal or user) that needs to access this cluster. Example:
1. With the `kubeconfig` file pointing to the `apiserver` of your Kubernetes cluster, create a service account in any namespace (the following command creates it in the default namespace):
166
166
167
167
```console
168
-
kubectl create serviceaccount admin-user
168
+
kubectl create serviceaccount demo-user
169
169
```
170
170
171
171
1. Create ClusterRoleBinding or RoleBinding to grant this [service account the appropriate permissions on the cluster](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#kubectl-create-rolebinding). Example:
1. Get the service account's token using the following commands:
177
+
1. Create a service account token:
178
178
179
179
```console
180
-
$SECRET_NAME=(kubectl get serviceaccount admin-user -o jsonpath='{$.secrets[0].name}')
180
+
kubectl apply -f - <<EOF
181
+
apiVersion: v1
182
+
kind: Secret
183
+
metadata:
184
+
name: demo-user-secret
185
+
annotations:
186
+
kubernetes.io/service-account.name: demo-user
187
+
type: kubernetes.io/service-account-token
188
+
EOF
181
189
```
182
190
183
191
```console
184
-
$TOKEN=(kubectl get secret ${SECRET_NAME} -o jsonpath='{$.data.token}' | base64 -d | sed $'s/$/\\\n/g')
192
+
$TOKEN=(kubectl get secret demo-user-secret -o jsonpath='{$.data.token}' | base64 -d | sed $'s/$/\\\n/g')
185
193
```
186
194
187
195
### [Azure PowerShell](#tab/azure-powershell)
188
196
189
197
1. With the `kubeconfig` file pointing to the `apiserver` of your Kubernetes cluster, create a service account in any namespace (the following command creates it in the default namespace):
190
198
191
199
```console
192
-
kubectl create serviceaccount admin-user
200
+
kubectl create serviceaccount demo-user
193
201
```
194
202
195
203
1. Create ClusterRoleBinding or RoleBinding to grant this [service account the appropriate permissions on the cluster](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#kubectl-create-rolebinding). Example:
0 commit comments