-
Notifications
You must be signed in to change notification settings - Fork 6
Use Helm binary instead of the Go SDK to manage charts #2770
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
Use Helm binary instead of the Go SDK to manage charts #2770
Conversation
a2a1610
to
308f730
Compare
This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app license ID. Online Installer:
Airgap Installer (may take a few minutes before the airgap bundle is built):
Happy debugging! |
@@ -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 |
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.
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 |
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.
Does this mean i need helm install locally to run unit tests?
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.
yes, any other ideas? helm binary is currently a requirement for the dev env anyways.
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.
if you were to instantiate only one client as suggested you would not have to set the env var
pkg/helm/client.go
Outdated
// 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") |
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.
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.
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.
makes sense. i will update so there's a single helm client used by the cli / api.
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.
hmm this will make it hard to override the log function for the helm client and other operation specific fields.
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.
what if i pass the helm binary path explicitly from callers instead of using the goods package?
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.
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 |
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.
could you move addKubernetesCLIFlags to this package and export it or make this dynamic?
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.
can you elaborate? what do you mean by making it dynamic?
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 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
if h.airgapPath != "" { | ||
// Use chart from airgap path | ||
return filepath.Join(h.airgapPath, fmt.Sprintf("%s-%s.tgz", releaseName, chartVersion)), nil | ||
} |
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.
this never felt like it belonged in this package. perhaps something to address later
cmd/installer/cli/install.go
Outdated
restConfig, err := flags.kubernetesEnvSettings.RESTClientGetter().ToRESTConfig() | ||
restConfig, err := clientcmd.BuildConfigFromFlags("", flags.kubernetesEnvSettings.KubeConfig) |
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.
why change this? is it equivalent? what if i dont explicitly set the kubeconfig as a flag?
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.
good catch
LogFn action.DebugLog | ||
HelmPath string | ||
KubernetesEnvSettings *helmcli.EnvSettings | ||
K8sVersion string |
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.
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?
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.
it is used
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 see this is only used for render. should it be an argument to that function? or is that difficult?
999881f
to
5ee5bcf
Compare
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?
Does this PR require documentation?
NONE