Can we shutdown the Kubernetes clusters without deleting them?

8/20/2019

I am trying to shutdown kubernet clusters. Is there any method to shutdown clusters without deleting it, We want to start the same cluster after some time.

-- pratik10
cluster-computing
google-cloud-platform
kubernetes

3 Answers

8/20/2019

As you are using GCP, you can change numbers of Nodes to 0. You can do it with many clusters, however please keep in mind that if you are using some special features (Network Load Balancig, Storage) you might be still charged (Cluster is still running but without any nodes). It's good to check billing after 2 days if you did not forget to turn off some features.

To resize number of the Nodes in Cluster:

Via command

gcloud container clusters resize [CLUSTER_NAME] --node-pool [POOL_NAME] \
    --num-nodes [NUM_NODES]

It's described in GCP documentation

Via GCP (browser)

  • On the top left corner (Navigation Menu) > Compute > Kubernetes Engine > Clusters
  • Chose your cluster
  • On the bottom of the site you will have "Node pools". Click on the pool name (probably will be "default-pool")
  • On the "Node pool details" on the top of the site you will have "Edit". Change "Size" to 0.

Later, when you will want to resize nodes you have to do the same steps.

After you will resize nodes to 0 you will be able to Connect to the cluster via Cloud Shell. All pods will be on pending state.

$ kubectl get all --all-namespaces
NAMESPACE     NAME                                          READY   STATUS    RESTARTS   AGE
default       pod/php-apache-84cc7f889b-q8x52               0/1     Pending   0          6d18h
kube-system   pod/event-exporter-v0.2.4-5f88c66fb7-mkfsg    0/2     Pending   0          6d18h
kube-system   pod/fluentd-gcp-scaler-59b7b75cd7-fs7ms       0/1     Pending   0          6d18h
kube-system   pod/heapster-v1.6.0-beta.1-65fc664955-qq52j   0/3     Pending   0          6d18h
kube-system   pod/kube-dns-6987857fdb-mf6b6                 0/4     Pending   0          6d18h
kube-system   pod/kube-dns-6987857fdb-qlk9m                 0/4     Pending   0          6d18h
kube-system   pod/kube-dns-autoscaler-bb58c6784-g2sr4       0/1     Pending   0          6d18h
kube-system   pod/l7-default-backend-fd59995cd-fscg4        0/1     Pending   0          6d18h
kube-system   pod/metrics-server-v0.3.1-57c75779f-59g8s     0/2     Pending   0          6d18h

Hope it help.

-- PjoterS
Source: StackOverflow

8/20/2019

In your case, if you are using GKE, just edit cluster and resize it to 0.

-- FL3SH
Source: StackOverflow

8/20/2019

Yes, you can do that. Follow the below steps

  1. Shut down kubelet on all the nodes
  2. Shut down docker on all the nodes
  3. Shut down etcd if you are running etcd externally as a service
-- P Ekambaram
Source: StackOverflow