Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Develop Component resource for: kubernetes:kustomize:Directory (#3036)
<!--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 ```
- Loading branch information