-
Notifications
You must be signed in to change notification settings - Fork 9
feat(install): store config values in a kube secret on install #3272
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
feat(install): store config values in a kube secret on install #3272
Conversation
|
|
||
| // createConfigValuesSecret creates or updates a Kubernetes secret with the config values. | ||
| // TODO: Handle 1MB size limitation by storing large file data fields as pointers to other secrets | ||
| // TODO: Consider maintaining history of config values for potential rollbacks |
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.
I don't know if this will be required or not? Just something I was wondering as we might want to keep a couple of versions of the config values laying around for this case or if this will be entirely up to Helm and we don't need to care about it 🤔
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.
we don't support rollbacks at this time. we can worry about it later.
| if !apierrors.IsAlreadyExists(err) { | ||
| return fmt.Errorf("create config values secret: %w", err) | ||
| } | ||
|
|
||
| // Secret exists, delete and recreate it | ||
| existingSecret := &corev1.Secret{} | ||
| existingSecret.Name = secretName | ||
| existingSecret.Namespace = namespace | ||
|
|
||
| if err := m.kcli.Delete(ctx, existingSecret); err != nil { | ||
| return fmt.Errorf("delete existing config values secret: %w", err) | ||
| } | ||
|
|
||
| // Recreate with new data | ||
| if err := m.kcli.Create(ctx, secret); err != nil { | ||
| return fmt.Errorf("recreate config values secret: %w", err) | ||
| } |
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.
I was thinking if another secret could already be in place? And opted for just replacing it if that's the case.
| // Create secret object | ||
| secret := &corev1.Secret{ | ||
| TypeMeta: metav1.TypeMeta{ | ||
| Kind: "Secret", | ||
| APIVersion: "v1", | ||
| }, | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: secretName, | ||
| Namespace: namespace, | ||
| Labels: map[string]string{ | ||
| "app.kubernetes.io/name": license.Spec.AppSlug, | ||
| "app.kubernetes.io/version": m.releaseData.ChannelRelease.VersionLabel, | ||
| "app.kubernetes.io/component": "config", | ||
| "app.kubernetes.io/part-of": "embedded-cluster", | ||
| "app.kubernetes.io/managed-by": "embedded-cluster-installer", | ||
| }, |
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.
Let me know what you think of the name and labels applied here.
|
I'll be adding a dryrun test assertion as follow up but for now this should be good for 👀 |
What this PR does / why we need it:
With us removing the usage of kots cli to install the app we need to keep the config values for the current app install and use that when we're running the upgrade installer.
This PR addresses the first part (creating a kube secret on install).
Which issue(s) this PR fixes:
https://app.shortcut.com/replicated/story/131755/store-user-config-values-in-a-kubernetes-secret
Does this PR require a test?
Yes
Does this PR require a release note?
Does this PR require documentation?
NONE