Code Monkey home page Code Monkey logo

trinity's Introduction

Trinity

Trinity Workflow is a utility that allows you to create simple workflows that can be scheduled to run. It makes use of a custom operator and a custom resource definition for workflows. It relies on Kubernetes CronJobs to schedule and execute Workflows based on the cron schedule.

Important Terms

  1. Workflow
    A Workflow consists of multiple tasks that are executed as jobs in a sequence. It is a custom resource definition and its schema is available under deployments/crd.yaml file.

  2. Task
    A Task is an individual step within a workflow that will be executed in a separate pod. It also has access to the outputs of the previous task. If the task generates an artifact ,say .zip file, it is possible to use this artifact in other tasks of the same workflow.

    You can run a single inline command in a task or execute a shell script. Output of command execution and the status of the task (failed or success) is captured as a part of Workflow execution.

  3. Run
    The execution status of a Workflow and its tasks are updated under status field of the Workflow. An execution of a Workflow is called as a RUN.

  4. Operator
    This is a custom controller that keeps track of all the workflows that are getting created, updated and deleted and updates the state in Kubernetes objects like CronJobs. For instance when you create a workflow, operator will automatically create a cronjob and schedule it to run based on the schedule that was mentioned in the Workflow.

Installation

  1. Deploy the custom resource definition under deployments/crd.yaml.
  2. Next deploy the deployments/deployment.yaml manifest. This will deploy a clusterrole,clusterrolebinding,deployment that will run a workflow controller. Make sure that the kubeconfig has sufficient permission to deploy these objects.
  3. Now, you can start deploying your workflows. To begin with use the sample workflow available under examples/basic.yaml.

Inline vs Script

  1. Inline accepts a command as string and an optional array of arguments for this command.
tasks:
  - name: task1    
    command:
      inline:
        command: "ls"
        args: ["-a"]
  1. Script accepts multiline shell commands that will be executed as a script.
tasks:
  - name: task2   
    command:
      script: "#!/bin/bash\n echo hostname"

Artifact Store

If you want to store a file or an artifact that you plan to use in other tasks, then you can turn on artifact store by setting storeartifacts: true. The default setting is false.

spec:
  schedule: "*/2 * * * *"
  storeartifacts: true

To store an artifact, move it to /artifacts/outgoing directory. Workflow will automatically scan for files under this directory for each task and upload the files to store. Similary if you want to use an artifact in other task, you can pick it up from /artifacts/incoming directory.

Workflow uses minio as an object storage. If storeartifacts is set to true, workflow will deploy minio and will use it to upload and download artifacts. This storage is available only during the execution of a workflow and will be removed once the workflow completes.

Check out the example examples/usingartifactstore.yaml

Note: Artifact download for first task and upload for last task will be automatically skipped.

Accessing output of previous task

In the current task,you can access the output of previous task using the environment variable WF_INPUT.

Check out the example examples/usinginputvar.yaml

Track the execution status of Workflow and its tasks

The status of a Workflow is available under the status field of the workflow. You can use kubectl describe workflow <workflow-name> or kubectl get workflow <workflow-name> -o json to view the results of the execution. Workflow will maintain the results of all the executions under RUNS.

"status": {
                "runs": [
                    {
                        "ended_at": "02-14-2021 10:42:21",
                        "id": 1,
                        "phase": "completed",
                        "started_at": "02-14-2021 10:42:08",
                        "tasks": [
                            {
                                "error": "",
                                "name": "task1",
                                "output": "",
                                "status": "success"
                            },
                            {
                                "error": "",
                                "name": "task2",
                                "output": "Hello\n",
                                "status": "success"
                            }
                        ]
                    },

Features I am working on

  1. Option to use a user specified image for running tasks.
  2. Decision tree.

Contribution

A contribution to this project is welcome through a pull request. Moreover, I am not a full time golang developer and hence the code base might not be idiomatic. Any kind of help will be highly appreciated.

License

MIT License

trinity's People

Contributors

k-e-r-n-e-l-p-a-n-i-c avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.