How to tell helm to not create/change resource if it already exists?

9/12/2019

I have a secret resource templates that upon installation will generate random values for the data.

I run into a problem after removing that chart (which did not delete the secret resource, because those stay), and reinstalling it later.

That caused it to run over the previous secret with newly generated data, which is not desired in my case.

I'm trying to find what is the if condition I need to include in the template so that it will not create or modify the secret if it already exists. How do I do that?

-- Tom Klino
kubernetes
kubernetes-helm

2 Answers

5/10/2020

From helm 3.1 version onwards, there is a lookup function available to check if the given resource exists or not. Using this function you can skip the upgrading or installing a resource if it already exists.

Lookup function

-- user2447587
Source: StackOverflow

9/12/2019

Sorry, but you can't at the moment.

According to the issue #4824 (Ignore existing resource on install if resource-policy is keep), the helm team neither support it yet nor have any plans.

UPD: there is a workaround for secrets:

generate secrets with Ansible k8s module, and pass them to Helm charts. A bit ugly, but works.

-- Yasen
Source: StackOverflow