Deploy the Example to a GKE cluster
Once the application is built you need to publish the docker images to some registry that stores, manages and secures your application images.
In this example we will use the GCloud registry
Follow these steps to complete the process of publishing:
Set up the target environment of publishing in your local build process. Create a file named
target-env.sbtin the root of your project folder (the same level where you have
build.sbt). The file needs to have the following 2 lines:
// Google Cloud Registry ThisBuild / cloudflowDockerRegistry := Some("eu.gcr.io") ThisBuild / cloudflowDockerRepository := Some("<gcloud project id>")
project id refers to the ID of your Google Cloud Platform project.
This can be found on the project page of your Google Cloud Platform.
Publish the docker image of your project to the above registry. This has 3 steps:
First make sure that you have access to the cluster
gcloud container clusters get-credentials <cluster-name>
And that you have access to the Google docker registry
gcloud auth configure-docker
Then build and publish the application
Once the image is successfully published, you will see something like the following as output of
buildApp in your console:
[info] Successfully built and published the following image: [info] eu.gcr.io/bubbly-observer-178213/sensor-data-scala:471-89ca008 [success] Cloudflow application CR generated in /.../sensor-data-scala/target/sensor-data-scala.json [success] Use the following command to deploy the Cloudflow application: [success] kubectl cloudflow deploy /path/to/sensor-data-scala/target/sensor-data-scala.json [success] Total time: 41 s, completed Jun 10, 2020 10:10:10 PM
At this point, the Docker image containing the streamlets has been published to the Docker repository.
sensor-data-scala.json file that the build produces contains the application descriptor.
We use the Cloudflow CLI to deploy that application description to a cluster.
This is quite straightforward and the output of
buildApp actually tells you what command to run for deployment.
In addition you need to supply the credentials to the Docker repository along with the CLI
$ kubectl cloudflow deploy /path/to/sensor-data-scala/target/sensor-data-scala.json -u oauth2accesstoken -p "$(gcloud auth print-access-token)"
If the command goes through you will see the following output:
[Done] Deployment of application `sensor-data-scala` has started.
Once all streamlets are up in their pods, you can see them running using the following command:
$ kubectl cloudflow status sensor-data-scala Name: sensor-data-scala Namespace: sensor-data-scala Version: 484-199a3c1-dirty Created: 2020-06-10 22:28:32 +0200 CEST Status: Running STREAMLET POD READY STATUS RESTARTS http-ingress sensor-data-scala-http-ingress-6f4b677c84-8gtk7 1/1 Running 0 invalid-logger sensor-data-scala-invalid-logger-f76667866-lffmk 1/1 Running 0 metrics sensor-data-scala-metrics-859d9cf974-vrpzs 1/1 Running 0 valid-logger sensor-data-scala-valid-logger-6946746b4b-bpqdc 1/1 Running 0 validation sensor-data-scala-validation-b7f85669d-kkpx9 1/1 Running 0
Note that all streamlets run in a namespace that matches the name of the application.
Congratulations! You have deployed and started your first Cloudflow application.
Now, we are ready to Exercise the example.