maorfr / helm-backup

Helm plugin which performs backup/restore of releases in a namespace to/from a file
Other
83 stars 18 forks source link

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

Closed devteng closed 5 years ago

devteng commented 5 years ago

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: )

maorfr commented 5 years ago

Hey @devteng,

That's a great find! :) I have added the label good first issue. Would you like to give it a try? If not, that is ok, I can fix it.

Would you like to get involved? ;)

devteng commented 5 years ago

I will give it a shot! Will scream for help if I need help.

devteng commented 5 years ago

Hi maorfr, I am not able to build this code. Mostly likely due to me being a novice to golang and not having a proper golang environment. What I am suspecting is that the tiller namespace is not being passed into ListReleases(ListOptions{}) in the func ListReleaseNamesInNamespace.

func ListReleaseNamesInNamespace(namespace string) (string, error) { releases, err := ListReleases(ListOptions{}) if err != nil { return "", err } uniqReleases := make(map[string]string) for _, r := range releases { if r.Namespace != namespace { continue } uniqReleases[r.Name] = "" } var inReleases string for k := range uniqReleases { inReleases += k inReleases += "," } return strings.TrimRight(inReleases, ","), nil }

maorfr commented 5 years ago

You are absolutely right. This is a bit more difficult since ListReleaseNamesInNamespace is in another package - helm-plugin-utils. To make things more simple, I have updated the utils package (with tag 0.1.2). If you want to take it from here - you are welcome ;)

The backup plugin is using dep for package management. Here are some links to help you with that: https://golang.github.io/dep/docs/introduction.html https://golang.github.io/dep/docs/Gopkg.toml.html#constraint

Again, if you prefer I do it - just say the word.

Thanks!

devteng commented 5 years ago

Thanks maorfr! For now, please work on it. I need to spend more time with golang before I take this on. I very much appreciate your work!

maorfr commented 5 years ago

Your appreciation is appreciated ;) The issue is fixed with version 0.1.1, give it a shot.

maorfr commented 5 years ago

Closing this issue, feel free to reopen if it isn't fixed :)

mr-rick commented 5 years ago

This isn't fixed. I'm experiencing the issue with version 0.1.1

My label default OWNER=TILLER as well. And my tiller-namespace is not kube-system

maorfr commented 5 years ago

Would love to see some output from the command execution!

mumrau commented 5 years ago

I think I am facing a similar issue.

For a command looking like helm backup whatever-namespace --tiller-namespace my-tiller-namespace, I get:

2019/04/08 09:26:40 getting tiller storage
2019/04/08 09:26:40 Found 0 tiller pods
Error: plugin "backup" exited with error

I feel like it basically ignore both --tiller-namespace options or TILLER_NAMESPACE env variable, I've tried both. It works flawlessly with kubte-system as my tiller-namespace though.

maorfr commented 5 years ago

can i please get a printout of describe of the tiller pod in the my-tiller-namespace namespace?

mumrau commented 5 years ago
Name:               tiller-deploy-664669fff8-6lcd6
Namespace:          my-tiller-namespace
Priority:           0
PriorityClassName:  <none>
Node:               cancun/10.46.1.109
Start Time:         Mon, 04 Mar 2019 09:55:01 +0100
Labels:             app=helm
                    name=tiller
                    pod-template-hash=664669fff8
Annotations:        <none>
Status:             Running
IP:                 10.244.6.99
Controlled By:      ReplicaSet/tiller-deploy-664669fff8
Containers:
  tiller:
    Container ID:   docker://eb6c8a9fc276911226cdd8bb59530ed25e5bd4f6453952d38a1f835677b49526
    Image:          gcr.io/kubernetes-helm/tiller:v2.13.0
    Image ID:       docker-pullable://gcr.io/kubernetes-helm/tiller@sha256:c4bf03bb67b3ae07e38e834f29dc7fd43f472f67cad3c078279ff1bbbb463aa6
    Ports:          44134/TCP, 44135/TCP
    Host Ports:     0/TCP, 0/TCP
    State:          Running
      Started:      Fri, 22 Mar 2019 17:22:51 +0100
    Last State:     Terminated
      Reason:       Error
      Exit Code:    2
      Started:      Mon, 04 Mar 2019 10:17:33 +0100
      Finished:     Fri, 22 Mar 2019 17:02:49 +0100
    Ready:          True
    Restart Count:  2
    Liveness:       http-get http://:44135/liveness delay=1s timeout=1s period=10s #success=1 #failure=3
    Readiness:      http-get http://:44135/readiness delay=1s timeout=1s period=10s #success=1 #failure=3
    Environment:
      TILLER_NAMESPACE:    my-tiller-namespace
      TILLER_HISTORY_MAX:  0
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from tiller-token-v6tds (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  tiller-token-v6tds:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  tiller-token-v6tds
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>

I have 3 pods (due to my helm config which has a replica count of 3) for your knowledge, maybe this is related.

EDIT: I also tried with the -l name=tiller or app=helm option, and the output is the exact same.

miklezzzz commented 5 years ago

hi guys, added PR for the problem https://github.com/maorfr/helm-backup/pull/8

maorfr commented 5 years ago

closing as the PR is merged. thanks!

lich1710 commented 5 years ago

You have merged this commit, but it seems like if I install using helm plugin as below, I still get the old 0.1.1

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

Only when I build locally then I get the fixed version. Can you check on this? Thanks!

maorfr commented 5 years ago

i just release 0.1.2. give it another try.

lich1710 commented 5 years ago

Cool...working fine now...thanks a lot!