This tutorial shows you how to write a Fluid program, convert it into a Tekton workflow, and run it on a Kubernetes cluster on your computer.
-
Install Minikube on macOS.
brew install minikube minikube start
If you are not using macOS, please follow this tutorial. After a successful installation, you can check the nodes (VM) running Minikube using the command
kubectl get nodes. -
Install Tekton.
kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
For more details, you can check this tutorial. You can type the command
kubectl get pods --namespace tekton-pipelinesto check related Pods are running. -
Install the Tekton Dashboard (optional).
kubectl apply --filename https://github.com/tektoncd/dashboard/releases/download/v0.3.0/dashboard-latest-release.yaml
To check Fluid from Github, type the following command.
git clone https://github.com/wangkuiyi/fluidTo tell Python where Fluid is, you can set the PYTHONPATH environment variable.
export PYTHONPATH=$PWD/fluid:$PYTHONPATHThe following example.py file defines a Task with two steps and two input parameters and runs the Task.
import fluid
@fluid.task
def echo_hello_world(hello, world="El mundo"):
fluid.step(image="ubuntu", cmd=["echo"], args=[hello])
fluid.step(image="ubuntu", cmd=["echo"], args=[world])
echo_hello_world("Aloha")To compile it into a Tekton YAML file, run the Python program.
python example.py > example.yamlThe Python function definition of echo_hello_world becomes the Task object in example.yaml. The call to echo_hello_world becomes a TaskRun object.
To run the example.yaml file, type the following command.
kubectl apply -f example.yamlTo check the status, type the kubectl get tekton-pipelines command. You will see some output like the following.
$ kubectl get tekton-pipelines
NAME AGE
task.tekton.dev/echo-hello-world 4m18s
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
taskrun.tekton.dev/echo-hello-world-run True Succeeded 4m18s 117s
The command tkn taskrun describe echo-hello-world-run checks details of the TaskRun object. Type tkn taskrun logs echo-hello-world-run to check logs.
$ tkn taskrun logs echo-hello-world-run
[example-py-12] Aloha
[example-py-13] El mundo
To view the dashboard in a Web browser, you need to map the Tekton Dashboard to a local port using the following command.
kubectl --namespace tekton-pipelines port-forward svc/tekton-dashboard 9097:9097Then, direct your Web browser to localhost:9097. You will be able to check all kinds of Kubernetes objects supported by Tekton.
