Deploying a Task Application in Kubernetes

This guide walks through how to deploy and run a simple spring-cloud-task application on Kubernetes by using Spring Cloud Data Flow.

We deploy the sample billsetuptask application to Kubernetes.

Setting up SCDF the Kubernetes Cluster

For this guide, we need a running Kubernetes cluster with Spring Cloud Data Flow deployed. For this example, we use minikube.

Verifying that Spring Cloud Data Flow is Running

When SCDF is running on Kubernetes, you should see the scdf-server pod in a Running state and the associated service created. You can use the following command (shown with typical output) to see the scdf-server:

kubectl get all -l app=scdf-server NAME READY STATUS RESTARTS AGE pod/scdf-server-65789665d-79hrz 1/1 Running 0 5m39s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/scdf-server LoadBalancer 10.109.181.91 <pending> 80:30403/TCP 5m39s NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/scdf-server 1/1 1 1 5m39s NAME DESIRED CURRENT READY AGE replicaset.apps/scdf-server-65789665d 1 1 1 5m39s

NOTE: On Minikube, EXTRNAL-IP = <pending> for the service is normal.

Building a Docker Image for the Sample Task Application

  1. Clone or download the dataflow samples git repo and navigate to the batchsamples directory. You can download the batch samples project from your browser or run the following command to download it from the command-line:
wget "https://github.com/spring-cloud/spring-cloud-dataflow-samples/blob/main/dataflow-website/batch-developer-guides/batch/batchsamples/dist/batchsamples.zip?raw=true" -O batchsamples.zip
  1. Build The project using the instructions from the readme file.
  2. Navigate to the billsetuptask directory
  3. Run the following commands to build the docker image:
eval $(minikube docker-env) ./mvnw spring-boot:build-image -Dspring-boot.build-image.imageName=springcloudtask/billsetuptask:0.0.1-SNAPSHOT

These commands add the image to the minikube Docker registry.

  1. Verify its presence by finding springcloudtask/billsetuptask in the list of images provided by running the following command:

    docker images

Registering, Creating, and Launching the Task by Using Data Flow

We use the Data Flow Dashboard to set up and launch the billsetuptask application.

First, we need to get the SCDF Server URL, which we can do with the following command (the listing includes the output):

minikube service --url scdf-server http://192.168.99.100:30403

Now you can follow the instructions to register and launch a task application using Data Flow, using the docker image we just built to register the application.