Skip to content

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
googs1025 committed Apr 2, 2024
1 parent 3e362d6 commit ad7b276
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
### 功能特性
- 支持 Job 之间的依赖关系
- 支持 Job 之间的全局参数传递(label,annotation,env)
- 支持 Job 之间的调度到同一节点
- 支持 Job 之间的共享数据卷 (./yaml/jobflow/example-shareVolume.yaml)
- 支持 Job 引用 JobTemplate 对象
- 支持 Job 之间的调度到同一节点 [example](./yaml/jobflow/example-sameNode.yaml)
- 支持 Job 之间的共享数据卷 [example](./yaml/jobflow/example-shareVolume.yaml)
- 支持 Job 引用 JobTemplate 对象 [example](./yaml/jobflow/example-jobTemplate.yaml)


![](./image/jobflow.png?raw=true)
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
Design Background: This project aims to implement a simple Job orchestration operator.

### JobFlow
Functionality: Native Job resources in Kubernetes do not have native orchestration features with dependencies (e.g., Job a completes -> execute Job b...). To address this requirement, a custom resource controller called JobFlow is implemented based on Kubernetes' extension capabilities. It enables the execution of multiple Job trees in an operator application.

Feature: Native Job resources in Kubernetes do not have native orchestration features with dependencies (e.g., Job a completes -> execute Job b...). To address this requirement, a custom resource controller called JobFlow is implemented based on Kubernetes' extension capabilities. It enables the execution of multiple Job trees in an operator application.
- Support dependencies between jobs
- Support global parameter passing between jobs(label,annotation,env)
- Supports scheduling between jobs to the same node [example](./yaml/jobflow/example-sameNode.yaml)
- Support shared data volumes between jobs [example](./yaml/jobflow/example-shareVolume.yaml)
- Supports Job references to JobTemplate objects [example](./yaml/jobflow/example-jobTemplate.yaml)

![](./image/jobflow.png?raw=true)

Expand All @@ -14,6 +18,9 @@ Functionality: Native Job resources in Kubernetes do not have native orchestrati
- name: flow name, multiple flow names cannot be repeated
- dependencies: Define dependencies. If there are multiple dependencies, we can fill in multiple
- jobTemplate: Job template that supports Kubernetes native job spec fields.
- jobTemplateRef: Job template instance, supports all fields of k8s native job spec, needs to fill in the JobTemplate name
- shareVolumes: job shared data volume
- shareVolumeMounts: job shared data volume mount
```yaml
apiVersion: api.practice.com/v1alpha1
kind: JobFlow
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ func (r *JobFlowController) findJobTemplateByNameNamespace(name, namespace strin
return jobTemplate.Spec.JobTemplate, nil
}

func (r *JobFlowController) prepareJob(jobFlow *jobflowv1alpha1.JobFlow, flow *jobflowv1alpha1.Flow, jobName string) (*batchv1.Job, error) {
func (r *JobFlowController) prepareJob(jobFlow *jobflowv1alpha1.JobFlow,
flow *jobflowv1alpha1.Flow, jobName string) (*batchv1.Job, error) {
// job 对象
job := &batchv1.Job{}

Expand Down
101 changes: 101 additions & 0 deletions yaml/jobflow/example-sameNode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
apiVersion: api.practice.com/v1alpha1
kind: JobFlow
metadata:
name: jobflow-example
spec:
# 可配置任务流中的全局参数,当设置后会在每个 job 与 pod 中都生效
globalParams:
# 可决定所有 job 都运行在同一节点上
nodeName: minikube
# 可加入 container 所需的参数
env:
- name: "FOO"
value: "bar"
- name: "QUE"
value: "pasa"
# job pod 的 annotations
annotations:
key1: value1
key2: value2
# job pod 的 labels
labels:
key1: value1
key2: value2

# 可填写多个 flow 流程
# 每个 flow 中重要字段 分别为:
# name: flow 名称,多个 flow 名称不能重复
# dependencies: 定义依赖项,如果有多个依赖可以填写多个
# jobTemplate: job 模版,支持 k8s 原生 job spec 全部字段
flows:
- name: job1
dependencies: []
jobTemplate:
template:
spec:
containers:
- image: busybox:1.28
command:
- sh
- -c
- sleep 10s
imagePullPolicy: IfNotPresent
name: nginx
- name: job2
jobTemplate:
template:
spec:
containers:
- image: busybox:1.28
command:
- sh
- -c
- sleep 100s
imagePullPolicy: IfNotPresent
name: nginx
dependencies:
- job1 # 代表 job2 依赖 job1 完成后才开始启动
- name: job3
jobTemplate:
template:
spec:
containers:
- image: busybox:1.28
command:
- sh
- -c
- sleep 100s
imagePullPolicy: IfNotPresent
name: nginx
dependencies:
# 代表 job3 依赖 job1 job2 完成后才开始启动
- job1
- job2
- name: job4
jobTemplate:
template:
spec:
containers:
- image: busybox:1.28
command:
- sh
- -c
- sleep 10s
imagePullPolicy: IfNotPresent
name: nginx
- name: job5
dependencies:
# 代表依赖 job2 job4 后才执行
- job4
- job2
jobTemplate:
template:
spec:
containers:
- image: busybox:1.28
command:
- sh
- -c
- sleep 10s
imagePullPolicy: IfNotPresent
name: nginx

0 comments on commit ad7b276

Please sign in to comment.