-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Avoid recreating random secrets #1550
Conversation
Anyway we can get this reviewed so it can get merged in? |
Actually, I think that While this PR will work for new deployment it removes defining certificate for token signing from external secret (you can use CertManager to do just that) - it will break the installation for those who already use The idea is good though - but it needs to preserve the |
Hi @Kajot-dev it should be solved. Could you review it again please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, you did a lot of work, thanks!!
Nice changes, but some of them apply only when generating new data.
Also there is much code duplication like this:
{{- $secret := lookup ... }}
{(- if $secret }}
old data..
{{- else }}
new data
{{- end }}
Also not all secret values are reused - for example if user won't put S3 secrets in external secret it will not use lookup for them
If you want to you can avoid code duplications by leveraging the fact that when secret is not present helm returns an empty object. Instead of having two blocks for reusing data and generation of the new data which share most of the code you can do something like this:
{{/* template definition */}}
{{- define "harbor.keyExtractor" -}}
{{- if hasKey .data .key }}
{{- $val := (index .data .key) }}
{{- if kindIs "string" $val }}
{{ .key }}: {{ $val | quote }}
{{- else }}
{{ .key }}: {{ $val }}
{{- end }}
{{- else }}
{{ .default }}
{{- end }}
{{- end -}}
{{/* and then */}}
{{- $secret := lookup ... }}
{{- template "harbor.keyExtractor" (dict "key" "SOME_PASSWORD_KEY" "data" $secret.data "default" "DEFAULT_VALUE" ) }}
Signed-off-by: Joan Miquel Luque Oliver <[email protected]>
Co-authored-by: Carlos Vega <[email protected]> Signed-off-by: Joan Miquel Luque Oliver <[email protected]>
…tion. Co-authored-by: Carlos Vega <[email protected]> Signed-off-by: Joan Miquel Luque Oliver <[email protected]>
Co-authored-by: Jakub Jaruszewski <[email protected]> Signed-off-by: Joan Miquel Luque Oliver <[email protected]>
Co-authored-by: Jakub Jaruszewski <[email protected]> Signed-off-by: Joan Miquel Luque Oliver <[email protected]>
Co-authored-by: Jakub Jaruszewski <[email protected]> Signed-off-by: Joan Miquel Luque Oliver <[email protected]>
Co-authored-by: Jakub Jaruszewski <[email protected]> Signed-off-by: Joan Miquel Luque Oliver <[email protected]>
Co-authored-by: Jakub Jaruszewski <[email protected]> Signed-off-by: Joan Miquel Luque Oliver <[email protected]>
Signed-off-by: Joan Miquel Luque Oliver <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
Nice work!
Could we get this reviewed and merged please? |
fix: #1609 |
Thanks for contributing to harbor-helm! |
Avoid recreating secrets with dynamic/random content on every helm update. This causes the
core
,registry
andjobservice
services to be redeployed in each update.Related to https://cloud-native.slack.com/archives/CC1E09J6S/p1689925408303219
Close #1549