Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes - how to tear down cluster?

Tags:

kubernetes

I've been trying to shut down kubernetes cluster , but I couldn't managed to do it.

When I type

kubectl cluster-info

I can see that my cluster is still running.

I tried commands like running script

kube-down.sh

but it didn't work.

I deleted all pods. How can I shut it down ?

like image 387
Mont Avatar asked Dec 11 '16 22:12

Mont


People also ask

How do you take down a Kubernetes cluster?

Stopping the Kubernetes clusterStop all worker nodes, simultaneously or individually. After all the worker nodes are shut down, shut down the Kubernetes master node. Note: If the NFS server is on a different host than the Kubernetes master, you can shut down the Kubernetes master when you shut down the worker nodes.

How do I destroy Kubernetes deployment?

Destroy Pod The action of deleting the pod is simple. 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.

How do I remove a clustered Kubernetes node?

To remove a Kubernetes Node:Log in to the Kubernetes Node that you want to remove. Log in to the Salt Master node. Log in to any Kubernetes Master node. Wait until the workloads are gracefully deleted and the Kubernetes Node is removed.

How do I remove objects from Kubernetes?

You can use the delete command to delete an object from a cluster: delete <type>/<name>


2 Answers

The tear down section of the official documentation says:

To undo what kubeadm did, you should first drain the node and make sure that the node is empty before shutting it down.

Talking to the master with the appropriate credentials, run:

kubectl drain <node name> --delete-local-data --force --ignore-daemonsets 
kubectl delete node <node name>

Then, on the node being removed, reset all kubeadm installed state:

kubeadm reset
like image 92
sajjadG Avatar answered Oct 04 '22 15:10

sajjadG


You cannot use kubectl stop command as it has been deprecated. If you have created pods using a yaml file, I suggest you use kubectl delete -f <filename>.yml to stop any running pod.

You can also delete service associated with running pods by using the following command:

# Delete pods and services with same names "baz" and "foo"
kubectl delete pod,service baz foo
like image 20
aftab kotwal Avatar answered Oct 04 '22 16:10

aftab kotwal