-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Enabling custom actions to create new k8s resources #12174
Labels
enhancement
New feature or request
Comments
This would be extremely useful. A first step would be just to allow creation of any resources as it would enable #4116 |
3 tasks
This would be extremely helpful. Watching 👀 |
Apart from ad-hoc creation of Job from CronJob, what other uses of this feature are expected? |
12 tasks
crenshaw-dev
added a commit
that referenced
this issue
Jun 23, 2023
* Kind wildcard support in health customizations Signed-off-by: reggie <reginakagan@gmail.com> * Updated health customizations docs to using the correct field with a / Signed-off-by: reggie <reginakagan@gmail.com> * Updated health customizations docs to using the correct field with a / Signed-off-by: reggie <reginakagan@gmail.com> * Document resource kind wildcard for custom health check Signed-off-by: reggie <reginakagan@gmail.com> * Implemented wildcard * support in API Group and Resource Kind and updated docs Signed-off-by: reggie <reginakagan@gmail.com> * Implemented wildcard * support in API Group and Resource Kind and updated docs Signed-off-by: reggie <reginakagan@gmail.com> * Implemented wildcard * support in API Group and Resource Kind and updated docs Signed-off-by: reggie <reginakagan@gmail.com> * Added a custom create-from CronJob action Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * added a ns in the action.lua and fixed tests Signed-off-by: reggie <reginakagan@gmail.com> * create-job Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * more changes Signed-off-by: reggie <reginakagan@gmail.com> * full unit tests and action returning an array Signed-off-by: reggie <reginakagan@gmail.com> * cleanup Signed-off-by: reggie <reginakagan@gmail.com> * fix the custom tests Signed-off-by: reggie <reginakagan@gmail.com> * e2e tests Signed-off-by: reggie <reginakagan@gmail.com> * json marshaling annotations ImpactedResource, e2e tests and docs Signed-off-by: reggie <reginakagan@gmail.com> * more docs and tests Signed-off-by: reggie <reginakagan@gmail.com> * upstream sync Signed-off-by: reggie <reginakagan@gmail.com> * fix wrong return upon going over the impacted resources + docs + fixing e2e tests Signed-off-by: reggie <reginakagan@gmail.com> * docs Signed-off-by: reggie <reginakagan@gmail.com> * better error handling Signed-off-by: reggie <reginakagan@gmail.com> * K8SOperation as an enum Signed-off-by: reggie <reginakagan@gmail.com> * added dry-run for create operation Signed-off-by: reggie <reginakagan@gmail.com> * small changes Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * gitops engine dependency and test fixes Signed-off-by: reggie <reginakagan@gmail.com> * add workflows action Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * cronworkflow and workflowtemplate actions Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * update gitops-engine Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> --------- Signed-off-by: reggie <reginakagan@gmail.com> Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
yyzxw
pushed a commit
to yyzxw/argo-cd
that referenced
this issue
Aug 9, 2023
…12925) * Kind wildcard support in health customizations Signed-off-by: reggie <reginakagan@gmail.com> * Updated health customizations docs to using the correct field with a / Signed-off-by: reggie <reginakagan@gmail.com> * Updated health customizations docs to using the correct field with a / Signed-off-by: reggie <reginakagan@gmail.com> * Document resource kind wildcard for custom health check Signed-off-by: reggie <reginakagan@gmail.com> * Implemented wildcard * support in API Group and Resource Kind and updated docs Signed-off-by: reggie <reginakagan@gmail.com> * Implemented wildcard * support in API Group and Resource Kind and updated docs Signed-off-by: reggie <reginakagan@gmail.com> * Implemented wildcard * support in API Group and Resource Kind and updated docs Signed-off-by: reggie <reginakagan@gmail.com> * Added a custom create-from CronJob action Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * added a ns in the action.lua and fixed tests Signed-off-by: reggie <reginakagan@gmail.com> * create-job Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * more changes Signed-off-by: reggie <reginakagan@gmail.com> * full unit tests and action returning an array Signed-off-by: reggie <reginakagan@gmail.com> * cleanup Signed-off-by: reggie <reginakagan@gmail.com> * fix the custom tests Signed-off-by: reggie <reginakagan@gmail.com> * e2e tests Signed-off-by: reggie <reginakagan@gmail.com> * json marshaling annotations ImpactedResource, e2e tests and docs Signed-off-by: reggie <reginakagan@gmail.com> * more docs and tests Signed-off-by: reggie <reginakagan@gmail.com> * upstream sync Signed-off-by: reggie <reginakagan@gmail.com> * fix wrong return upon going over the impacted resources + docs + fixing e2e tests Signed-off-by: reggie <reginakagan@gmail.com> * docs Signed-off-by: reggie <reginakagan@gmail.com> * better error handling Signed-off-by: reggie <reginakagan@gmail.com> * K8SOperation as an enum Signed-off-by: reggie <reginakagan@gmail.com> * added dry-run for create operation Signed-off-by: reggie <reginakagan@gmail.com> * small changes Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * gitops engine dependency and test fixes Signed-off-by: reggie <reginakagan@gmail.com> * add workflows action Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * cronworkflow and workflowtemplate actions Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * update gitops-engine Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> --------- Signed-off-by: reggie <reginakagan@gmail.com> Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
leoluz
pushed a commit
to leoluz/argo-cd
that referenced
this issue
Sep 29, 2023
argoproj#516) * separating kubectl and resource ops mocks Signed-off-by: reggie <reginakagan@gmail.com> * separating kubectl and resource ops mocks Signed-off-by: reggie <reginakagan@gmail.com> * separating kubectl and resource ops mocks Signed-off-by: reggie <reginakagan@gmail.com> * server dry-run for MockKubectlCmd Signed-off-by: reggie <reginakagan@gmail.com> * server dry-run for MockKubectlCmd Signed-off-by: reggie <reginakagan@gmail.com> * server dry-run for MockKubectlCmd Signed-off-by: reggie <reginakagan@gmail.com> * mock create noop Signed-off-by: reggie <reginakagan@gmail.com> * ctl create resource with createOptions Signed-off-by: reggie <reginakagan@gmail.com> --------- Signed-off-by: reggie <reginakagan@gmail.com>
tesla59
pushed a commit
to tesla59/argo-cd
that referenced
this issue
Dec 16, 2023
…12925) * Kind wildcard support in health customizations Signed-off-by: reggie <reginakagan@gmail.com> * Updated health customizations docs to using the correct field with a / Signed-off-by: reggie <reginakagan@gmail.com> * Updated health customizations docs to using the correct field with a / Signed-off-by: reggie <reginakagan@gmail.com> * Document resource kind wildcard for custom health check Signed-off-by: reggie <reginakagan@gmail.com> * Implemented wildcard * support in API Group and Resource Kind and updated docs Signed-off-by: reggie <reginakagan@gmail.com> * Implemented wildcard * support in API Group and Resource Kind and updated docs Signed-off-by: reggie <reginakagan@gmail.com> * Implemented wildcard * support in API Group and Resource Kind and updated docs Signed-off-by: reggie <reginakagan@gmail.com> * Added a custom create-from CronJob action Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * added a ns in the action.lua and fixed tests Signed-off-by: reggie <reginakagan@gmail.com> * create-job Signed-off-by: reggie <reginakagan@gmail.com> * in progress Signed-off-by: reggie <reginakagan@gmail.com> * more changes Signed-off-by: reggie <reginakagan@gmail.com> * full unit tests and action returning an array Signed-off-by: reggie <reginakagan@gmail.com> * cleanup Signed-off-by: reggie <reginakagan@gmail.com> * fix the custom tests Signed-off-by: reggie <reginakagan@gmail.com> * e2e tests Signed-off-by: reggie <reginakagan@gmail.com> * json marshaling annotations ImpactedResource, e2e tests and docs Signed-off-by: reggie <reginakagan@gmail.com> * more docs and tests Signed-off-by: reggie <reginakagan@gmail.com> * upstream sync Signed-off-by: reggie <reginakagan@gmail.com> * fix wrong return upon going over the impacted resources + docs + fixing e2e tests Signed-off-by: reggie <reginakagan@gmail.com> * docs Signed-off-by: reggie <reginakagan@gmail.com> * better error handling Signed-off-by: reggie <reginakagan@gmail.com> * K8SOperation as an enum Signed-off-by: reggie <reginakagan@gmail.com> * added dry-run for create operation Signed-off-by: reggie <reginakagan@gmail.com> * small changes Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * ref to my gitops-engine fork out Signed-off-by: reggie <reginakagan@gmail.com> * gitops engine dependency and test fixes Signed-off-by: reggie <reginakagan@gmail.com> * add workflows action Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * cronworkflow and workflowtemplate actions Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> * update gitops-engine Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> --------- Signed-off-by: reggie <reginakagan@gmail.com> Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
Currently, custom actions are only updating the resource they are acting upon.
There is a need for them to be able to create new resources as well.
Motivation
#4116
Proposal
Custom actions will have the ability to return either a list of resources with an operation type to perform for each (just create, currently), or just a single resource, for backward compatibility.
It would be nice to have the ability to use yaml manifests/template files in Lua actions, but if io library is not considered safe for the use case, the Lua script will construct the yaml inline.
Lua libraries are of a limited use from security reasons.
So the actual creation of the new resources will have to be outside of Lua.
A permission check will have to take place, to ensure the NEW resources are allowed to be created for this app.
For example: if the custom action operates on a CronJob resource, and creates a new Job resource, the permission to create a Job resource kind has to be granted on Project level, either implicitly or explicitly.
If the user is rbac-allowed to invoke the action, the action can still FAIL upon invocation if no resource permissions are granted.
The operations that can be performed on resources, returned from Lua scripts, will be only "create" at this point.
Creating the new resource(s) will happen in the same component that currently performs the kubectl patch, resulting from the Lua action - the API Server.
Issues to decide on
Updating another resource will not be supported at this point because of security considerations.
There are semantycs around update and patch - the current actions return a resource in an update format, but actually a kubectl patch is performed.
Do we want to support an explicit "patch" operation in addition, so that the users can specify a jsonPatch or merge snippet, instead of a full resource?
Is there such a use case?
Tests:
The text was updated successfully, but these errors were encountered: