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

Add helmChart support to kustomize.Directory resource #2470

Closed
jaxxstorm opened this issue Jun 26, 2023 · 8 comments
Closed

Add helmChart support to kustomize.Directory resource #2470

jaxxstorm opened this issue Jun 26, 2023 · 8 comments
Assignees
Labels
impact/usability Something that impacts users' ability to use the product easily and intuitively kind/enhancement Improvements or new features resolution/fixed This issue was fixed
Milestone

Comments

@jaxxstorm
Copy link
Contributor

jaxxstorm commented Jun 26, 2023

Some kustomize folders contain nested helm charts. To utilize these, you need to specify --enable-helm as an option

Updated description:
Kustomize optionally supports expanding helm charts with a plugin. We add experimental support for this feature in #2471 behind the PULUMI_K8S_KUSTOMIZE_HELM environment variable flag. If we decide to make this feature generally available, the following work still needs to be done:

  1. Add a configurable path option for the helm binary
  2. Add a test to verify that kustomization.Directory resources that don't use the helmChart feature do not require the helm binary to be present. This works currently, but could regress in the future.
  3. Remove the feature flag
@jaxxstorm jaxxstorm added kind/enhancement Improvements or new features needs-triage Needs attention from the triage team labels Jun 26, 2023
@jaxxstorm
Copy link
Contributor Author

Looks like we need to upgrade to krusty v0.14 to get this functionality

@jturolla
Copy link
Contributor

Looks like we need to upgrade to krusty v0.14 to get this functionality

Didn't see that on the api release for 0.14, am I looking in the right place? Where did you get this information from?

https://github.com/kubernetes-sigs/kustomize/releases/tag/api%2Fv0.14.0

@kpitzen
Copy link
Contributor

kpitzen commented Jun 28, 2023

Hi @jaxxstorm - could you provide a little more detail around what the desired design / UX looks like here? Is this an option we'd like to pass down through the pulumi cli to the provider? What would the intended behavior be when it is provided?

@kpitzen kpitzen added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Jun 28, 2023
@jaxxstorm
Copy link
Contributor Author

@kpitzen I'm not super familiar with this myself, but from a quick google:

https://github.com/kubernetes-sigs/kustomize/blob/master/examples/chart.md

The flag --enable-helm exists to have the user acknowledge that kustomize is running an external program as part of the build step. It's like the --enable-plugins flag, but with a helm focus.

I believe this just needs to be added to the provider

@lblackstone lblackstone removed the awaiting-feedback Blocked on input from the author label Jun 29, 2023
@lblackstone lblackstone changed the title Add --enable-helm command line option to kustomize resources Add helmChart support to kustomize.Directory resource Jun 29, 2023
@jturolla
Copy link
Contributor

jturolla commented Jun 29, 2023

Thanks for the effort, really looking forward to this release. That was super fast and I'm really happy with the result. 🙇‍♂️

@kpitzen kpitzen added the impact/usability Something that impacts users' ability to use the product easily and intuitively label Jun 29, 2023
@jaxxstorm
Copy link
Contributor Author

Looks like this was shipped in 3.30.1 so closing, thanks all!

@pulumi-bot pulumi-bot reopened this Jun 30, 2023
@pulumi-bot
Copy link
Contributor

Cannot close issue without required labels: resolution/

@lblackstone lblackstone added the resolution/fixed This issue was fixed label Jul 13, 2023
@lblackstone lblackstone self-assigned this Jul 13, 2023
@lblackstone lblackstone added this to the 0.91 milestone Jul 13, 2023
@EronWright
Copy link
Contributor

EronWright commented May 29, 2024

The long-term plan for Helm support in Kustomize: kubernetes-sigs/kustomize#4401

EronWright added a commit that referenced this issue May 31, 2024
<!--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

This PR implements the Kustomize `Directory` resource (v2) as a
multi-language component resource.

The `Directory` resource creates child resources based on a
kustomization directory. The input is a path to a directory containing
'kustomization.yaml', or a git repository URL with a path suffix and
other qualifiers.

### 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. -->

Closes #2786 

### API

|property|description|
|-|-| 
| `directory` | The directory or git URL containing the kustomization to
apply. |
| `namespace` | Overrides the default namespace. |
| `skipAwait` | Applies the skipAwait annotation. |
| `resourcePrefix` | Prefix for child resources, defaults to the
component name. |

### Feature: Remote Targets

This implementation supports remote kustomization targets as described
[here](https://github.com/kubernetes-sigs/kustomize/blob/master/examples/remoteBuild.md).

Note: the v1 implementation also supports git references, but resolves
them using the Pulumi SDK
([`RetrieveGitFolder`](https://github.com/pulumi/pulumi/blob/v3.117.0/sdk/go/common/workspace/templates.go#L392))
rather than using Kustomize's own implementation.

### Feature: Enable Alpha Plugins

This implementation always enables Kustomize's plugin support, akin to
`kustomize build --enable-alpha-plugins`.

Plugins are drawn from `KUSTOMIZE_PLUGIN_HOME` (default:
`~/.config/kustomize/plugin/`). Note: the kustomize library doesn't
allow for easy customization of the plugin home.

### Feature: Unrestricted Loading

Kustomize has a strict and a relaxed mode with respect to path
references outside the kustomization base directory
(`--load-restrictor`, default is `strict`). The feature seems intended
to encourage portability, similarly to paths in Dockerfiles. This
implementation simply enables the relaxed mode.

### Feature: Enable Helm Charts

This implementation enables [Helm chart support in
Kustomize](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/helmcharts/),
which is an experimental feature of Directory v1 (see:
#2470). Note that
chart support in Kustomize is limited and evolving; see
kubernetes-sigs/kustomize#4401 for the
long-term support plan.

The `helm` binary is assumed to be on the path.

### Feature: Namespace Override

New to v2 is support for overriding the default namespace (default is
from provider configuration), as a convenience. Kustomize itself has a
similar facility (see:
[namespace](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/namespace/))
but it makes sense to support it natively.

### Feature: Resource Ordering

The Directory resource uses Pulumi's engine to install the resources
produced by kustomize. It automatically detects dependencies between
some resources. For example, it knows to install namespaces and Custom
Resource Definitions (CRDs) first.

Use the `config.kubernetes.io/depends-on` annotation to declare an
explicit resource dependency. See [blog
post](https://www.pulumi.com/blog/kubernetes-yaml-v2/#resource-ordering)
for more info.

### Limitation: Kubernetes-Style Transformations

The older v1 implementation provides the ability to transform the
Kubernetes objects produced by kustomize before being sent to the
server. That feature isn't available in Directory v2 at this time. You
may still use Pulumi's [transform
option](https://www.pulumi.com/docs/concepts/options/transformations/)
to modify the child resources.

### Tests

The PR includes unit tests covering the provider implementation code.

### Example

Here's an example of deploying a couple of kustomizations. The `local`
kustomization (see:
[helloWorld](https://github.com/kubernetes-sigs/kustomize/tree/master/examples/helloWorld)
for details) shows how to use a variable to select a kustomization
overlay.

```yaml
name: issue-2786-yaml
runtime: yaml
description: |
  Demonstrates the Directory resource.
  Reference: https://github.com/kubernetes-sigs/kustomize/tree/master/examples/helloWorld
config:
  variant:
    type: string
    default: staging
outputs:
  name: ${local.resources}
resources:
  ns:
    type: kubernetes:core/v1:Namespace
  local:
    type: kubernetes:kustomize/v2:Directory
    properties:
      namespace: ${ns.metadata.name}
      directory: ./config/${variant}
      skipAwait: true
  remote:
    type: kubernetes:kustomize/v2:Directory
    properties:
      namespace: ${ns.metadata.name}
      directory: https://github.com/kubernetes-sigs/kustomize//examples/helloWorld/?ref=v3.3.1
      skipAwait: true
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/usability Something that impacts users' ability to use the product easily and intuitively kind/enhancement Improvements or new features resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

6 participants