How to delete kubernetes dashboard ui pod using kubectl

9/6/2019

I installed kubernetes dashboard ui , but the status is aways pending. Now I want to delete the pending pod . Query current pod:

[root@iZuf63refzweg1d9dh94t8Z ~]# kubectl get pods --all-namespaces
NAMESPACE     NAME                                    READY   STATUS    RESTARTS   AGE
kube-system   kubernetes-dashboard-7d75c474bb-b2lwd   0/1     Pending   0          8d

now I am trying to delete pod:

[root@iZuf63refzweg1d9dh94t8Z ~]# kubectl delete pod kubernetes-dashboard-7d75c474bb-b2lwd
Error from server (NotFound): pods "kubernetes-dashboard-7d75c474bb-b2lwd" not found

how to delete kubernetes dashboard pod?

-- Dolphin
kubernetes

2 Answers

9/6/2019

You should either specify the namespace with your kubectl delete command or set the namespace context before executing the command.

kubectl config set-context --current --namespace=kube-system
kubectl delete pod kubernetes-dashboard-7d75c474bb-b2lwd
-- Charlie
Source: StackOverflow

9/6/2019

Unless you've previously specified it, kubectl operations default to being performed against the default namespace. You don't have a Pod called kubectl delete pod kubernetes-dashboard-7d75c474bb-b2lwd in the default namespace, but as you see in the kubectl get pod --all-namespaces output you do have it in the kube-system namespace. So, instead, do:

kubectl delete pod kubernetes-dashboard-7d75c474bb-b2lwd --namespace=kube-system
-- Amit Kumar Gupta
Source: StackOverflow