Kubernetes RBAC with serviceaccount for every new user
TAGS:Authentication of new k8s users via serviceaccount with RBAC role
- Configure RBAC on your cluster (pass –authorization-mode=RBAC to kube-apiserver)
- Log via ssh in any Linux machine, install kubectl and jq
ssh vm1 apt update; apt -y install jq curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl chmod +x kubectl mv kubectl /usr/local/bin
- Create kubeconfig with admin rights, test it
mkdir ~/.kube
vim ~/.kube/config
config
kubectl get no
- create adduser.sh file
adduser.sh
chmod +x adduser.sh
- Modify or cut out last section of adduser.sh - part with Role and Rolebinding yaml
- Execute script, create Role and RoleBinding for new user
adduser.sh cooluser kubectl create -f role.yaml kubectl create -f cooluser_role_bond.yaml
sample role sample binding
Written on November 22, 2017