For default service account I have creating clusterrolebinding for cluster role=cluster-admin
using below kubectl command
kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=rbac-test:default
cluster-admin role is bind to default service account.
How to unbind it again from service account?
When you run your kubectl
command it creates the following object:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
creationTimestamp: null
name: add-on-cluster-admin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: default
namespace: rbac-test
You should be able to just delete that object:
kubectl delete clusterrolebinding add-on-cluster-admin