RBAC

Role Based Access Control

Step 1: Check the pods

kubectl get pods

Step 2: Create a private key for your user.

cd /etc/kubernetes/pki/
sudo openssl genrsa -out nishanth.key 2048

Step 3: Create a certificate sign request nishanth.csr using the private key you just created

After running the below command, it will ask for details. please provide necessary details.

sudo openssl req -new -key nishanth.key -out nishanth.csr

Step 4: Locate your Kubernetes cluster certificate authority (CA)

cd /etc/kubernetes/pki/

Step 5: Generate the final certificate nishanth.crt by approving the certificate sign request, nishanth.csr, you made earlier

sudo openssl x509 -req -in nishanth.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out nishanth.crt

Save both nishanth.crt and nishanth.key in a safe location. i.e Keep them in a folder from where you can access and have permission on the filesystem

Step 6: Add new credentials for your Kubernetes cluster

kubectl config set-credentials nishanth --client-certificate=nishanth.crt  --client-key=nishanth.key

Step 7: Now use ''nishanth" to check the permissions

Step 8: Create a Role to get the list of pods

Step 09: Apply the Role

Step 10: Apply the role binding

Step 11: Now Verify the Pods

Step 12: Lets try to delete any pod. Be cautious to replace the podname

Step 13: Delete the role file

Step 14: Create a new role file with more permissions

Step 15: Apply the Updated role again

Step 16: Lets Create a new deployment

Step 17: Check the Pods

Step 18: Perform a New Deployment

Step 19: Check the List of Pods

Step 20: Check the Single Pod. Change the pod name in command

Step 21: Delete any of the running pod and verify. Change the pod name in command

Step 22: Delete the Deployment and Verify

Last updated

Was this helpful?