Skip to content

Conversation

@JGAntunes
Copy link
Member

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?

NONE

Does this PR require documentation?

NONE

@JGAntunes JGAntunes self-assigned this Dec 5, 2025

// 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
Copy link
Member Author

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 🤔

Copy link
Member

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.

Comment on lines 138 to 154
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)
}
Copy link
Member Author

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.

Comment on lines +113 to +128
// 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",
},
Copy link
Member Author

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.

@JGAntunes JGAntunes marked this pull request as draft December 5, 2025 15:51
@JGAntunes JGAntunes marked this pull request as ready for review December 5, 2025 19:01
@JGAntunes
Copy link
Member Author

I'll be adding a dryrun test assertion as follow up but for now this should be good for 👀

@JGAntunes JGAntunes merged commit 77f195c into main Dec 5, 2025
27 checks passed
@JGAntunes JGAntunes deleted the jgantunes/sc-131755/store-user-config-values-in-a-kubernetes branch December 5, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants