Skip to content

Commit

Permalink
Helm Chart v4 (Component) (#2947)
Browse files Browse the repository at this point in the history
<!--Thanks for your contribution. See [CONTRIBUTING](CONTRIBUTING.md)
    for Pulumi's contribution guidelines.

    Help us merge your changes more quickly by adding more details such
    as labels, milestones, and reviewers.-->

### Proposed changes

<!--Give us a brief description of what you've done and what it solves.
-->
This PR implements an MLC-based `Chart` resource as per [design
doc](https://docs.google.com/document/d/1_DZlsAyG4-3BxrAkJBj8R6wIVuzhAkxRDyq8k_Zcst4/edit?usp=sharing).

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](https://www.pulumi.com/docs/concepts/assets-archives/) 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:
```yaml
type: kubernetes:helm.sh/v4:Chart
properties:
  namespace: cert-manager
  chart: ./cert-manager
```

Repository Chart:
```yaml
# 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:
```yaml
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:
```yaml
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:
```yaml
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:
```yaml
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:
```yaml
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)

<!--Refer to related PRs or issues: #1234, or 'Fixes #1234' or 'Closes
#1234'.
Or link to full URLs to issues or pull requests in other GitHub
repositories. -->

Fixes #2847
  • Loading branch information
EronWright authored May 15, 2024
1 parent ad58732 commit e7249ac
Show file tree
Hide file tree
Showing 69 changed files with 7,573 additions and 96 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Fix Chart previews when the cluster is unreachable. (https://github.com/pulumi/pulumi-kubernetes/pull/2992)
- Fix a panic that could occur when a missing field became `null`. (https://github.com/pulumi/pulumi-kubernetes/issues/1970)
- Add field manager's name to server-side apply conflict errors. (https://github.com/pulumi/pulumi-kubernetes/pull/2983)
- Helm Chart V4 (https://github.com/pulumi/pulumi-kubernetes/pull/2947)

## 4.11.0 (April 17, 2024)

Expand Down
1 change: 1 addition & 0 deletions provider/cmd/pulumi-gen-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func generateSchema(swaggerPath string) schema.PackageSpec {
// This is to mostly filter resources from the spec.
var resourcesToFilterFromTemplate = codegen.NewStringSet(
"kubernetes:helm.sh/v3:Release",
"kubernetes:helm.sh/v4:Chart",
"kubernetes:yaml/v2:ConfigFile",
"kubernetes:yaml/v2:ConfigGroup",
)
Expand Down
168 changes: 165 additions & 3 deletions provider/cmd/pulumi-resource-kubernetes/schema.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions provider/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0
github.com/onsi/ginkgo/v2 v2.15.0
github.com/onsi/gomega v1.31.0
github.com/pkg/errors v0.9.1
github.com/pulumi/cloud-ready-checks v1.1.0
github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.0.0
github.com/pulumi/pulumi-kubernetes/tests/v4 v4.0.0-20240302002028-652829a1ed71
Expand All @@ -32,6 +33,7 @@ require (
helm.sh/helm/v3 v3.14.3
k8s.io/api v0.30.0
k8s.io/apimachinery v0.30.0
k8s.io/cli-runtime v0.30.0
k8s.io/client-go v0.30.0
k8s.io/kube-openapi v0.0.0-20240411171206-dc4e619f62f3
k8s.io/kubectl v0.30.0
Expand Down Expand Up @@ -216,7 +218,7 @@ require (
k8s.io/apiserver v0.29.0 // indirect
k8s.io/component-base v0.30.0 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
oras.land/oras-go v1.2.4 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1
Expand Down Expand Up @@ -292,7 +294,6 @@ require (
github.com/pgavlin/fx v0.1.6 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect
github.com/pulumi/esc v0.6.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand All @@ -307,7 +308,6 @@ require (
golang.org/x/tools v0.18.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311173647-c811ad7063a7 // indirect
k8s.io/cli-runtime v0.30.0 // indirect
lukechampine.com/frand v1.4.2 // indirect
sigs.k8s.io/controller-runtime v0.15.0 // indirect
)
Loading

0 comments on commit e7249ac

Please sign in to comment.