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

Update KEPS 2299 and 2953 #3097

Merged
merged 2 commits into from
Mar 17, 2022

Conversation

KnVerey
Copy link
Contributor

@KnVerey KnVerey commented Dec 24, 2021

  • One-line PR description: Updates KRM Function related KEPs as discussed in a meeting several weeks ago.

/cc @mengqiy @jeremyrickard

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory sig/cli Categorizes an issue or PR as relevant to SIG CLI. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 24, 2021
Comment on lines +293 to +298
- Absolute paths will be permitted, and will be subjected to a new load restriction rule that requires them to be within a specific root, such as `$XGD_CONFIG_HOME/kustomize/plugins`. This is needed to support airgap use cases, as discussed in https://github.com/kubernetes-sigs/kustomize/issues/4288.
+ This also provides a migration path for legacy exec plugins, which already exist in such a location. Kustomize should be able to derive Catalogs for them automatically in cases where they are already configured declaratively (i.e. do not require bespoke args).
Copy link

Choose a reason for hiding this comment

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

In the case of GitOps based workflows that support Kustomize (e.g. ArgoCD, Red Hat Advanced Cluster Management), this would require the user to be aware of what the absolute path to the plugin is on the container/system executing Kustomize. Ideally, that would continue to be an implementation detail that the user does not need to be aware of.

Could there be an additional Kustomize option that falls back to checking the root directory if the relative path to the plugin does not exist in the Kustomization directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that end users of a platform should not need to know where tools are installed for them. In this scenario, it sounds like we have up to three actors: the actor who runs the gitops platform that includes Kustomize, the actor who wants to run Kustomize for their app, and the actor who actually wrote a particular Kustomization. If I understand correctly, it's the first one that installs the plugins. If so, it seems to me that they could provide a Catalog of what they've installed, such that users wouldn't even need to reference the binary/container in their config anymore. This could be done by compiling the Catalog into their version of Kustomize, by including a flag with that Catalog in Kustomize invocations by default, and/or by exposing that Catalog to users through configuration. Users could configure additional catalogs to trust in their individual invocations, if they're able to install custom plugins as well. On the contrary, if allowing arbitrary code execution like that would be undesirable, the new system should allow the platform maintainer to compile versions of Kustomize that only trust the built-in catalog, and do not allow additional plugins to be trusted at runtime. Do those options sound reasonable?

Copy link

Choose a reason for hiding this comment

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

@KnVerey that sounds good. Thank you for your help!

As long as the GitOps platform has the ability to call Kustomize (through the Go API and/or the CLI) with only allowing the single trusted catalog, that would work for my use-case.

To make sure I understand this correctly, would the GitOps platform be able to just provide the --trusted-catalog argument to the local catalog when executing Kustomize using the user's kustomization? The user's kustomization would then only need to provide the plugin's configuration YAML like they do today for exec plugins. Is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As long as the GitOps platform has the ability to call Kustomize (through the Go API and/or the CLI) with only allowing the single trusted catalog, that would work for my use-case.

I've added a description of the option to disable adding catalogs at runtime in my latest commit, so we can remember that/why that option is needed.

To make sure I understand this correctly, would the GitOps platform be able to just provide the --trusted-catalog argument to the local catalog when executing Kustomize using the user's kustomization? The user's kustomization would then only need to provide the plugin's configuration YAML like they do today for exec plugins. Is that right?

You could do it that way, yes, but then end users would be able to add the flag as well if I've understood the setup correctly. To prevent that, you'd need to build a version of Kustomize that trusts your plugins only, automatically. I've added a story about this scenario to the KEP in my last commit. Either way, yes, the end user plugin configuration will just be the resource as in the legacy exec style today.

Copy link

Choose a reason for hiding this comment

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

@KnVerey that sounds good!

In the use-case of a GitOps platform, the user wouldn't typically specify how kustomize is called. Only the kustomization that they want build. As long as additional trusted catalogs cannot be added via the kustomization file(s), then I think runtime flags that the GitOps platform always uses when executing kustomize would suffice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, ok. That would work then. I got the impression that end users could kustomize the runtime flags from this Argo doc fwiw: https://argo-cd.readthedocs.io/en/stable/user-guide/kustomize/#kustomize-build-optionsparameters

Copy link

Choose a reason for hiding this comment

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

From my understanding, only the ArgoCD administrators would be able to set those ConfigMap entries.

- reserved `provider` field
- `Composition` implemented with an alpha GV and supported by `kustomize build`. This includes implementing the `transformer`, `transformersFrom`, `transformerOverrides` and `transformerOrder` fields.
- `ResourceGenerator` extracted as a transformer
- Introduce a way to use default `fieldSpecs` when invoking builtin transformers from the transformers field (and generators from the generators field, etc.).
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be a new thing in the list. Why do we need to support fieldSpecs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's something I discovered in making the PR to Kustomize. This is specific to builtin transformers, without access to which Composition isn't very useful. Most of them use fieldSpecs to determine what to do, and when given an empty list, they do nothing. When you use them via a top-level field, Kustomize automatically injects a lengthy set of defaults that work in most cases. But when you express them as transformers, the default is empty field spec, i.e. do nothing. Expecting end users to explicitly use a copy of the various defaults would be horrible UX, hence this action item. The good news is that someone is already working on it: kubernetes-sigs/kustomize#4461

keps/sig-cli/2953-kustomize-plugin-graduation/README.md Outdated Show resolved Hide resolved
keps/sig-cli/2953-kustomize-plugin-graduation/README.md Outdated Show resolved Hide resolved

1. Kustomize retrieves all trusted catalogs specified on the command line.
1. Kustomization is read. If it includes a `catalogs` field, that field is compared to the trusted catalogs from the command line. If any required catalogs have not been trusted, a warning is printed with the details of the missing catalog (which remains untrusted).
1. Kustomize reads the user's Kustomize preferences file and loads the list of default trusted catalogs, combining this with the list from the command line.
1. Kustomization is read. If it includes a `catalogs` field, that field is compared to the trusted catalogs. If any required catalogs have not been trusted, a warning is printed with the details of the missing catalog (which remains untrusted).
Copy link
Member

Choose a reason for hiding this comment

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

Should it be an error instead of a warning? Warning meaning the execution can still proceed, which is not the desired behavior based on our earlier discussion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The execution will still halt in the step below, if something from the catalog was actually needed. Trying to remember why we didn't want to just error out at this stage, and I think it is for scenarios where you might have a whole chain of Composition resources. Imagine a foundational layer sources Foo from catalog X and explicitly lists that catalog as a result. But the end user of the top-level Composition overrides the settings for Foo to use a custom version. So catalog X is still collected from the lower level Composition, but it is not used, so the end user should not be forced to authorize it.


By default, plugins not listed in a trusted catalog will not be executed and an error will be printed. The providers for these plugins must be listed explicitly in each plugin config, and additional flags are always required to use them. Which flags are required depends on the provider type.

For plugins distributed as containers, the `--enable-container-plugins` flag will need to be provided. The containers will continue to be denied disk and network access by default. To enable access, the existing network/mount restriction flags will be retained but renamed to clarify what they govern: `--plugin-container-networks=[STRING]` `--plugin-container-mounts=[STRING]`.
Copy link
Member

Choose a reason for hiding this comment

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

Is the network flag a binary flag? If so, maybe using --enable-plugin-container-networks is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current flag is a named network: --network-name string

@KnVerey KnVerey force-pushed the update_kustomize_krm_keps branch from 9fe3861 to 0dbe5bf Compare February 23, 2022 22:16
@KnVerey KnVerey requested a review from mengqiy February 23, 2022 22:16
@mengqiy
Copy link
Member

mengqiy commented Feb 28, 2022

/retest

@mengqiy
Copy link
Member

mengqiy commented Feb 28, 2022

/lgtm
/approve

/hold
Add hold label in case there are actions still required to address comments from @mprahl. If there are nothing to address, please feel free to unhold.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 28, 2022
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: KnVerey, mengqiy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mengqiy
Copy link
Member

mengqiy commented Feb 28, 2022

CI is failing, please fix

@KnVerey KnVerey force-pushed the update_kustomize_krm_keps branch from fcafa2d to 9bf8fbb Compare February 28, 2022 20:12
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2022
@KnVerey KnVerey force-pushed the update_kustomize_krm_keps branch from 9bf8fbb to da69692 Compare February 28, 2022 23:18
@KnVerey
Copy link
Contributor Author

KnVerey commented Mar 1, 2022

@mengqiy I believe my last commit addressed @mprahl feedback, and I've fixed CI.

@mengqiy
Copy link
Member

mengqiy commented Mar 17, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 17, 2022
@mengqiy
Copy link
Member

mengqiy commented Mar 17, 2022

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 17, 2022
@k8s-ci-robot k8s-ci-robot merged commit a48c19f into kubernetes:master Mar 17, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.24 milestone Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants