Skip to content
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

Implement Helm library #16

Merged
merged 9 commits into from
Dec 7, 2023
Merged

Implement Helm library #16

merged 9 commits into from
Dec 7, 2023

Conversation

mateoflorido
Copy link
Member

Summary

This pull request adds a library for managing Helm charts and includes a proof of concept for CLI entries (enable, disable) for components.

Changes

  • Integration of CoreDNS chart (version 1.11.1).
  • Addition of charts using the dump plugin to bundle them within the snap.
  • Implementation of a minimal CLI for enabling and disabling components.
  • Creation of a Helm library designed to manage the chart/release lifecycle.
  • PoC facade to enhance the integration between the CLI|REST API endpoints, and the Helm library.

FAQ

  • Why use the Helm SDK instead of a custom wrapper around the binary?: Using the Helm SDK offers streamlined integration with Helm's robust code, reducing the need for extensive boilerplate. Also, it ensures enhanced error handling capabilities, facilitating the debugging and maintenance.

@mateoflorido
Copy link
Member Author

Manual testing:

➜  k8s git:(KU-104/helm-wrapper) sudo ./bin/static/k8s enable dns -f ~/values.yaml
INFO[0000] Component dns enabled
➜  k8s git:(KU-104/helm-wrapper) k get cm -A
NAMESPACE         NAME                                                   DATA   AGE
kube-system       extension-apiserver-authentication                     6      11h
kube-system       kube-apiserver-legacy-service-account-token-tracking   1      11h
default           kube-root-ca.crt                                       1      11h
kube-node-lease   kube-root-ca.crt                                       1      11h
kube-public       kube-root-ca.crt                                       1      11h
kube-system       kube-root-ca.crt                                       1      11h
kube-system       ck-dns-coredns                                         1      45s
➜  k8s git:(KU-104/helm-wrapper) sudo ./bin/static/k8s disable dns
INFO[0000] Component dns disabled

@jnsgruk
Copy link
Member

jnsgruk commented Dec 5, 2023

➜  k8s git:(KU-104/helm-wrapper) sudo ./bin/static/k8s enable dns -f ~/values.yaml

Why does your binary expose -f values.yaml? That should definitely be hidden from our users?

Copy link
Contributor

@neoaggelos neoaggelos left a comment

Choose a reason for hiding this comment

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

Really nice work overall! Leaving some comments

I assumed that we wanted to have k8s only talk with k8sd. Is this simply a PoC that shows that this works, and a separate PR will move things to a components endpoint?

As for the charts, I would prefer keeping the tar.gz around unless we have to edit it somehow, things would be a lot more tidy (and has no functional differences)

I am also missing some tooling/README/doc that describes the process of upgrading the bundled charts (how do we fetch them? how do we tell k8s to use the new version? this could look like helm pull ... and update src/k8s/component/component.componentMap accordingly.

As a final comment, I would love to be able to quickly tell the component version, e.g. have things like:

charts/coredns-1.11.1.tgz
charts/cilium-1.15.0.tgz
...

src/k8s/cmd/k8s/k8s_enable.go Outdated Show resolved Hide resolved
src/k8s/cmd/k8s/k8s_enable.go Outdated Show resolved Hide resolved
src/k8s/cmd/k8s/k8s_enable.go Outdated Show resolved Hide resolved
src/k8s/pkg/helm/helm.go Outdated Show resolved Hide resolved
src/k8s/pkg/helm/helm.go Outdated Show resolved Hide resolved
src/k8s/pkg/helm/helm.go Outdated Show resolved Hide resolved
src/k8s/pkg/helm/helm.go Outdated Show resolved Hide resolved
src/k8s/pkg/k8s/component/component.go Outdated Show resolved Hide resolved
src/k8s/pkg/k8s/component/component.go Outdated Show resolved Hide resolved
src/k8s/pkg/helm/helm.go Outdated Show resolved Hide resolved
Copy link
Contributor

@bschimke95 bschimke95 left a comment

Choose a reason for hiding this comment

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

Great work @mateoflorido!

One thing:
We want the CLI to only interact with the REST API that is exposed by k8sd. I assume the current CLI implementation is for testing and will eventually moved to an /component endpoint in a future PR?

src/k8s/cmd/k8s/k8s_disable.go Show resolved Hide resolved
src/k8s/cmd/k8s/k8s_disable.go Outdated Show resolved Hide resolved
src/k8s/cmd/k8s/k8s_disable.go Outdated Show resolved Hide resolved
src/k8s/cmd/k8s/k8s_disable.go Outdated Show resolved Hide resolved
src/k8s/cmd/k8s/k8s_enable.go Outdated Show resolved Hide resolved
src/k8s/cmd/k8s/k8s_enable.go Outdated Show resolved Hide resolved
src/k8s/cmd/k8s/k8s_enable.go Outdated Show resolved Hide resolved
src/k8s/pkg/helm/helm.go Outdated Show resolved Hide resolved
src/k8s/pkg/k8s/component/component.go Outdated Show resolved Hide resolved
src/k8s/pkg/k8s/component/component.go Outdated Show resolved Hide resolved
src/k8s/pkg/helm/helm.go Outdated Show resolved Hide resolved
@mateoflorido
Copy link
Member Author

I have addressed (hopefully) all the comments in the code review. I have performed a refactor on the Helm package (now Component Manager) to make it more generic. Also, I removed the flags for setting values and additional configuration for the components.

Copy link
Contributor

@bschimke95 bschimke95 left a comment

Choose a reason for hiding this comment

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

Added some comments on how the component manager interface is used. Sorry that I haven't seen this in the first review iteration.

src/k8s/pkg/componentmanager/component.go Outdated Show resolved Hide resolved
src/k8s/cmd/k8s/k8s_enable.go Outdated Show resolved Hide resolved
src/k8s/pkg/componentmanager/component.go Outdated Show resolved Hide resolved
src/k8s/cmd/k8s/k8s_disable.go Outdated Show resolved Hide resolved
src/k8s/pkg/componentmanager/component.go Outdated Show resolved Hide resolved
src/k8s/pkg/k8s/component/component.go Outdated Show resolved Hide resolved
src/k8s/pkg/k8s/component/component.go Outdated Show resolved Hide resolved
@mateoflorido
Copy link
Member Author

I have switched to using a configuration file for defining the components, using Viper. Additionally, I have refactored the component package to make it more generic and decoupled from its implementation.

Copy link
Contributor

@bschimke95 bschimke95 left a comment

Choose a reason for hiding this comment

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

Cool stuff, @mateoflorido!
I really like the interface now.

One final question: The Refresh method is not yet used, is it?

src/k8s/pkg/component/component.go Outdated Show resolved Hide resolved
@mateoflorido mateoflorido merged commit dc41952 into main Dec 7, 2023
9 checks passed
@mateoflorido mateoflorido deleted the KU-104/helm-wrapper branch December 7, 2023 14:36
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.

4 participants