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

Helm Chart v4 (Component) #2947

Merged
merged 41 commits into from
May 15, 2024
Merged

Helm Chart v4 (Component) #2947

merged 41 commits into from
May 15, 2024

Conversation

EronWright
Copy link
Contributor

@EronWright EronWright commented Apr 12, 2024

Proposed changes

This PR implements an MLC-based Chart resource as per design doc.

Notable improvements over v3:Chart:

  • Input schema more closely resembles v3:Release.
  • Performs templating in an online mode.
  • More control over resource ordering via annotation: config.kubernetes.io/depends-on
  • Uses Pulumi Assets for supplemental files (keyring, repository opts).
  • Use assets as values files (--values) and as individual values (--set-file).
  • Use multiple values files.
  • Support for post-rendering w/ arguments.
  • OCI registry support.

Detailed changes:

  • [pkg/helm] introduce a reusable Helm tool wrapper
  • [pkg/gen] define helm.sh/v4:Chart resource plus v4:PostRenderer,v4:RepositoryOpts
  • [provider] initialize the Helm EnvSettings based on provider configuration
  • [provider/helmv4] implement Chart resource provider
  • [provider/yamlv2] add PreRegisterF hook to be able to mutate child resource options, specifically RetainOnDelete
  • [provider/yamlv2] new gomega matcher: HaveSkipAwaitAnnotation()
  • [tests/testdata] new 'reference' chart for testing purposes
  • [misc] bugfix for kube client settings

Tests:

  • New suite for Chart provider w/ coverage of all in-scope features
  • Extended tests for provider Construct RPC to cover namespacing, kube client settings, helm release settings

Examples

See the examples in the API docs:
https://github.com/pulumi/pulumi-kubernetes/blob/47a6ae4fceb8339c49d4f13b5f765af798c0308b/provider/pkg/gen/examples/overlays/chartV4.md#example-usage

Local Chart:

type: kubernetes:helm.sh/v4:Chart
properties:
  namespace: cert-manager
  chart: ./cert-manager

Repository Chart:

# helm repo add bitnami https://charts.bitnami.com/bitnami
type: kubernetes:helm.sh/v4:Chart
properties:
  namespace: cert-manager
  chart: bitnami/cert-manager
  version: "1.1.0"

Remote Chart:

type: kubernetes:helm.sh/v4:Chart
properties:
  namespace: cert-manager
  chart: cert-manager
  version: "1.1.0"
  repositoryOpts:
    repo: https://charts.bitnami.com/bitnami

OCI Chart:

type: kubernetes:helm.sh/v4:Chart
properties:
  namespace: cert-manager
  chart: oci://registry-1.docker.io/bitnamicharts/cert-manager
  version: "1.1.0"

Custom Values:

type: kubernetes:helm.sh/v4:Chart
properties:
  namespace: cert-manager
  chart: oci://registry-1.docker.io/bitnamicharts/cert-manager
  version: "1.1.0"
  values:
    installCRDs: false
    notes:
      fn::fileAsset: notes.txt
  valueYamlFiles:
  - fn::fileAsset: values.yaml

Chart Verification w/ Keyring:

type: kubernetes:helm.sh/v4:Chart
properties:
  namespace: cert-manager
  chart: oci://registry-1.docker.io/eronwrightpulumi/cert-manager
  version: "1.1.0"
  verify: true
  keyring:
    fn::fileAsset: "public.pgp"

Post-Rendering:

type: kubernetes:helm.sh/v4:Chart
properties:
  namespace: cert-manager
  chart: oci://registry-1.docker.io/bitnamicharts/cert-manager
  version: "1.1.0"
  postRenderer:
    command: ./kustomize
    args: []

Related issues (optional)

Fixes #2847

@EronWright EronWright changed the title Chart v4 (Component) [WIP] Chart v4 (Component) Apr 12, 2024
Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.

New resources:

  • helm.sh/v4.Chart

Copy link

codecov bot commented Apr 12, 2024

Codecov Report

Attention: Patch coverage is 61.04746% with 238 lines in your changes are missing coverage. Please review.

Project coverage is 32.29%. Comparing base (ad58732) to head (a27f402).

Files Patch % Lines
provider/pkg/helm/tool.go 48.51% 113 Missing and 26 partials ⚠️
provider/pkg/provider/helm/v4/chart.go 74.04% 23 Missing and 11 partials ⚠️
provider/pkg/logging/log_writer.go 25.00% 27 Missing ⚠️
provider/pkg/helm/values.go 68.96% 10 Missing and 8 partials ⚠️
provider/pkg/helm/fake.go 80.00% 8 Missing and 4 partials ⚠️
provider/pkg/gen/schema.go 0.00% 4 Missing ⚠️
provider/pkg/provider/provider.go 92.85% 1 Missing and 1 partial ⚠️
provider/pkg/provider/util.go 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2947      +/-   ##
==========================================
+ Coverage   29.99%   32.29%   +2.29%     
==========================================
  Files          63       69       +6     
  Lines        8338     8947     +609     
==========================================
+ Hits         2501     2889     +388     
- Misses       5615     5791     +176     
- Partials      222      267      +45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This was referenced Apr 12, 2024
@EronWright EronWright closed this Apr 12, 2024
@EronWright EronWright reopened this Apr 12, 2024
@EronWright EronWright requested review from rquitales and blampe May 1, 2024 23:52
@EronWright EronWright force-pushed the eronwright/chartv4 branch from a8f65ff to 2186e1d Compare May 2, 2024 00:09
@EronWright EronWright marked this pull request as ready for review May 2, 2024 00:18
@EronWright EronWright changed the title [WIP] Chart v4 (Component) Helm Chart v4 (Component) May 2, 2024
Copy link
Contributor

@blampe blampe left a comment

Choose a reason for hiding this comment

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

Crazy thought experiment, partly out of curiosity and partly to help me better understand our wrapping:

Let's pretend newRootCmd is public, so we have a NewRootCmd that gives us a cobra.Command encapsulating all of helm's functionality.

We can feed that cobra.Command raw arguments with something like cmd.SetArgs([]string{"install", "--values", ...})), and we can execute it like any other command.

I'm curious what functionality we would lose, or what would no longer be expressible, if we reduced everything to parsing Pulumi's inputs → mapping those to CLI args → feeding that to the CLI command?

Obviously the command's outputs would be awkward to work with, but there's also the really appealing upside of always matching upstream...

provider/pkg/provider/helm/v4/chart_test.go Outdated Show resolved Hide resolved
provider/pkg/provider/helm/v4/chart_test.go Show resolved Hide resolved
provider/pkg/provider/helm/v4/chart_test.go Outdated Show resolved Hide resolved
provider/pkg/gen/examples/overlays/chartV4.md Outdated Show resolved Hide resolved
provider/pkg/logging/log_writer.go Outdated Show resolved Hide resolved
provider/pkg/helm/values.go Outdated Show resolved Hide resolved
provider/pkg/provider/provider.go Show resolved Hide resolved
provider/pkg/helm/keyring.go Outdated Show resolved Hide resolved
provider/pkg/provider/helm/v4/chart.go Show resolved Hide resolved
provider/pkg/provider/helm/v4/chart_test.go Show resolved Hide resolved
@EronWright EronWright force-pushed the eronwright/chartv4 branch from d797696 to 5342b6b Compare May 10, 2024 18:08
@EronWright EronWright requested a review from blampe May 13, 2024 20:03
provider/pkg/gen/examples/overlays/chartV4.md Outdated Show resolved Hide resolved
provider/pkg/gen/examples/overlays/chartV4.md Outdated Show resolved Hide resolved
provider/pkg/gen/examples/overlays/chartV4.md Show resolved Hide resolved
provider/pkg/helm/tool.go Show resolved Hide resolved
provider/pkg/helm/tool.go Show resolved Hide resolved
provider/pkg/helm/tool.go Show resolved Hide resolved
provider/pkg/provider/helm/v4/chart.go Show resolved Hide resolved
provider/pkg/provider/helm/v4/chart.go Outdated Show resolved Hide resolved
tests/gomega/kube.go Outdated Show resolved Hide resolved
@EronWright EronWright requested a review from blampe May 14, 2024 22:13
provider/pkg/gen/overlays.go Show resolved Hide resolved
provider/pkg/helm/fake.go Outdated Show resolved Hide resolved
limitations under the License.
*/

// package helm contains code vendored from the upstream Helm project.
Copy link
Member

Choose a reason for hiding this comment

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

Wondering what our maintenance strategy is for this vendored fork? Are we going to try and track upstream changes closely? If so, maybe a quick doc.go that describes how this code was vendored and the releavant changes made, if any?

Copy link
Member

Choose a reason for hiding this comment

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

Also it appears that we have our own code within the vendored code in this file? If so, should we also include a Pulumi license to this file? Not sure what the correct procedure here is.

Copy link
Contributor Author

@EronWright EronWright May 14, 2024

Choose a reason for hiding this comment

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

I too was wondering about that but I'm pretty sure we've done enough with the headers. The vendoring was done simply by copy-paste of certain functions. I think we'll keep iterating on the tool soon, e.g. for a Release v4 resource.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to headers being sufficient.

Part of the motivation behind my suggestion here was to help reduce non-upstream code, because otherwise things will start to get intermingled and harder to keep in sync.

It might make sense to break out our pulumi-specific stuff into its own package (pulumihelm or something) to make tracking upstream easier, but we don't need to do that now.

@EronWright EronWright requested a review from rquitales May 14, 2024 23:24
Copy link
Contributor

@blampe blampe left a comment

Choose a reason for hiding this comment

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

I'm still really curious if we can remove the custom MergeValues but that doesn't need to block. Let's do it!

@EronWright EronWright merged commit e7249ac into master May 15, 2024
18 checks passed
@EronWright EronWright deleted the eronwright/chartv4 branch May 15, 2024 23:16
lumiere-bot bot referenced this pull request in coolguy1771/home-ops May 24, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@pulumi/kubernetes](https://pulumi.com)
([source](https://togithub.com/pulumi/pulumi-kubernetes)) | dependencies
| minor | [`4.11.0` ->
`4.12.0`](https://renovatebot.com/diffs/npm/@pulumi%2fkubernetes/4.11.0/4.12.0)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>pulumi/pulumi-kubernetes (@&#8203;pulumi/kubernetes)</summary>

###
[`v4.12.0`](https://togithub.com/pulumi/pulumi-kubernetes/blob/HEAD/CHANGELOG.md#4120-May-21-2024)

[Compare
Source](https://togithub.com/pulumi/pulumi-kubernetes/compare/v4.11.0...v4.12.0)

##### Added

- Added a new Helm Chart v4 resource.
([https://github.com/pulumi/pulumi-kubernetes/pull/2947](https://togithub.com/pulumi/pulumi-kubernetes/pull/2947))
- Added support for deletion propagation policies (e.g. Orphan).
([https://github.com/pulumi/pulumi-kubernetes/pull/3011](https://togithub.com/pulumi/pulumi-kubernetes/pull/3011))
- Server-side apply conflict errors now include the original field
manager's name.
([https://github.com/pulumi/pulumi-kubernetes/pull/2983](https://togithub.com/pulumi/pulumi-kubernetes/pull/2983))

##### Changed

- Pulumi will now wait for DaemonSets to become ready.
([https://github.com/pulumi/pulumi-kubernetes/pull/2953](https://togithub.com/pulumi/pulumi-kubernetes/pull/2953))
- The Release resource's merge behavior for `valueYamlFiles` now more
closely matches Helm's behavior.
([https://github.com/pulumi/pulumi-kubernetes/pull/2963](https://togithub.com/pulumi/pulumi-kubernetes/pull/2963))

##### Fixed

- Helm Chart V3 previews no longer fail when the cluster is unreachable.
([https://github.com/pulumi/pulumi-kubernetes/pull/2992](https://togithub.com/pulumi/pulumi-kubernetes/pull/2992))
- Fixed a panic that could occur when a missing field became `null`.
([https://github.com/pulumi/pulumi-kubernetes/issues/1970](https://togithub.com/pulumi/pulumi-kubernetes/issues/1970))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNzEuMSIsInVwZGF0ZWRJblZlciI6IjM3LjM3MS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJ0eXBlL21pbm9yIl19-->

Co-authored-by: lumiere-bot[bot] <98047013+lumiere-bot[bot]@users.noreply.github.com>
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.

Develop Component resource for: kubernetes:helm:v4:Chart
3 participants