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

Task(s) to manage kubernets resources in a cluster #233

Closed
afrittoli opened this issue Mar 20, 2020 · 24 comments
Closed

Task(s) to manage kubernets resources in a cluster #233

afrittoli opened this issue Mar 20, 2020 · 24 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@afrittoli
Copy link
Member

Feature description

In the context of MLOps, but most likely also beyond that, it's a common use case to create / update / delete kubernetes resources as part of a Tekton pipeline.

The proposal here is to have a task or set of tasks in the catalog that would define a standard way of doing that in Tekton, which a clear and re-usable interface.

Inputs would be:

  1. The resource meta, including type, name (template), namespace, labels and annotations, and the spec which could be an arbitrary JSON/YAML, which we would have to define how it is conveyed to the task
  2. The target cluster, which could be a cluster PipelineResource or a set of params
  3. The operation to be performed - i.e. create, replace, delete

This would be about managing single resources, so it shall not support provisioning the content of a folder or a generic YAML with multiple resources.

This could be implemented as one generic tasks that takes rather generic inputs, which could be usable for all resources, but have a weak validation - or a set of tasks, one per resource type, at least for common resources, which could have more strict checks on input params.

@vdemeester
Copy link
Member

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 23, 2020
@vdemeester
Copy link
Member

@afrittoli should this issue take over #37 ? 🙃

@afrittoli
Copy link
Member Author

#37

Oh, I. missed that one :)

We, we could do that. I guess for deployments we might also have tasks that support provisioning a set of resources at once, so everything that is needed to deploy a service (including deployment, configmap, secrets, ingress etc).

@ckadner
Copy link

ckadner commented Mar 23, 2020

This could be implemented as one generic task that takes rather generic inputs, which could be usable for all resources, but have a weak validation - or a set of tasks, one per resource type, at least for common resources, which could have more strict checks on input params.

In order to streamline that implementation from a KFP-Tekton compiler perspective, we would like to follow the precedence laid out by Argo's ResourceTemplate, and create one generic task with the following parameters:

  • action: ['get', 'create', 'apply', 'delete', 'replace', 'patch'] -- the action to perform to the resource
  • merge_strategy: ['strategic', 'merge', 'json'] -- the strategy used to merge a patch, defaults to "strategic"
  • success_condition: a label selector expression which describes the success condition
  • failure_condition: a label selector expression which describes the failure condition
  • manifest: the kubernetes manifest

@animeshsingh
Copy link

@vincent-pli @vdemeester @afrittoli this is a high priority requirement coming from our internal product teams. Would be good to know how can we get this prioritized? I have also discussed these with the OpenShift pipelines team, the relevance and importance of the work effort.

@vincent-pli
Copy link
Member

Could we just use image with kubectl and use workspace to mount related yaml files to the task, then make path of the yaml file as parameter then define create, delete as args...

@ckadner
Copy link

ckadner commented Mar 24, 2020

We want to use the new "ResourceTask" via a taskRef in our pipelines and provide the manifest YAML as a string parameter without having to create files workspaces file mounts etc.

For implementing the task, I think a kubectl wrapper image would be okay. Especially from a maintenance point of view since anyone working with Kubernetes would be able to understand the commands, fix issues, try command locally, etc.

@ckadner
Copy link

ckadner commented Mar 24, 2020

A quick searching of DockerHub brings up this kubectl image that looks promising and has 10M+ pulls (Apache 2.0 license):

There are also a few recipes to cook up a custom kubectl image:

@vincent-pli
Copy link
Member

@ckadner
and this one:

image: gcr.io/cloud-builders/kubectl # it is huge

@Tomcli
Copy link

Tomcli commented Mar 24, 2020

In Argo it was done in the controller since they already have kubectl binary in the controller image.
https://github.com/argoproj/argo/blob/master/workflow/executor/resource.go#L22-L76

@Tomcli
Copy link

Tomcli commented Mar 24, 2020

After we create/delete the resource, we also need to return a status to tell whether this is up running/deleted.

@vincent-pli
Copy link
Member

@Tomcli
I think a kubectl wrapper could satisfy you with some extra work.
for example:

  • Create a pod, stuck until the pod is running:
    you need extra loop to watch the status of pod.
  • Create a pod, stuck until the pod complete and make decision base on output of the pod:
    then you could mount the same pvc (from the workspace) to the new created pod...

@animeshsingh
Copy link

@vincent-pli is this something you want to take forward? Get this pushed in tekton, and we can leverage it as part of KFP?

@vincent-pli
Copy link
Member

@animeshsingh
OK, I think I can make pr for kubectl wrapped example but no loop monitoring as @Tomcli mentioned.

@vincent-pli
Copy link
Member

#237

@Tomcli Tomcli mentioned this issue Mar 26, 2020
3 tasks
@ckadner
Copy link

ckadner commented Mar 26, 2020

Thanks for your PR @vincent-pli. I just took a quick look, but I only saw one parameter resource. Ideally we would need 4 more as I described in my comment above:

#233 (comment)

  • action: ['get', 'create', 'apply', 'delete', 'replace', 'patch'] -- the action to perform to the resource
  • merge_strategy: ['strategic', 'merge', 'json'] -- the strategy used to merge a patch, defaults to "strategic"
  • success_condition: a label selector expression which describes the success condition
  • failure_condition: a label selector expression which describes the failure condition
  • manifest: the kubernetes manifest

Assuming your parameter resource really is the manifest, could we add action even if initally it only supports default action create or apply?

@vincent-pli
Copy link
Member

@ckadner

Sorry for delay, involved in a tough project.
The function you mentioned is correct and needed for a complete kubernete resource hendler features, it's too complex to just with script and yml, I think it should be a pre-prepared image.

Whatever, I will dig into and check if i can found something.

@Tomcli
Copy link

Tomcli commented Apr 15, 2020

Thanks @vincent-pli, maybe you can add you kubeclient task for this? We still have some edge cases for the results that we love to have support such as kubeflow/kfp-tekton#94

@vincent-pli
Copy link
Member

Thanks @Tomcli , I add some draft code to address your requirement, please check that:https://github.com/vincent-pli/kubectl-wrapper

@animeshsingh
Copy link

thanks folks - @vincent-pli great to see this coming in as a PR soon

vincent-pli added a commit to vincent-pli/catalog that referenced this issue Apr 29, 2020
The requirements discussed in tektoncd#233
- action: ['get', 'create', 'apply', 'delete', 'replace', 'patch'] -- the action to perform to the resource
- merge_strategy: ['strategic', 'merge', 'json'] -- the strategy used to merge a patch, defaults to "strategic"
- success_condition: a label selector expression which describes the success condition
- failure_condition: a label selector expression which describes the failure condition
- manifest: the kubernetes manifest"
vincent-pli added a commit to vincent-pli/catalog that referenced this issue May 1, 2020
The requirements discussed in tektoncd#233
- action: ['get', 'create', 'apply', 'delete', 'replace', 'patch'] -- the action to perform to the resource
- merge_strategy: ['strategic', 'merge', 'json'] -- the strategy used to merge a patch, defaults to "strategic"
- success_condition: a label selector expression which describes the success condition
- failure_condition: a label selector expression which describes the failure condition
- manifest: the kubernetes manifest"
vincent-pli added a commit to vincent-pli/catalog that referenced this issue May 20, 2020
The requirements discussed in tektoncd#233
- action: ['get', 'create', 'apply', 'delete', 'replace', 'patch'] -- the action to perform to the resource
- merge_strategy: ['strategic', 'merge', 'json'] -- the strategy used to merge a patch, defaults to "strategic"
- success_condition: a label selector expression which describes the success condition
- failure_condition: a label selector expression which describes the failure condition
- manifest: the kubernetes manifest"
tekton-robot pushed a commit that referenced this issue Jun 10, 2020
The requirements discussed in #233
- action: ['get', 'create', 'apply', 'delete', 'replace', 'patch'] -- the action to perform to the resource
- merge_strategy: ['strategic', 'merge', 'json'] -- the strategy used to merge a patch, defaults to "strategic"
- success_condition: a label selector expression which describes the success condition
- failure_condition: a label selector expression which describes the failure condition
- manifest: the kubernetes manifest"
@tekton-robot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

/close

Send feedback to tektoncd/plumbing.

@tekton-robot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.

/lifecycle stale

Send feedback to tektoncd/plumbing.

@tekton-robot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

@tekton-robot
Copy link

@tekton-robot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

/close

Send feedback to tektoncd/plumbing.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests

7 participants