I've created a Kubernetes deployment. However, there seem to be additional pods running - that I'm hoping to be able to delete the unnecessary ones.
I see no need to run the dashboard container. I'd like to remove it to free up CPU resources.
How can I disable this container from starting up? Preferably from the deployment config.
Essentially the following pod:
kubectl get pods --all-namespaces | grep "dashboard" kube-system kubernetes-dashboard-490794276-sb6qs 1/1 Running 1 3d
Additional information:
Output of kubectl --namespace kube-system get deployment
:
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE heapster-v1.3.0 1 1 1 1 3d kube-dns 2 2 2 2 3d kube-dns-autoscaler 1 1 1 1 3d kubernetes-dashboard 1 1 1 1 11m l7-default-backend 1 1 1 1 3d
Output of kubectl --namespace kube-system get rs
:
NAME DESIRED CURRENT READY AGE heapster-v1.3.0-191291410 1 1 1 3d heapster-v1.3.0-3272732411 0 0 0 3d heapster-v1.3.0-3742215525 0 0 0 3d kube-dns-1829567597 2 2 2 3d kube-dns-autoscaler-2501648610 1 1 1 3d kubernetes-dashboard-490794276 1 1 1 12m l7-default-backend-3574702981 1 1 1 3d
The simplest method of deleting any resource in Kubernetes is to use the specific manifest file used to create it. With the manifest file on hand, we can use the kubectl delete command with the -f flag. The manifest file contains all of the information to target a specific resource.
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.
To have a clean removal you must to delete a lot of objects. Overtime removing the dashboard has been a common problem, so you can now do this:
kubectl delete -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended.yaml
If you don't want to do a blind thing and you want to know what are you removing just try to execute this:
kubectl get secret,sa,role,rolebinding,services,deployments --namespace=kube-system | grep dashboard
If the output is empty, just double check your dashboard namespace's with the command
kubectl get namespaces
The dashboard is stored in a separate namespace and, depending of your context, the dashboard can be not always in the same namespace. If you want have a deeper look start trying with kubernetes-dashboard
or kube-system
and always specify the namespace while callin kubectl
.
UPDATE MAY 2020:
Thanks to Lee Richardson for his comment ;)
They have changed the organisation of the files in the repo and as well the command on Kubernetes manual, so the new kubectl delete
command needs to be:
kubectl delete -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended.yaml
ORIGINAL POST:
As said before, you can delete the deployment to remove the pods too, running this:
kubectl delete deployment kubernetes-dashboard --namespace=kube-system
But, if you want to clean all the dashboard related things, you can simply execute the delete command K8s cluster file based in the official Kubernetes manual:
kubectl delete -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With