Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete a service account in kubernetes?

Tags:

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
like image 409
rgaut Avatar asked Sep 13 '18 23:09

rgaut


People also ask

How do I remove a service from Kubernetes?

You can delete a StatefulSet in the same way you delete other resources in Kubernetes: use the kubectl delete command, and specify the StatefulSet either by file or by name. You may need to delete the associated headless service separately after the StatefulSet itself is deleted.

How do I delete a pods and services in Kubernetes?

To delete the pod you have created, just run kubectl delete pod nginx . Be sure to confirm the name of the pod you want to delete before pressing Enter. If you have completed the task of deleting the pod successfully, pod nginx deleted will appear in the terminal.

What is the service account in Kubernetes?

Kubernetes service accounts are Kubernetes resources, created and managed using the Kubernetes API, meant to be used by in-cluster Kubernetes-created entities, such as Pods, to authenticate to the Kubernetes API server or external services.


1 Answers

You have to specify the namespace when deleting it:

kubectl delete serviceaccount -n kube-system kubernetes-dashboard
like image 81
coderanger Avatar answered Sep 22 '22 17:09

coderanger