Skip to content

Commit 1193970

Browse files
committed
update
1 parent 4f55d49 commit 1193970

1 file changed

Lines changed: 73 additions & 33 deletions

File tree

doc/design.md

Lines changed: 73 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ spec:
101101
We hope Fluid users could represent it by the following line.
102102

103103
```python
104-
skaffold_git = fluid.Git(
104+
skaffold_git = fluid.git_resource(
105105
revision="master",
106106
url="https://github.com/GoogleContainerTools/skaffold)
107107
```
@@ -125,7 +125,7 @@ spec:
125125
We hope Fluid users could represent the above YAML file by the following line.
126126

127127
```python
128-
skaffold_image_leeroy_web = fluid.Image(
128+
skaffold_image_leeroy_web = fluid.image_resource(
129129
url="gcr.io/wangkuiyi/leeroy-web")
130130
```
131131

@@ -142,7 +142,7 @@ According to the [document](https://github.com/tektoncd/pipeline/blob/master/doc
142142
The following example from the [Tekton tutorial](https://github.com/tektoncd/pipeline/blob/master/docs/tutorial.md#task-inputs-and-outputs) takes an input resource, an output resource, and two input parameters.
143143

144144
```yaml
145-
goapiVersion: tekton.dev/v1alpha1
145+
apiVersion: tekton.dev/v1alpha1
146146
kind: Task
147147
metadata:
148148
name: build-docker-image-from-git-source
@@ -185,28 +185,30 @@ We hope Fluid users could represent it by the following Python/Fluid code.
185185

186186
```python
187187
def build_docker_image_from_git_source(
188+
docker_source: "input,git",
189+
built_image: "output,image",
190+
path_to_dockerfile="/workspace/docker-source/Dockerfile",
191+
path_to_context="/workspace/docker-source"):
192+
'''Define a Tekton Task that builds a Docker image from a Git repo'''
193+
couler.step(image="gcr.io/kaniko-project/executor:v0.14.0",
194+
cmd=["/kaniko/executor"],
195+
args=[f"--dockerfile={path_to_dockerfile}",
196+
f"--destination={built_image.url}",
197+
f"--context={path_to_context}"],
198+
env={"DOCKER_CONFIG": "/tekton/home/.docker/"})
188199
```
189200

190201
### Pipeline
191202

192-
A Pipeline object is like function decleration.
193-
194-
A Pipeline in Tekton defined an ordered series of Tasks. A valid Pipeline declearation
195-
must include a reference to at last one `Task`, for example:
196-
197-
``` yaml
198-
tasks:
199-
- name: build-the-image
200-
taskRef:
201-
name: build-push
202-
```
203+
A Pipeline object is like function declaration.
203204

204-
The `Pipeline Tasks` in a Pipeline can be connected and run as a Directed Acyclic Graph(DAG), each of the Pipeline Tasks is a node, which can be connected with:
205+
A Pipeline in Tekton defined an ordered series of Tasks. A valid Pipeline declaration
206+
must include a reference to at last one `Task`, The `Pipeline Tasks` in a Pipeline can be connected and run as a Directed Acyclic Graph(DAG), each of the Pipeline Tasks is a node, which can be connected with:
205207

206208
- `runAfter` clauses on the `Pipeline Tasks`.
207209
- `from` clauses on the `PipelineResources` needed by a `Task`.
208210

209-
For an example `Pipeline` spec with `runAfter`:
211+
The following example `Pipeline` spec comes from [Tekton's Pipeline tutorial](https://github.com/tektoncd/pipeline/blob/master/docs/pipelines.md):
210212

211213
``` yaml
212214
- name: lint-repo
@@ -279,44 +281,82 @@ build-app build-frontend
279281
In Python, a function is like a node of the DAG, which connected by the input
280282
and of output of the functions.
281283

282-
We hope Fluid users can write the following program to express a DAG with `fluid.pipeline`:
284+
We hope Fluid users can write the following program to express a DAG with `fluid.pipeline` as the following code:
283285

284286
``` python
287+
288+
WORKSPACE = fluid.git_resource(
289+
url="https://github.com/GoogleContainerTools/skaffold",
290+
revision="master")
291+
292+
APP_IMAGE = fluid.image_resource()
293+
294+
FRONTED_IMAGE = fluid.image_resource()
295+
285296
@fluid.task
286-
def pylint():
287-
fluid.step(...)
297+
def pylint(workspace:"input,git"):
298+
fluid.step(image="ubuntu", cmd=["pylint"])
288299
289300
@fluid.task
290-
def make_test():
291-
fluid.step(...)
301+
def make_test(workspace:"input,git"):
302+
fluid.step(image="ubuntu", cmd=["make"], args=["test"])
292303
293304
@fluid.task
294-
def kaniko_build_app():
305+
def kaniko_build_app(workflow:"input,git", image:"output,image"):
295306
fluid.step(...)
296307
297308
@fluid.task
298-
def kaniko_build_frontend():
309+
def kaniko_build_frontend(workflow:"input,git", image:"output,image"):
299310
fluid.step(...)
300311
301312
@fluid.task
302-
def deploy_kubectl():
313+
def deploy_kubectl(my_frontend_image:"input,image", my_app_image:"input,image"):
303314
fluid.step(...)
304315
305316
@fluid.pipeline
306317
def dag_demo():
307-
lint_repo = pylint()
308-
test_app = make_test()
309-
build_app = kaniko_build_app().run_after(test_app)
310-
build_frontend = kaniko_build_frontend().run_after(test_app)
311-
deploy_all = deploy_kubectl()
312-
deploy_all.inputs.my_frontend_image.from(build_app)
313-
deploy_all.inputs.my_app_image.from(build_frontend)
318+
lint_repo = pylint(WORKSPACE)
319+
test_app = make_test(WORKSPACE)
320+
build_app = kaniko_build_app(WORKSPACE, APP_IMAGE).run_after(test_app)
321+
build_frontend = kaniko_build_frontend(WORKSPACE, FRONTEND_IMAGE).run_after(test_app)
322+
323+
deploy_all = deploy_kubectl(APP_IMAGE, FRONTEND_IMAGE)
324+
deploy_all.my_frontend_image.from(build_app)
325+
deploy_all.my_app_image.from(build_frontend)
314326
```
315327

316328
### PipelineRun
317329

318-
A PipelineRun object is like a function invocation:
330+
A PipelineRun object is like a function invocation.
331+
332+
A PipelineRun object defines a call to a Pipeline. The following is a PipelineRun example from [Tekton's tutorial](https://github.com/tektoncd/pipeline/blob/master/docs/tutorial.md#creating-and-running-a-pipeline):
333+
334+
``` yaml
335+
apiVersion: tekton.dev/v1beta1
336+
kind: PipelineRun
337+
metadata:
338+
name: tutorial-pipeline-run-1
339+
spec:
340+
serviceAccountName: tutorial-service
341+
pipelineRef:
342+
name: tutorial-pipeline
343+
resources:
344+
- name: source-repo
345+
resourceRef:
346+
name: skaffold-git
347+
- name: web-image
348+
resourceRef:
349+
name: skaffold-image-leeroy-web
350+
```
351+
352+
We hope Fluid users write the following program:
319353

320354
``` python
321-
build_pipeline()
355+
skaffold_git = fluid.git_resource(
356+
revision="master",
357+
url="https://github.com/GoogleContainerTools/skaffold")
358+
skaffold_image_leeroy_web = fluid.image_resource(
359+
url="gcr.io/wangkuiyi/leeroy-web")
360+
361+
tutorial(skaffold_git, skaffold_image_leeroy_web)
322362
```

0 commit comments

Comments
 (0)