Fix a Helm "Secret Too Long" Bug

2021 Mar 23

When try to upgrade a Helm chart, it failed with an error like below.

Error: UPGRADE FAILED: create: failed to create: Secret "sh.helm.release..." is invalid: data: Too long: must have at most 1048576 bytes

Helm by default uses Kubernetes Secrets to store release information. For what is “release information”,

The release information includes the contents of charts and values files

See Storage backends for more details.

In my case, some certificates (after encryption) are stored in the chart files. These certificates are for different deploy environments. To solve this error for my chart, a simple solution to create a script to dynamically “helm ignore” files which are not needed for a Helm release for a deploy environment. For example, add files which are for production into the .helmignore file when deploy for the staging environment.

Helm also has a beta feature called “SQL storage backend” to store release information in a database, for a big chart.

Using such a storage backend is particularly useful if your release information weighs more than 1MB