EMK - Hibernate and wake up a Kubernetes cluster
Estimated time to read: 5 minutes
In this tutorial you learn how to hibernate and wake up your Kubernetes cluster through the GUI, kubectl or Terraform.
Be aware that using the "Hibernation" feature will shut down the following EMK cluster components:
- Workloads
- Worker Nodes of the EMK Cluster
Remaining costs
However, floating IP addresses, load balancers, and persistent volumes remain active and continue to incur charges, and the control plane will still generate costs even while hibernated.
It is possible to automate the hibernation and wake up process for your cluster, see cluster hibernation schedules.
Hibernate a cluster
Hibernate an EMK Cluster is straightforward.
Navigate to the EMK Cluster overview in the Fuga dashboard
Here you can find an overview of all your clusters. Click on the three dots "..." and select "Hibernate cluster". A form will pop up with the request if you want to set hibernation for your cluster. Click on hibernate cluster now
.
Requirements:
- Kubectl, installation instructions can be found here.
- Service Account (SA), how to get one; See here.
First list your clusters.
% export KUBECONFIG=emk-sa-kubeconfig.yaml
% kubectl get shoots
NAME K8S VERSION HIBERNATION LAST OPERATION STATUS AGE
my-cluster 1.28.9 Awake Reconcile Succeeded (100%) healthy 42d
To hibernate your cluster with kubectl use the following command:
kubectl patch shoot my-cluster -p '{"spec":{"hibernation":{"enabled": true}}}'
shoot.core.gardener.cloud/my-cluster patched
Now that your cluster is getting hibernated, you can check the status of the hibernation process by listing your clusters.
Requirements:
- Terraform, installation instructions can be found here.
- Service Account (SA), how to get one; See here.
This Terraform guide assumes the creation of clusters through our creation tutorial; see here.
To hibernate the cluster it is required to set the value spec.hibernation.enabled
to true
in the cluster.yaml
configuration:
Run terraform plan
and terraform apply
.
❯ terraform apply
kubectl_manifest.my_first_cluster: Refreshing state... [id=/apis/core.gardener.cloud/v1beta1/namespaces/ garden-thomas/shoots/my-cluster]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# kubectl_manifest.my_first_cluster will be updated in-place
~ resource "kubectl_manifest" "my_first_cluster" {
id = "/apis/core.gardener.cloud/v1beta1/namespaces/garden-thomas/shoots/my-cluster"
name = "my-cluster"
~ yaml_body = (sensitive value)
~ yaml_body_parsed = <<-EOT
apiVersion: core.gardener.cloud/v1beta1
kind: Shoot
spec:
+ hibernation:
+ enabled: "true"
name: my-cluster
namespace: garden-thomas
spec:
.............
EOT
# (13 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
kubectl_manifest.my_first_cluster: Modifying... [id=/apis/core.gardener.cloud/v1beta1/namespaces/ garden-thomas/shoots/my-cluster]
kubectl_manifest.my_first_cluster: Modifications complete after 0s [id=/apis/core.gardener.cloud/v1beta1/ namespaces/garden-thomas/shoots/my-cluster]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
The cluster will now be hibernated, the process for hibernation can take some time.
Wake up a cluster
Waking up an EMK Cluster is straightforward.
Navigate to the EMK Cluster overview in the Fuga dashboard
Here you can find an overview of all your clusters. Click on the three dots "..." and select "Wake up cluster". A form will pop up with the request if you want to wake up your cluster. Click on wake up cluster
.
Requirements:
- Kubectl, installation instructions can be found here.
- Service Account (SA), how to get one; See here.
First list your clusters.
% export KUBECONFIG=emk-sa-kubeconfig.yaml
% kubectl get shoots
NAME K8S VERSION HIBERNATION LAST OPERATION STATUS AGE
my-cluster 1.28.9 Hibernated Reconcile Succeeded (100%) healthy 42d
To wake up your cluster with kubectl use the following command:
kubectl patch shoot my-cluster -p '{"spec":{"hibernation":{"enabled": false}}}'
shoot.core.gardener.cloud/my-cluster patched
Now that your cluster is waking up, you can check the status of the process by listing your clusters:
Requirements:
- Terraform, installation instructions can be found here.
- Service Account (SA), how to get one; See here.
This Terraform guide assumes the creation of clusters through our creation tutorial; see here.
To wake up the cluster it is required to set the value spec.hibernation.enabled
to false
in the cluster.yaml
configuration:
Run terraform plan
and terraform apply
.
❯ terraform apply
kubectl_manifest.my_first_cluster: Refreshing state... [id=/apis/core.gardener.cloud/v1beta1/namespaces/ garden-thomas/shoots/my-cluster]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# kubectl_manifest.my_first_cluster will be updated in-place
~ resource "kubectl_manifest" "my_first_cluster" {
id = "/apis/core.gardener.cloud/v1beta1/namespaces/garden-thomas/shoots/my-cluster"
name = "my-cluster"
~ yaml_body = (sensitive value)
~ yaml_body_parsed = <<-EOT
apiVersion: core.gardener.cloud/v1beta1
kind: Shoot
spec:
hibernation:
+ enabled: "false"
name: my-cluster
namespace: garden-thomas
spec:
.............
EOT
# (13 unchanged attributes hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
kubectl_manifest.my_first_cluster: Modifying... [id=/apis/core.gardener.cloud/v1beta1/namespaces/ garden-thomas/shoots/my-cluster]
kubectl_manifest.my_first_cluster: Modifications complete after 0s [id=/apis/core.gardener.cloud/v1beta1/ namespaces/garden-thomas/shoots/my-cluster]
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
The cluster will now be waking up.