How to delete a service account in kubernetes?

9/13/2018

By mistake I created a service account to give admin permission for dashboard. But now I am unable to delete it.

The reason I want to get rid of that service account is if I follow the steps here https://github.com/kubernetes/dashboard. When I jump to the URL it doesn't ask for config/token anymore.

$ kubectl get serviceaccount --all-namespaces | grep dashboard

NAMESPACE     NAME                   SECRETS   AGE

kube-system   kubernetes-dashboard   1         44m

$ kubectl delete serviceaccount kubernetes-dashboard

Error from server (NotFound): serviceaccounts "kubernetes-dashboard" not found
-- rgaut
kubernetes

1 Answer

9/14/2018

You have to specify the namespace when deleting it:

kubectl delete serviceaccount -n kube-system kubernetes-dashboard
-- coderanger
Source: StackOverflow