Skip to content

Conversation

sgalsaleh
Copy link
Member

What this PR does / why we need it:

Uses the Helm binary instead of the Go SDK to manage Helm charts

Which issue(s) this PR fixes:

SC-128058

Does this PR require a test?

Yes

Does this PR require a release note?

NONE

Does this PR require documentation?

NONE

@sgalsaleh sgalsaleh force-pushed the salah/sc-128058/use-helm-binary-instead-of-the-go-sdk-to branch from a2a1610 to 308f730 Compare August 29, 2025 23:20
Copy link

github-actions bot commented Sep 2, 2025

This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app license ID.

Online Installer:

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci/appver-dev-d458620" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Airgap Installer (may take a few minutes before the airgap bundle is built):

curl "https://staging.replicated.app/embedded/embedded-cluster-smoke-test-staging-app/ci-airgap/appver-dev-d458620?airgap=true" -H "Authorization: $EC_SMOKE_TEST_LICENSE_ID" -o embedded-cluster-smoke-test-staging-app-ci.tgz

Happy debugging!

@sgalsaleh sgalsaleh marked this pull request as ready for review September 2, 2025 20:56
@sgalsaleh sgalsaleh requested a review from emosbaugh September 2, 2025 20:56
cursor[bot]

This comment was marked as outdated.

@@ -25,6 +25,9 @@ K0S_VERSION = $(K0S_VERSION_1_$(K0S_MINOR_VERSION))
# Format: K0S_BINARY_SOURCE_OVERRIDE_<MINOR_VERSION>
# Example: K0S_BINARY_SOURCE_OVERRIDE_32 = https://github.com/k0sproject/k0s/releases/download/v1.32.7+k0s.0/k0s-v1.32.7+k0s.0-amd64

# Helm Version
HELM_VERSION = v3.18.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should you add automation to update this to the dependencies.yaml github actions workflow?

@@ -90,6 +90,8 @@ func TestGetInstallationConfig(t *testing.T) {
},
}

t.Setenv("HELM_BINARY_PATH", "helm") // use the helm binary in PATH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean i need helm install locally to run unit tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, any other ideas? helm binary is currently a requirement for the dev env anyways.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you were to instantiate only one client as suggested you would not have to set the env var

// used in tests so that we don't pass the helm binary path all over the place
return hp, nil
}
hp, err := goods.Binary("helm")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be possible to pass around a HelmClient rather than an EnvSettings so you dont have to use the goods package outside of the cli? Looks like you would have to factor out logging into the call to the client functions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. i will update so there's a single helm client used by the cli / api.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm this will make it hard to override the log function for the helm client and other operation specific fields.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if i pass the helm binary path explicitly from callers instead of using the goods package?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you didnt want to add the log as an argument to all methods, could you add the log to the context? Similar to this https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/log

chartRequested, err := loader.Load(localPath)
if err != nil {
return nil, fmt.Errorf("load: %w", err)
// Add all helm CLI flags from kubernetesEnvSettings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you move addKubernetesCLIFlags to this package and export it or make this dynamic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate? what do you mean by making it dynamic?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would prefer that the add flags and add env args were just moved closer in the code, perhaps both in this package. if not, it may be possible to use flagset.Visit to iterate over the flags and construct the cli args

Comment on lines +411 to +414
if h.airgapPath != "" {
// Use chart from airgap path
return filepath.Join(h.airgapPath, fmt.Sprintf("%s-%s.tgz", releaseName, chartVersion)), nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this never felt like it belonged in this package. perhaps something to address later

Comment on lines 593 to 591
restConfig, err := flags.kubernetesEnvSettings.RESTClientGetter().ToRESTConfig()
restConfig, err := clientcmd.BuildConfigFromFlags("", flags.kubernetesEnvSettings.KubeConfig)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change this? is it equivalent? what if i dont explicitly set the kubeconfig as a flag?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

LogFn action.DebugLog
HelmPath string
KubernetesEnvSettings *helmcli.EnvSettings
K8sVersion string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is K8sVersion no longer used? Is this going to be an issue for things like buildtools or rendering before install k0s? If not can you remove it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is used

Copy link
Member

@emosbaugh emosbaugh Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is only used for render. should it be an argument to that function? or is that difficult?

cursor[bot]

This comment was marked as outdated.

@sgalsaleh sgalsaleh force-pushed the salah/sc-128058/use-helm-binary-instead-of-the-go-sdk-to branch from 999881f to 5ee5bcf Compare September 4, 2025 16:10
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@sgalsaleh sgalsaleh merged commit 08bd1f9 into milestone-7-redo Sep 5, 2025
163 of 172 checks passed
@sgalsaleh sgalsaleh deleted the salah/sc-128058/use-helm-binary-instead-of-the-go-sdk-to branch September 5, 2025 18:28
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.

2 participants