Giter Club home page Giter Club logo

helm-backup's Introduction

Helm Backup Plugin

This is a Helm plugin which performs backup/restore of releases in a namespace to/from a file

Usage

backup releases from namespace to file

$ helm backup [flags] NAMESPACE

restore releases from file to namespace

$ helm backup [flags] NAMESPACE --restore

Flags:

      --file string        file name to use (.tgz file). If not provided - will use <namespace>.tgz
  -h, --help               help for backup
  -l, --label string       label to select tiller resources by (default "OWNER=TILLER")
  -r, --restore            restore instead of backup
  -t, --tiller-ns string   namespace of Tiller (default "kube-system")

Install

$ helm plugin install https://github.com/maorfr/helm-backup

The above will fetch the latest binary release of helm backup and install it.

Developer (From Source) Install

If you would like to handle the build yourself, instead of fetching a binary, this is how recommend doing it.

First, set up your environment:

  • You need to have Go installed. Make sure to set $GOPATH
  • If you don't have Dep installed, this will install it into $GOPATH/bin for you.

Clone this repo into your $GOPATH. You can use go get -d github.com/maorfr/helm-backup for that.

$ cd $GOPATH/src/github.com/maorfr/helm-backup
$ make bootstrap build
$ HELM_PUSH_PLUGIN_NO_INSTALL_HOOK=1 helm plugin install $GOPATH/src/github.com/maorfr/helm-backup

That last command will skip fetching the binary install and use the one you built.

helm-backup's People

Contributors

bhavin192 avatar maorfr avatar wbertelsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

helm-backup's Issues

Release the last version

Hi,

The 0.1.2 version uses "apply" instead of "create" during the restoration. Could you release the last version to avoid problems ?

Thank you

The ConfigMap is invalid: metadata.annotations: Too long: must have at most 262144 characters

I have a release of prometheus-operator called prom. The release key from prom.v1 configMap has value with character length 467908. We are using kubectl apply … command while creating the release configMaps.

helm-backup/main.go

Lines 134 to 138 in 2e7d6b8

restoreCmd := []string{
"kubectl",
"--namespace", tillerNamespace,
"apply", "-f", manifestsFileName,
}

kubectl apply adds annotation kubectl.kubernetes.io/last-applied-configuration in the configMap which has whole object in JSON format.

  • prom.v1 configMap

    apiVersion: v1
    data:
      release: H4sIAAAAAAAC...
    kind: ConfigMap
    metadata:
      annotations:
        kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","data":{"release":"H4sIAAAAAAAC..."},"kind":"ConfigMap","metadata":{"annotations":{},"creationTimestamp":"2019-11-25T10:35:18Z","labels":{"MODIFIED_AT":"1574678151","NAME":"prom","OWNER":"TILLER","STATUS":"DEPLOYED","VERSION":"1"},"name":"prom.v1","namespace":"kube-system","resourceVersion":"3983651","selfLink":"/api/v1/namespaces/kube-system/configmaps/prom.v1","uid":"46925b3d-0f6f-11ea-abfa-02a3452c4edd"}}
      creationTimestamp: "2019-11-25T10:35:18Z"
      labels:
        MODIFIED_AT: "1574678151"
        NAME: prom
        OWNER: TILLER
        STATUS: DEPLOYED
        VERSION: "1"
      name: prom.v1
      namespace: kube-system
      resourceVersion: "3983651"
      selfLink: /api/v1/namespaces/kube-system/configmaps/prom.v1
      uid: 46925b3d-0f6f-11ea-abfa-02a3452c4edd
  • Error from plugin:

    $ helm backup --restore utilities
    2019/11/26 15:54:34 extracting backup from file utilities.tgz
    2019/11/26 15:54:34 reading backup data
    2019/11/26 15:54:34 releases found to restore: prom, …
    2019/11/26 15:54:34 applying backup data to tiller (this command will fail if releases exist)
    2019/11/26 15:54:51 Error: command execution failed: [kubectl --namespace kube-system apply -f restore/manifests.yaml]
    2019/11/26 15:54:51 Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
    configmap/cluster-autoscaler.v1 configured
    
    The ConfigMap "prom.v1" is invalid: metadata.annotations: Too long: must have at most 262144 characters
    Error: plugin "backup" exited with error
  • Versions

    $ kubectl version --short
    Client Version: v1.16.2
    Server Version: v1.14.6-eks-5047ed
    
    $ helm version  --short
    Client: v2.15.2+g8dce272
    Server: v2.15.2+g8dce272
    
    # helm-backup version
    # 0.1.2

Should we use kubectl create or kubectl replace instead of kubectl apply while creating the configMaps? I can work on this if we plan to make the change :)

Couldn't restore due to config map conflict

Scenario:

  1. helm backup --file dev.tgz dev in old cluster
  2. Move secrets from one cluster to another
  3. helm backup --restore --file dev.tgz dev in old cluster

Output:

19/08/01 14:56:03 applying backup data to tiller (this command will fail if releases exist)
2019/08/01 15:28:47 Error: command execution failed: [kubectl --namespace kube-system apply -f restore/manifests.yaml]
2019/08/01 15:28:47 configmap/XXX.v1 created
configmap/XXX.v10 created
... many many lines with configmap created
configmap/XXX.v99 created
Error from server (Conflict): Operation cannot be fulfilled on configmaps "XXX.v1": the object has been modified; please apply your changes to the latest version and try again
... many conflict errors.

Although all releases were created and helm ls confirmed it, no pods started.

Install plugin in macOS

Cannot install helm-backup plugin.
OS: macOS 10.14.3
Helm: v2.11.0

helm plugin install https://github.com/maorfr/helm-backup      
                                                                                                                                                       
Downloading and installing helm-backup  ...
https://github.com/maorfr/helm-backup/releases/download//helm-backup-macos-.tgz
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
mv: rename releases//backup to bin/backup: No such file or directory
mv: rename releases//backup.exe to bin/backup: No such file or directory
Installed plugin: backup

awk Error on install

When installing on a Linux system, awk throws the following error:

awk: cmd. line:1: warning: regexp escape sequence `\"' is not a known regexp operator

Not able to backup when tiller is installed on another namespace other the kube-system

I can backup Helm charts when Tiller is installed into kube-system. But if I have Tiller installed into another namespace and I specifically state that in the argument, it is not able to find any releases.

kubectl get pods --namespace appabc
NAME READY STATUS RESTARTS AGE
test1-service-68b4b238fd-7frr4 1/1 Running 0 5d
test1-service-68b4b238fd-fcnv8 1/1 Running 0 5d
demo-service-6d75111d6c-ft8ht 1/1 Running 36 5d
demo-service-6d75111d6c-rjd55 1/1 Running 36 5d
tiller-deploy-8bb9111b5-clfn8 1/1 Running 0 5d

$ helm list --tiller-namespace appabc
NAME REVISION UPDATED STATUS CHART NAMESPACE
test1-service 1 Thu Nov 29 10:53:16 2018 DEPLOYED test-service-0.1.1-snapshot offeropt
demo-service 1 Thu Nov 29 10:53:10 2018 DEPLOYED demo-service-0.2.0 offeropt

$ helm backup --tiller-namespace appabc appabc
2018/12/04 14:10:11 getting tiller storage
2018/12/04 14:10:11 found tiller storage: configmaps
2018/12/04 14:10:11 getting releases in namespace "offeropt"
2018/12/04 14:10:12 found relases:
2018/12/04 14:10:12 getting backup data
2018/12/04 14:10:14 successfully got backup data
2018/12/04 14:10:14 writing backup to file offeropt.tgz
2018/12/04 14:10:14 backup of namespace "offeropt" to file offeropt.tgz complete (found releases: )

Support for Helm v3

Please give us a support for Helm 3. It is a great tool. Maybe a doc in order to do a fork to implement support.

Plugin does not support multi path KUBECONFIG env var

Hello I use Multiple path in my KUBECONFIG env var as explaind in the doc

However the plugin try to "stat" the config file and fail as it expect a single file:

2019/01/17 13:00:55 getting tiller storage
2019/01/17 13:00:55 stat /home/ggenot/.kube/config-1:/home/ggenot/.kube/config-2:/home/ggenot/.kube/config-3:: no such file or directory
Error: plugin "backup" exited with error

Note that I have the same behavior with the helm-logs plugin

Can this be used to migrate tiller configmaps from one namespace to another

I am trying to migrate the existing tiller installation from kube-system namespace to tiller namespace.

I created a backup like this
helm backup -l OWNER=TILLER -t kube-system dev
and then trying to restore like this
helm backup --file dev.tgz dev --restore -t tiller

However, I get this error:

the namespace from the provided object "kube-system" does not match the namespace "tiller". You must pass '--namespace=kube-system' to perform this operation.

Does this mean that the source and the destination namespace has to be the same?

No Auth Provider found for name "azure"

Hi, I ran into this on Windows 10 using git-bash for Azure's AKS

$ helm backup svfb --tiller-namespace svfb
2018/11/29 16:00:20 No Auth Provider found for name "azure"
Error: plugin "backup" exited with error

How do I enable debug? This message coming from Kube or Helm is vague.

Error: unknown flag: --kubeconfig

I use --kubeconfig to manage multiple kubernetes clusters.

but however, looks like the backup plugin not support this flag

$ helm --kubeconfig=~/.kube/config  backup -h
Error: unknown flag: --kubeconfig
Usage:
  backup [flags] NAMESPACE

Flags:
      --file string               file name to use (.tgz file). If not provided - will use <namespace>.tgz
  -h, --help                      help for backup
  -l, --label string              label to select tiller resources by (default "OWNER=TILLER")
  -r, --restore                   restore instead of backup
      --tiller-namespace string   namespace of Tiller (default "kube-system")

Error: plugin "backup" exited with error

Thanks for the plugins

one tool to export/import

hey there, love your tools for export and import you made.
it would make more sense to have one plugin which does both.
maybe call it backup 🙂

Not working with microk8s installation (conjure up)

Hello,

On my local, I have microk8s installed via conjure up, and it does not have following file. I think it is not created for minikube as well.

/home/shipahi/.kube/config

I am getting following error.

helm backup default
2018/12/31 01:13:21 getting tiller storage
2018/12/31 01:13:21 stat /home/shipahi/.kube/config: no such file or directory

any idea or improvement suggestions on this?
If you need credentials, maybe we can supply auth token value?

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.