How to delete a service account in kubernetes?

Viewed 15811

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
1 Answers

You have to specify the namespace when deleting it:

kubectl delete serviceaccount -n kube-system kubernetes-dashboard
Related