gke setting up kubernetes rbac for a user
To configure RBAC capabilities for a gke cluster, we need to enable this feature. This allow the user or principal to grant permission what he/she can do or cannot do in a cluster.
And you can see this in the IAM portal :-
Next, let's connect to our cluster and create our namespace. The we will create role and rolebinding using the following script:
Creating namespace
kubectl create namespace team-a
Creating role.yaml
Creating rolebinding
Apply this 2 files:-
kubectl apply -f role-team-a-dev.yaml
kubectl apply -f rolebinding-team-a-dev.yaml
# Should be allowed
kubectl auth can-i create pods -n team-a --as=alice@example.com
kubectl auth can-i create virtualservices.networking.istio.io -n team-a --as=alice@example.com (only if you have enabled service mesh in your gke cluster)
# Should be denied (different namespace, or no binding)
kubectl auth can-i create pods -n team-b --as=alice@example.com
kubectl auth can-i delete namespaces --as=alice@example.com

Comments