'How can Helm preserve ConfigMap of last n versions

I have a ConfigMap in my chart, and it has a different name in each release. When release 3 is deployed, there's only my-cm-bea2 exists.

Release reversion         ConfigMap name
       1                    my-cm-3287
       2                    my-cm-475f
       3                    my-cm-bea2

How can I preserve the last 2 versions of ConfigMap, e.g., when release 3 is deployed, keep both my-cm-bea2 and my-cm-475f and then delete my-cm-3287.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source