Skip to content

Freeze Pod Volumes in Kubernetes for the purpose of snapshotting

License

Notifications You must be signed in to change notification settings

wikiwi/kube-volume-freezer

Repository files navigation

kube-volume-freezer

Freeze Pod Volumes in Kubernetes for the purpose of producing a live snapshot.

Build Status Widget GoDoc Widget Coverage Status Widget Code Climate Widget MicroBadger Version Widget MicroBadger Image Widget

Use-Case

  • You want to sync and freeze one or multiple Kubernetes Pod Volumes before creating a live snapshot without adding additional capabilities to your Pods. (GCE-Guide on creating snapshots)

Architecture

  • kvf-minion is run on every Node with required privileges and perform the actual syncing, freezing and thawing of local Volumes on the host.
  • kvf-apiserver delegates client requests to the correct Minion.
  • kvfctl is a command-line interface to the kvf-apiserver.

Install

The folder manifests contains an example deployment of kube-volume-freezer with token protected Minions and API server.

Steps to install:

  • Set your base64 encoded tokens in the kcf-secret.yaml file.
  • Add kvf-secret.yaml, kvf-daemonset.yaml, kvf-deployment.yaml and kvf-svc.yaml to your Kubernetes.

Example

The following example shows how to create a live snapshot from a running system on GCE using kubectl, kvfctl, and gcloud.

#!/bin/bash
# Open a local port to the kube-volume-freezer service.
# This is not needed when running inside a Kubernetes Cluster.
kubectl port-forward kube-volume-freezer-master-1053963144-7uxa2 8080:8080 &
PID=$!

# Freeze Volume named "data" in Pod "gitlab-3323024633-063kf".
kvfctl freeze --address localhost:8080 --token "my-token" gitlab-3323024633-063kf data

# Create snapshot on GCE associated with the Pod.
gcloud compute disks snapshot gitlab-disk --zone europe-west1-b --snapshot-names "gitlab-disk-$(date +"%Y%m%d%H%M%S")"

# Thaw Volume.
kvfctl thaw --address localhost:8080 --token "my-token" gitlab-3323024633-063kf data

# Close local port.
kill -TERM ${PID}

In a more complex example you can use kubectl to detect persistent disks of different deployments automatically and perform live snapshotting simultaneously.

Library

About

Freeze Pod Volumes in Kubernetes for the purpose of snapshotting

Resources

License

Stars

Watchers

Forks

Packages

No packages published