Skip to content

tiller is using an insane amount of memory #4543

Closed

Description

@primalmotion

Tiller is using an insane amount of memory and grows continuously as we query helm list (we do this for monitoring)

screen shot 2018-08-27 at 23 39 58

The drop in the chart is either me killing it or kubernetes after evicting a few of my database instances in the process...

Output of helm version:

Client: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}

Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.4", GitCommit:"5ca598b4ba5abb89bb773071ce452e33fb66339d", GitTreeState:"clean", BuildDate:"2018-06-06T15:22:13Z", GoVersion:"go1.9.6", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10+", GitVersion:"v1.10.6-gke.2", GitCommit:"384b4eaa132ca9a295fcb3e5dfc74062b257e7df", GitTreeState:"clean", BuildDate:"2018-08-15T00:10:14Z", GoVersion:"go1.9.3b4", Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.): GKE

Activity

  1. primalmotion commented on Aug 28, 2018

    @primalmotion
    Author

    the same happened with helm 2.9.1

  2. jascott1 commented on Aug 28, 2018

    @jascott1
    Contributor

    @bacongobbler I recall something like this before with some handles being kept open. Ring any bells with you?

  3. added
    bug
    on Aug 28, 2018
  4. YenTheFirst commented on Sep 18, 2018

    @YenTheFirst

    We've been seeing a similar issue with helm history.

    specifically, while true; do helm history RELEASE_NAME >/dev/null & sleep 1; done seems to easily reproduce the following:

    1. tiller's memory usage quickly climbs to 500mb, and then slowly continues to grow from there to nearly 2gb.
    2. Every 4 hours, tiller initiates some kind of cleanup on sockets, and is unavailable for roughly 3 minutes.
    helm version
    
    Client: &version.Version{SemVer:"v2.9.1", GitCommit:"20adb27c7c5868466912eebdf6664e7390ebe710", GitTreeState:"clean"}
    Server: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}
    
    kubectl version
    
    Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-08T16:31:10Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"darwin/amd64"}
    Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.7", GitCommit:"0c38c362511b20a098d7cd855f1314dad92c2780", GitTreeState:"clean", BuildDate:"2018-08-20T09:56:31Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}```
    
  5. chaholl commented on Feb 8, 2019

    @chaholl

    I'm seeing the same problem in an AKS cluster.

    I have 16 clusters running with the same config and only the older clusters are affected at the moment, suggesting that the problem is related to #4821. However, of the older clusters, one has 564 releases, and ticks along happily with around 80Mb memory, which jumps to 700Mb when responding to helm list, whereas the other has 310 releases, ticks along at around 70Mb then jumps to 670Mb when responding to helm list.

    Every consecutive call to helm list it uses a bit more memory until, as described by @primalmotion, things start to break. The same thing happens with installs and upgrades, so you can imagine, with a busy CI/CD pipeline, things start to fall over pretty quickly.

  6. whereisaaron commented on Feb 13, 2019

    @whereisaaron
    Contributor

    We are seeing performance degradation over time on older clusters. Every execution of helm upgrade or helm list is churning the API servers and causes 1-2 GB additional RAM use. Chaining commands just keeps allocating more RAM. Waiting a decent period of time allows some RAM to be released.

    This command on one cluster took a while and there are 3.5k ConfigMaps. Each is 1MB max, so up to 3.5GB data. The most frequently deployed application has >1000 revisions.

    $ kubectl -n kube-system get cm --no-headers -l OWNER=TILLER | wc -l
    3417
    

    How can we prune ConfigMaps for older revisions of deployments with out deleting deployed, in-production applications?

  7. bacongobbler commented on Feb 13, 2019

    @bacongobbler
    Member

    @mortent's comment here in #4821 seems to be fairly compelling. Last I checked the filtering was indeed being done on Tiller's side rather than filtering out on the apiserver side. If someone wants to take a look at how we could improve the filtering from the apiserver, that'd be great.

    For the lazy:

    Based on just a quick look at the code, it seems like pretty much all filtering, including the size limit, is enforced in Tiller and not in the ApiServer/etcd. So you could potentially be pulling in a large number of ConfigMaps from the ApiServer.

  8. whereisaaron commented on Feb 13, 2019

    @whereisaaron
    Contributor

    It sounds like redeploying with something reasonable for --history-max is our best option to stabilize these clusters. Then there will not be so much to filter every time.

  9. asherlporetz commented on Feb 13, 2019

    @asherlporetz

    You might also want to check the size of the charts since they are stored in the configmaps. Anything where the packaged chart .tgz is greater than 100kb is suspect, check .helmignore. Here's a snippet to check the size of the tiller configmaps.

    kubectl -n tiller-namespace get cm -lOWNER=TILLER -oname | xargs -n1 -I CM sh -c 'echo "CM" $(kubectl -n tiller-namespace get CM -ojsonpath={.data.release} | wc -c)' 
  10. whereisaaron commented on Feb 14, 2019

    @whereisaaron
    Contributor

    Thanks @asherlporetz, I checked the state backups, and the total size all the ~3,500 ConfigMaps is 70MB, so each release ConfigMap averages around 20Kb (full text, including release data).

    While the raw data is ~70MB for ~3,500 objects, the API Server allocates over 900MB of RAM to respond to all the tiller requests during a single helm list involving these objects, and tiller allocates a further 400MB RAM to process the responses. It's all not very scaleable.

    Options like helm list --max 1 or helm list <release-name> don't seem to reduce the impact, Proabably because as @bacongobbler pointed out, all the filtering is done in tiller. It appears to fetch everything, every time. And multiple helm operations close together in time compound until something breaks, as @paolomainardi experienced.

    Given this experience a strictly limited --max-history is essential. I don't think 'unlimited' is a sensible --max-history default.

  11. whereisaaron commented on Feb 14, 2019

    @whereisaaron
    Contributor

    As I bring down the object counts in my testing I am seeing a pretty linear relationship; For each average 20Kb ConfigMap in the cluster, tiller reads it in and allocates ~110Kb of RAM, when doing any operation like a helm list or helm upgrade. A helm upgrade needs about and extra 40MB RAM over a helm list, which seems a very reasonable uplift for computing an actual deployment manifest.

    So with a cluster with ~200 charts deployed, each on average 20Kb, and --max-history=50 you appear to need about 1GB RAM for a single tiller operation. You possibly need that amount again for each concurrent tiller operation, as multiple operations don't seem to share any retrieved release data, they fetch it all again. Even with --max-history in place, tiller resourcing and API server load can be significant.

  12. 27Bslash6 commented on Feb 14, 2019

    @27Bslash6

    Is there a quick workaround for this? I see in #3414 that setting --history-max on an already initialised cluster has no effect.

    Is there any convenient way to reduce max history size on a running cluster and not lose the entire current tiller state?

  13. bacongobbler commented on Feb 14, 2019

    @bacongobbler
    Member

    Removing tiller won't cause it to lose state. The only way it'll lose state is if you remove the ConfigMaps tiller stores in kube-system yourself. You can safely call helm reset --force && helm init without losing any cluster state as it only removes tiller, but not the releases.

    As a mini demonstration:

    ><> helm install stable/nginx-ingress
    ><> helm list
    NAME      	REVISION	UPDATED                 	STATUS  	CHART              	APP VERSION	NAMESPACE
    wobbly-bee	1       	Thu Feb 14 14:50:42 2019	DEPLOYED	nginx-ingress-1.3.0	0.22.0     	default  
    
    ><> helm reset --force
    Tiller (the Helm server-side component) has been uninstalled from your Kubernetes Cluster.
    
    ><> helm init
    ><> helm list
    NAME      	REVISION	UPDATED                 	STATUS  	CHART              	APP VERSION	NAMESPACE
    wobbly-bee	1       	Thu Feb 14 14:50:42 2019	DEPLOYED	nginx-ingress-1.3.0	0.22.0     	default
    

    Either that or just kubectl -n kube-system edit deploy tiller-deploy and change the value of TILLER_HISTORY_MAX. Either way ends up being the same.

  14. whereisaaron commented on Feb 14, 2019

    @whereisaaron
    Contributor

    Yes @27Bslash6 you can change the --history-max for tiller on an active cluster. Once changed the next deployment to each release will purge the history.

    ...
          containers:
          - env:
            - name: TILLER_HISTORY_MAX
              value: "20"
    ...
    
  15. 2 remaining items

  16. whereisaaron commented on Feb 15, 2019

    @whereisaaron
    Contributor

    No, I still have a lot of pruning to do on clusters, given you need re-deploy every release to trigger the clean-up function. I'm locking new clusters to just --max-history 10. I want to try to keep the number of ConfigMaps retrieved from the API Server per helm operation under 1,000 objects. And that should also keep tiller to ~0.25GB RAM per concurrent operation. I'm patching in resource settings for tiller so it can't undermine node stability.

  17. whereisaaron commented on Feb 28, 2019

    @whereisaaron
    Contributor

    We've pruned down to under 1,000 objects and it has made a big difference. Tiller memory appears mainly driven by the number of ConfigMaps/Secrets for a release; Per deployment RAM use has dropped from ~500MB+ to ~30-40MB, even less than I expected. And API server RAM use per deployment has dropped from ~1GB to ~500MB.

    We don't have use for the release history, as the deployment history is all in the CI/CD system anyway. So we'll probably configure --max-history to a minimum, maybe 2-3 revisions. That should eliminate the scaling problem entirely.

  18. max-lobur commented on Oct 11, 2019

    @max-lobur

    Same issue here, been able to get 20seconds of helm ls at best :(

    Tiller memory footprint decreased from 160 to 60mb, however helm ls time decreased only by 5 seconds and now its 20s :(
    Any further ideas appreciated.

  19. bacongobbler commented on Oct 12, 2019

    @bacongobbler
    Member

    I'm very curious to see if this has been improved in Helm 3. With Tiller's removal, we took the time to refactor a huge chunk of the underlying SDK supporting helm ls and how Helm interacts with the API server.

  20. virtuman commented on Feb 12, 2020

    @virtuman

    Helm 3, all list operations are still horribly slow with 40+ releases.
    We have approximately 5 versions of each release and were forced to re-write our CD process from helm ls to helm get ... and lookups with kubectl get secrets .... -l name=xxx,status=..., etc.

  21. bacongobbler commented on May 14, 2020

    @bacongobbler
    Member

    Does anyone have a test case to help reproduce this issue? There are many reports of this behaviour, but I don't see a way to reproduce the issue ourselves. It's important we have a base case to test against so we can confirm if a fix will resolve this issue. Thanks!

  22. itaimalek commented on May 17, 2020

    @itaimalek

    @bacongobbler
    yes I do. helm 2 though.

  23. bacongobbler commented on May 17, 2020

    @bacongobbler
    Member

    That's fine. Please share

  24. clhlc commented on May 26, 2020

    @clhlc

    +1
    helm 3 ,release 200+, and history default 10
    helm ls -->50s

  25. liuming-dev commented on May 26, 2020

    @liuming-dev
    Contributor

    +1
    helm 3 ,release 200+, and history default 10
    helm ls -->50s

    similar performance issue #8008, and we find that kubectl get secret -l owner=helm costs too much time if there are 1000+ release secrets, it's probably etcd's or apisever's issue.

  26. whereisaaron commented on Jun 27, 2020

    @whereisaaron
    Contributor

    With helm 2 we could work around most of the memory and speed problems by setting a Tiller history max value and clamping that to 2 or 3 per deployment. With helm 3 is there any similar environment setting we can use, like HELM_HISTORY_MAX or similar? There is the --history-max command line argument, but it seems like you have to reliably add it to absolutely every invocation or it will default to 10, potentially keeping more that you wanted, or worse, deleting some history you wanted to keep.

  27. hickeyma commented on Jun 29, 2020

    @hickeyma
    Contributor

    @whereisaaron This is a good point that you raise. I have opened #8367 for this.

  28. bacongobbler commented on Aug 14, 2020

    @bacongobbler
    Member

    We are no longer accepting bug fixes for Helm 2. See https://helm.sh/blog/helm-v2-deprecation-timeline/ for more details.

    As this issue is related to "tiller consuming an insane amount of memory", and tiller no longer exists for Helm 3, I'm going ahead and closing this.

    For those reporting performance issues with helm list for Helm 3, please follow up in #8008. A test case to reproduce the issue (as in, a script to create a cluster, create 1000+ releases, and observe the time of helm list) would be helpful as well so we can try to reproduce the same issue. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugunconfirmed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions