-
Notifications
You must be signed in to change notification settings - Fork 227
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
Declarative function storage mounts are ignored #1151
Comments
I agree with that:
I would also explicitly mention the 'security-related' reasoning: we don't want the author of the function to set the absolute path in the user system that would be mounted to the function container. Just imagine that src is set to '/' - that will allow function that works as a Trojan horse to steal some data from the user machine. User isn't supposed to check all function declaration before running to make sure it's 'safe'. BUT
The condition for this is: if src is relative.
Why it may be useful: This would allow to use mount in the kpt pipeline only for the functions that really need mounts rather than to set a 'common' mount-list for all functions in the pipeline, even though only 1 really uses it. I think cc: @Shell32-Natsu |
Just as an example of the previous comment I've drafted the initial commit representing how it should work: kubernetes-sigs/kustomize#3336 and the more I'm thinking about that the more I like that relative path idea: |
@aodinokov question about your use case - are you trying to do in place transformation of the yaml files in the package? Are you trying to read/write some other files that happen to be in the same directory. I am curious what the higher order goal is beyond having access to the package directory and files within. |
@mikebz my use-case was "how to provide krm-function I use as generator with some additional files (not necessarily yamls) in the same directory or subdirectory". e.g. helm with some values.yaml to override values. Here is the example. And here is its config. The part about
With the proposal from kubernetes-sigs/kustomize#3336 the part with yaml files as resources becomes possible even though it's a bit artificial. If I try to generalize this - generator-like krm functions abilities will be extended by this feature since in addition to setting the values in their config it will be possible to link some external files. |
As pointed out, there are security concerns, and to lesser extend portability concerns here. It’s desirable to be able to run functions hermetically without any privileges; preventing access to the host filesystem and networking (Talking to network also introduces non-determinism which is a separate discussion) . KRM functions are packaged and executed as container containers. By default, functions run as user nobody without any privileges such as access to host network or host volume. In the ideal world, any file required by the function is either:
We're still exploring and gathering concrete use cases for functions that require a non-KRM resource from the host file system, and whether they can be formulated in a better way. There are security mitigations that can be done (file being local to the directory containing the function config is one such option). A concrete use case where this comes up is a Helm inflator function where the function depends on a Helm chart which is not a KRM resource. There are different ways to formulate this:
|
A concrete use case for this is khelm. Ideally as a user I don't want to bother with mounts at all but just be able to specify local file paths as function parameters, relative to the Kptfile or function.yaml (also see #1531).
While I prefer the latter it comes with the problem that the Helm chart directory usually needs to be maintained outside of the kpt directory since the invalid yaml within the templates makes kpt fail to read the function input otherwise. |
This is considered part of privileged execution which is only allowed when running functions imperatively in kpt 1.0. This topic is discussed here: https://kpt.dev/book/04-using-functions/02-imperative-function-execution?id=privileged-execution We want to avoid mounting of any kind for declarative execution. Most use cases we've seen can be formulated as running a priviledged function once instead of repeatedly as part of the pipeline. e.g. Expand a Helm chart into a directory with Your suggestion of wrapping non-yaml in a KRM (e.g. a FileBlob resource kind) automatically is interesting and worth exploring more. Current proposal for supporting non-KRM files is for functions to define such wrappers and having a pre-processor function to inject file content into the wrapper. See #2350 |
That's true and still allows declarative usage of such a kpt package as a dependency for others. However unfortunately that means that parts of the kpt workflow still have to be done imperatively although I'd like to declare them as well.
While I understand the security concern behind that decision mounting files would be more efficient than copying non-KRM files. The latter could result in poor performance (impacting UX) for pipelines that rely on many/large non-KRM files.
That's interesting. Supporting a
To solve both problems the Kptfile could support the declaration of a list of directories/files that should be wrapped into KRM/ Secrets like git credentials or a Helm registries.yaml from the host still cannot be injected directly this way - using sealed secrets that could work as well though.
For binary blobs my only use case so far is to inject the helm cache into a function run. However for that to work the function would also need to be able write cached chart files and repo index yamls back to disk on the host. Though I guess khelm could as well do so by returning |
IMO just because something is one-off instead of typical Maybe it would be possible to have alternative pipelines, so the same syntax can be used, and because it's no longer part of the |
Re-raising kubernetes-sigs/kustomize#3141 here as suggested.
It seems like a decision has been made to make KRM function storage mounts imperative-only because as mentioned by @Shell32-Natsu:
In my experience, one of the main benefits of KRM functions is the ability for a package consumer to compose functions and apply them to pulled packages. Kptfiles allow you to declaratively specify functions that get applied during a
sync
operation (here) which makes it possible to apply a series of transformation and validation functions to packages as they are synced from upstream. Making certain properties of KRM functions imperative-only feels like it goes against the direction of the recent declarative setters proposal.The text was updated successfully, but these errors were encountered: