-
Notifications
You must be signed in to change notification settings - Fork 231
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
Design and implementation of "built-in" functions #1905
Comments
Related idea: Multiple functions (e.g., set namespace, name, labels, annotations) could be bundled into the same container, though I'm sure it would affect the UX some. |
In addition to setters, common kustomize-style transforms (names, namespaces, labels, annotations), and common validation functions, the Starlark runtime is a prime candidate as a built-in function also. |
I actually think that having a special in-process mechanism for running Starlark functions would be advantageous. I know it used to be in-process and was moved to a container like all the other functions, but the current strategy of having all functions be in a container has some negative consequences:
If we make Starlark functions a special type of function that run in-process it would have the following benefits:
We could even integrate with Cloud Code so that syntax highlighting and IDE features work when writing Starlark in KRM. In this world, functions would be pretty trivial to write, could be used both client-side and server-side, and would even be usable for validating and mutating webhooks. You could use the same validation functions in kpt, Config Sync, and Policy Controller. This would really unify the Anthos Config Management story around a single ecosystem of functions for both config and policy. |
I think after being in the market for a year and getting feedback and comparison to existing tools like
Here are my candidates for built in (this is a subset of kustomize):
I think these are generally useful and the behavior is well understood. |
@mikebz Yes, it's a good idea to have some common functions built into Kpt and totally agree with those 3 reasons you listed. I saw you've called it out several times and here's more detailed reasons why it's not planned:
|
Currently, there is no notion of built-in functions. The first-party function images in
gcr.io/kpt-fn
have no special meaning or treatment and are released and versioned independently from the kpt CLI. This is by design and has many benefits:One disadvantage of this approach (See #1838 (comment)) is that the user is exposed to, and needs to think about, version management for even basic functions. To address this, we can provide a porcelain on top of the existing functionality without creating fundamentally different mechanisms under the hood.
Strawman:
In addition to supporting fully specified function images e.g.:
gcr.io/kpt-fn/set-labels:v1
We can support a notation for functions in the
gcr.io/kpt-fn
registry, e.g.:set-labels
This will resolve to a container image with a fully specified semver, e.g.:
gcr.io/kpt-fn/set-labels:v1.2.3
This resolution is done by lookin up manifest of functions baked into the CLI, e.g.:
This manifest is is cut with the release of the CLI and contains the latest stable version of each function in
kpt-fn
registry at the time.Caveats:
gcr.io/kpt-fn/set-labels:v1.2.3
) and built-in (e.g.set-labels
) in the same package hierarchy. If the user wants to prevent the former (at the risk of incompatibility with off-the-shelf packages), there needs to be an orthogonal mechanism. See Fine-grained control allowed functions and their privilege usingFunctionPermission
#1904The text was updated successfully, but these errors were encountered: