Spring Cloud Task allows a user to develop and run short lived microservices using Spring Cloud and run them locally or in the cloud. They can also be run as part of Spring Cloud Data Flow. We thought that it would be interesting if we could add a task runtime to riff to run tasks there. This document explains how to run a quick demo of this task runtime POC.
Download the riff-task-poc-demo.zip archive and unzip it in a riff-task-demo
directory.
mkdir riff-task-demo
cd riff-task-demo
wget https://storage.googleapis.com/riff-task-poc/riff-task-poc-demo.zip
unzip riff-task-poc-demo.zip
Install the riff-task controller and CRDs:
kubectl apply -f riff-task-controller.yaml
You should now see a new task-controller-mananger
running in the riff-system
namespace:
riff-system riff-build-controller-manager-fbbdff99f-kjn2n 2/2 Running 0 21h
riff-system riff-core-controller-manager-757d47f467-kwzjt 2/2 Running 0 21h
riff-system riff-knative-controller-manager-57df8759d8-vqkjh 2/2 Running 0 21h
riff-system riff-task-controller-manager-6fbdcfc8f8-f6q58 2/2 Running 0 13s
NOTE: The demo must be run from the directory where the zip archive was extracted. The download contains a custom
riff
CLI that has extra task commands included. Any time we run a riff command use./riff
as the start of any commands.
Open a separate terminal window and run the following watch:
watch kubectl get containers,tasklaunchers,taskexecutions,pods
Now we can create a riff image resource for the Spring Cloud Task sample timestamp-task
app:
./riff container create timestamp --image springcloudtask/timestamp-task:2.1.0.RELEASE
Next, we create a task launcher referencing the conatiner we just created:
./riff task launcher create timestamp --container-ref timestamp
Once that completes we can execute this launcher:
./riff task execution create --launcher-ref timestamp
That should start a bare pod for the timestamp task. We can see the logs for this pod using:
kubectl logs -l task.projectriff.io/launcher=timestamp
The log should contain a line that shows the timestamp
2019-10-04 14:01:34.803 INFO 1 --- [ main] TimestampTaskConfiguration$TimestampTask : 2019-10-04 14:01:34.803
We can now clean up any task resources:
kubectl delete pod -l task.projectriff.io/launcher=timestamp
kubectl delete taskexecutions --all
kubectl delete tasklaunchers timestamp
kubectl delete containers timestamp
To uninstall the riff-task-controller-manager and the CRDs run:
kubectl delete crd taskexecutions.task.projectriff.io
kubectl delete crd tasklaunchers.task.projectriff.io
kubectl delete -n riff-system service riff-task-controller-manager-metrics-service
kubectl delete -n riff-system deployment riff-task-controller-manager
kubectl delete -n riff-system rolebinding riff-task-leader-election-rolebinding
kubectl delete -n riff-system role riff-task-leader-election-role
kubectl delete clusterrolebinding riff-task-manager-rolebinding
kubectl delete clusterrolebinding riff-task-proxy-rolebinding
kubectl delete clusterrole riff-task-manager-role
kubectl delete clusterrole riff-task-proxy-role