{"id":16813077,"url":"https://github.com/ivanvc/dispatcher","last_synced_at":"2025-04-05T09:24:01.126Z","repository":{"id":66900189,"uuid":"552131805","full_name":"ivanvc/dispatcher","owner":"ivanvc","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-29T05:51:25.000Z","size":544,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T06:28:14.530Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivanvc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-15T22:25:43.000Z","updated_at":"2025-03-29T05:50:28.000Z","dependencies_parsed_at":"2024-11-11T08:26:24.269Z","dependency_job_id":"a679464f-3f35-4f74-a8db-bd3bd039d9a3","html_url":"https://github.com/ivanvc/dispatcher","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanvc%2Fdispatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanvc%2Fdispatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanvc%2Fdispatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanvc%2Fdispatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivanvc","download_url":"https://codeload.github.com/ivanvc/dispatcher/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247313765,"owners_count":20918691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T10:24:34.668Z","updated_at":"2025-04-05T09:24:01.105Z","avatar_url":"https://github.com/ivanvc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dispatcher\nDispatcher is a simple Kubernetes job enqueuer. It uses job templates stored\nin the cluster, and exposes an HTTP service to enqueue them.\n\nIt uses a job template\ndefinition stored in a JobTemplate CRD, and it then executing it is done through\ncreating a JobExecution. Invoking a JobExecution can be done through its HTTP\nAPI. Therefore, executing jobs doesn't require clients to know the actual job\ntemplate, but just the job's name.\n\n## Description\nThe first step to use Dispatcher, is to have a JobTemplate (CRD) defined in\nthe cluster. The JobTemplate CRD defines the spec from\n`batchv1.JobTemplateSpec`, so the syntax is the same as defining a CronJob or a\nJob.\n\nGiven a JobTemplate like with the following definition:\n\n```yaml\napiVersion: dispatcher.ivan.vc/v1alpha1\nkind: JobTemplate\nmetadata:\n  name: jobtemplate-sample\nspec:\n  jobTemplate:\n    spec:\n      template:\n        spec:\n          containers:\n          - name: my-container\n            image: alpine:latest\n            command: [\"echo\", \"$PAYLOAD\"]\n            env:\n            - name: PAYLOAD\n              value: \"{{ .Payload }}\"\n          restartPolicy: Never\n      backoffLimit: 0\n```\n\nIt can be executed by manually creating a JobExecution (CRD), or by calling the\nHTTP API endpoint. Although the former is possible, is the least desired way to\nexecute a Job.\n\nManually executing the previously defined JobTemplate, can be done by creating\nthe following JobExecution:\n\n```yaml\napiVersion: dispatcher.ivan.vc/v1alpha1\nkind: JobExecution\nmetadata:\n  name: jobexecution-sample\nspec:\n  jobTemplateName: jobtemplate-sample\n  payload: my test payload\n```\n\nThe dispatcher controller will create a Job using the `jobexecution-sample`\ntemplate, and will feed `Payload` with `\"my test payload\"`. Therefore, the\noutput of the job would be just a simple echo of this payload.\n\nThe best way to execute the JobTemplate would be using the HTTP API endpoint, it\ncould be done by calling:\n\n```bash\ncurl http://dispatcher-manager/execute/[namespace]/jobexecution-sample -X PUT -d\n'my test payload'\n```\n\nReplace `[namespace]` with the actual namespace where you created the\nJobTemplate. You can also configure a default namespace (by default it is\n`\"default\"`), and omit the namespace from the URL path.\n\nBy running this, it will create a JobExecution, that will create a Job with the\npayload that it received from the HTTP request body.\n\n## Getting Started\nYou’ll need a Kubernetes cluster to run against. You can use\n[KIND](https://sigs.k8s.io/kind) to get a local cluster for testing, or run\nagainst a remote cluster. **Note:** Your controller will automatically use the\ncurrent context in your kubeconfig file (i.e. whatever cluster `kubectl\ncluster-info` shows).\n\n### Running on the cluster\n1. Install Instances of Custom Resources:\n\n```sh\nkubectl apply -f config/samples/\n```\n\n2. Build and push your image to the location specified by `IMG`:\n\t\n```sh\nmake docker-build docker-push IMG=\u003csome-registry\u003e/dispatcher:tag\n```\n\t\n3. Deploy the controller to the cluster with the image specified by `IMG`:\n\n```sh\nmake deploy IMG=\u003csome-registry\u003e/dispatcher:tag\n```\n\n### Uninstall CRDs\nTo delete the CRDs from the cluster:\n\n```sh\nmake uninstall\n```\n\n### Undeploy controller\nUnDeploy the controller to the cluster:\n\n```sh\nmake undeploy\n```\n\n## Contributing\nPull Requests are welcome for new features. If you have any issues or ideas to\ndiscuss, feel free to open an issue.\n\n### How it works\nThis project aims to follow the Kubernetes [Operator\npattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/)\n\nIt uses\n[Controllers](https://kubernetes.io/docs/concepts/architecture/controller/)\nwhich provide a reconcile function responsible for synchronizing resources\nuntile the desired state is reached on the cluster.\n\n### Test It Out\n1. Install the CRDs into the cluster:\n\n```sh\nmake install\n```\n\n2. Run your controller (this will run in the foreground, so switch to a new terminal if you want to leave it running):\n\n```sh\nmake run\n```\n\n**NOTE:** You can also run this in one step by running: `make install run`\n\n### Modifying the API definitions\nIf you are editing the API definitions, generate the manifests such as CRs or CRDs using:\n\n```sh\nmake manifests\n```\n\n**NOTE:** Run `make --help` for more information on all potential `make` targets\n\nMore information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html)\n\n## License\n\nCopyright 2022 Ivan Valdes.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanvc%2Fdispatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivanvc%2Fdispatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanvc%2Fdispatcher/lists"}