Kubernetes Cluster Backup with Heptio Ark on GCP

Heptio Ark is a utility for managing disaster recovery, specifically for your Kubernetes cluster resources and persistent volumes. It provides a simple, configurable, and operationally robust way to back up and restore applications and PVs from a series of checkpoints. Heptio Ark supports the AWS, GCP, and Azure cloud provider platforms, but in this article, I will work only with GCP.

When I just started using Kubernetes, I had a task to backup everything inside of our k8s cluster with it’s volumes and etc. I tried to follow their documentation, but had lots of problems here and there so when I finally overcame those problems, I thought I should save the right steps for myself in the future. This article does not explain all ins and outs, so if you want a detailed tutorial or documentation, please read their github page.

Prerequisites:

  1. Owner role on the GCP project you are working on
  2. Kubernetes cluster
  3. Installed and configured kubectl
  4. It is good to get familiar with Heptio Ark basics before continuing. Go through the Quickstart section on the Heptio Ark github page

Cluster admin role binding

When I tried to install and get Ark running on my cluster, my Kubernetes user didn’t have enough permissions to create Ark’s custom resources even if I had an owner role in GCP. In Kubernetes, you can create a user and set permissions to other users only if you have those permissions yourself. In order to get rid of it, connect your account with Kubernetes cluster-admin role:

kubectl create clusterrolebinding myname-cluster-admin-binding --clusterrole=cluster-admin --user=myname@example.org

This will create cluster-admin role binding for you account and now you can do quite everything in your cluster.

Now follow their tutorial on github https://github.com/heptio/ark/blob/master/docs/cloud-provider-specifics.md which is quite easy to understand.

If you have any questions, please feel free to ask.

Happy backuping!