Giter Club home page Giter Club logo

kubefreezer's Introduction

Build Status

Kubefreezer

Freezes the running kubernetes cluster into local yaml manifests.

Motivation

Backups are always useful. Especially when the configuration effort is high like with Kubernetes. Usually you have a few manifests lying around locally. However, over time, they become outdated, because you have made a few small adjustments with "kubectl edit". These undocumented changes accumulate over time and are then simply no longer traceable.

Nowadays there is more and more middleware software available that overlays the kubectl layer to make it easier to use. Rancher for example offers a graphical interface to the kubernetes cluster. With AWS, Azure, Redshift and Google also offer such possibilities. Especially here it is important to store the configurations in a uniform, kubectl conform way somewhere. This is what Kubefreezer offers.

Environment Variables

Environment Variable Description Example
CLUSTER_NAME Name of the kubernetes-cluster to be backed up 'test-cluster-0'
NAMESPACES Relevant namespaces to be secured 'default,production,staging,testing'
RESOURCES Relevant resources to be secored 'ingresses.configmaps,secrets,deployments'
KUBECTL_OPTIONS (optional) Options that is passed to kubectl. '--insecure-skip-tls-verify'

Usage

#!/bin/bash
docker build -t kubefreezer .
docker run --rm -it \
    -e CLUSTER_NAME='testing-cluster-0' \
    -e NAMESPACES='testing,staging,production,default' \
    -e RESOURCES='ingresses,secrets,configmaps,deployments' \
    -v /path/to/kubeconfig:/app/kubeconfig \
    -v /path/to/backup-dir/:/var/lib/data \
    kubefreezer:v1.1.0

Full Example Script

#!/bin/bash
#
# Author:
# Quving (https://github.com/Quving)
#
# Description
# This script creates a backup of the kubernetes-cluster using kubectl. It creates snapshots of different resources.

BACKUP_DIR=manifests/$(date +%F)

mkdir -p $BACKUP_DIR

docker run --rm -it \
    -e CLUSTER_NAME='quving' \
    -e NAMESPACES='default,apps,infrastructure' \
    -e RESOURCES='ingresses,secrets,configmaps,deployments,certificates' \
    -v $(pwd)/kubeconfig:/app/kubeconfig \
    -v $(pwd)/$BACKUP_DIR:/var/lib/data \
    quving/kubefreezer:v1.0.0

kubefreezer's People

Contributors

quving avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.