Reuse auth token when upgrading an Helm chart without token#20763
Reuse auth token when upgrading an Helm chart without token#20763
Conversation
When upgrading an Helm chat and not providing the auth token because it was previously set, Helm deleted the secret and Statefulset pods become stuck because the secret does not exist. This PR reads the secret value from the previous upgrade/install and reuses it during the upgrade. Fixes #20761
|
@hugoShaka I followed the following options but didn't like any.
Let me know your thoughts |
|
@tigrato If I understand correctly, the agent should be able to start because it still has a valid state (either in a PV or in its own secret), but the pods cannot be scheduled because they try to mount the secret containing the token, even if it is not needed and won't be used. We also want to fail fast during deployment if we know it won't work. I see 3 cases:
I fear lookups because they aren't testable and tend to break Helm's statelessness/idempotency properties.I would tend to prefer your other approach, where you either always create a secret or conditionally create a secret based on the provided values. This would allow to remove the join token from the cluster after installation, which is a nice thing for users relying on static or long-lived tokens. In both methods, the user experience could be maintained with a couple of The downside with handling those cases separately is that |
| @@ -12,4 +11,3 @@ type: Opaque | |||
| stringData: | |||
| auth-token: | | |||
| {{ coalesce .Values.joinParams.tokenName .Values.authToken }} | |||
There was a problem hiding this comment.
you removed if or .Values.authToken .Values.joinParams.tokenName so couldn't these both be null/falsy? What gets put here in that case?
There was a problem hiding this comment.
By default, .Values.authToken is "" so coalesce will write "".
If you override the default value with nil, it will print whatever you define
|
Could we fail on setups we know that won't work? Something like {{- $renewableJoinMethods := list "token" "ec2" "iam" }}
{{- $joinToken := coalesce .Values.joinParams.tokenName .Values.authToken }}
{{- if and (empty $joinToken) (not (has .Values.joinParams.method $renewableJoinMethods)) }}
{{- printf "Non renewable join method %s require a join token, set 'joinParams.tokenName' or 'authToken'" .Values.joinParams.method | fail }}
{{- end }} |
|
friendly ping @nklaassen |
* Reuse auth token when upgrading an Helm chart without token When upgrading an Helm chat and not providing the auth token because it was previously set, Helm deleted the secret and Statefulset pods become stuck because the secret does not exist. This PR reads the secret value from the previous upgrade/install and reuses it during the upgrade. Fixes #20761 * remove secret lookup
* Fix Helm chart Join token secret creation Since #20763 was merged, we lost the ability of the chart reusing the externally created secrets for join token. This PR changes the logic and allows to control the secret creation using the `joinTokenSecret.create` boolean and the secret name with `joinTokenSecret.name`. Fixes #20763 * Add changelog
* Fix Helm chart Join token secret creation Since #20763 was merged, we lost the ability of the chart reusing the externally created secrets for join token. This PR changes the logic and allows to control the secret creation using the `joinTokenSecret.create` boolean and the secret name with `joinTokenSecret.name`. Fixes #20763 * Add changelog
* Fix Helm chart Join token secret creation Since #20763 was merged, we lost the ability of the chart reusing the externally created secrets for join token. This PR changes the logic and allows to control the secret creation using the `joinTokenSecret.create` boolean and the secret name with `joinTokenSecret.name`. Fixes #20763 * Add changelog
When upgrading an Helm chat and not providing the auth token because it was previously set, Helm deleted the secret and Statefulset pods become stuck because the secret does not exist.
This PR forces the creation the secret even if no token is provided.
Fixes #20761