TAP Part 4 – Developing and Deploying First Application on Tanzu Application Platform

In this blog post, I will talk about how easily you can create a scaffold for your Java based application and deploy it. TAP make this very easy for us with the help of accelerators and it also comes with few out of the box accelerators. We will be using accelerator to generate a scaffold and then deploy the application.

#1 Use Case: Developing Application

Thinking from a developer perspective, you are planning to develop a Java based application and deploy it on a Kubernete platform without knowing the complexity of the underlying Kubernetes platform.

So, as a developer, you will get readymade accelerators to speedup the application development.

Let’s create the scaffold for your application now.

– Login to TAP GUI

– Navigate to the Create option

– Choose Tanzu Java Web App

– Provide the required detail as shown in the below screenshot.


Image Repository name is a combination of SERVER/REPOSITORY-NAME you have provided in tap-values.yaml file during tap install/update.
Name, You can provide the application name or leave the default one.

– You can also explore the project by clicking on EXPLORE button and the following detail will be displayed.

– Explore the important files like config/workload.yaml and Tiltfile. I will talk about these files in detail later on.

– Click on the Next Step button

– Click on the Create button and this will generate a zip file for you.

– Download the zip file, unzip and open the Java project. I am using Visual Studio Code and would recommend to use that because in later parts, I will be talking about the Tanzu plugin for VSCode that helps you as a developer to accelerate the application changes.

$ unzip tanzu-java-web-app.zip
Archive:  tanzu-java-web-app.zip
   creating: tanzu-java-web-app/
 extracting: tanzu-java-web-app/.gitignore  
   creating: tanzu-java-web-app/.mvn/
   creating: tanzu-java-web-app/.mvn/wrapper/
 extracting: tanzu-java-web-app/.mvn/wrapper/MavenWrapperDownloader.java  
 extracting: tanzu-java-web-app/.mvn/wrapper/maven-wrapper.jar  
 extracting: tanzu-java-web-app/.mvn/wrapper/maven-wrapper.properties  
 extracting: tanzu-java-web-app/LICENSE  
 extracting: tanzu-java-web-app/README.md  
 extracting: tanzu-java-web-app/Tiltfile  
 extracting: tanzu-java-web-app/accelerator-log.md  
 extracting: tanzu-java-web-app/catalog-info.yaml  
   creating: tanzu-java-web-app/config/
 extracting: tanzu-java-web-app/config/workload.yaml  
 extracting: tanzu-java-web-app/mvnw  
 extracting: tanzu-java-web-app/mvnw.cmd  
 extracting: tanzu-java-web-app/pom.xml  
   creating: tanzu-java-web-app/src/
   creating: tanzu-java-web-app/src/main/
   creating: tanzu-java-web-app/src/main/java/
   creating: tanzu-java-web-app/src/main/java/com/
   creating: tanzu-java-web-app/src/main/java/com/example/
   creating: tanzu-java-web-app/src/main/java/com/example/springboot/
 extracting: tanzu-java-web-app/src/main/java/com/example/springboot/Application.java  
 extracting: tanzu-java-web-app/src/main/java/com/example/springboot/HelloController.java  
   creating: tanzu-java-web-app/src/main/resources/
 extracting: tanzu-java-web-app/src/main/resources/application.yml  
   creating: tanzu-java-web-app/src/test/
   creating: tanzu-java-web-app/src/test/java/
   creating: tanzu-java-web-app/src/test/java/com/
   creating: tanzu-java-web-app/src/test/java/com/example/
   creating: tanzu-java-web-app/src/test/java/com/example/springboot/
 extracting: tanzu-java-web-app/src/test/java/com/example/springboot/HelloControllerTest.java  
 $ ls     

– I am pushing the code in my github repository. You can do the same but use your github repository.

$ git remote add origin https://github.com/dineshtripathi30/tanzu-java-web-app.git
 (main) $ git branch -M main
 (main) $ git push -u origin main
Enumerating objects: 34, done.
Counting objects: 100% (34/34), done.
Delta compression using up to 12 threads
Compressing objects: 100% (24/24), done.
Writing objects: 100% (34/34), 60.36 KiB | 10.06 MiB/s, done.
Total 34 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/dineshtripathi30/tanzu-java-web-app.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

So, here the development part is completed. Now, lets deploy the application.

#2 Use Case: Deploying Application

Deploying application is very easy and you do not have to worry about writing a complex Dockerfile, yaml files etc. Just run the below tanzu command to deploy this application.

$ tanzu apps workload create tanzu-java-web-app \
> --git-repo https://github.com/dineshtripathi30/tanzu-java-web-app \
> --git-branch main \
> --type web \
> --label app.kubernetes.io/part-of=tanzu-java-web-app \
> --yes
Create workload:
      1 + |---
      2 + |apiVersion: carto.run/v1alpha1
      3 + |kind: Workload
      4 + |metadata:
      5 + |  labels:
      6 + |    app.kubernetes.io/part-of: tanzu-java-web-app
      7 + |    apps.tanzu.vmware.com/workload-type: web
      8 + |  name: tanzu-java-web-app
      9 + |  namespace: default
     10 + |spec:
     11 + |  source:
     12 + |    git:
     13 + |      ref:
     14 + |        branch: main
     15 + |      url: https://github.com/dineshtripathi30/tanzu-java-web-app

Created workload "tanzu-java-web-app"

– Keep watching the pod status as it will take sometime to build and deploy the application. TAP internally uses Tanzu Build Service (TBS) for turning application source code to a container image.

– Run the below command to see the status of application deployment.

$ tanzu apps workload tail tanzu-java-web-app --since 10m --timestamp

– Run the below command after few mins and you will see the status in detail.

$ tanzu apps workload get tanzu-java-web-app
# tanzu-java-web-app: Ready
lastTransitionTime: "2021-12-27T04:32:03Z"
message: ""
reason: Ready
status: "True"
type: Ready

Workload pods
NAME                                         STATE       AGE
tanzu-java-web-app-build-1-build-pod         Succeeded   56m
tanzu-java-web-app-config-writer-kmlfp-pod   Succeeded   55m

Workload Knative Services
NAME                 READY   URL
tanzu-java-web-app   Ready   http://tanzu-java-web-app.default.example.com

– Run the below command to get other objects

$ kubectl get workload,gitrepository,pipelinerun,images.kpack,podintent,app,services.serving
NAME                                    AGE
workload.carto.run/tanzu-java-web-app   8m32s

NAME                                                        URL                                                      READY   STATUS                                                            AGE
gitrepository.source.toolkit.fluxcd.io/tanzu-java-web-app   https://github.com/dineshtripathi30/tanzu-java-web-app   True    Fetched revision: main/c593c74131cada0f0a723b36b649b08528e90edc   8m29s

NAME                                LATESTIMAGE                                                                                                                           READY
image.kpack.io/tanzu-java-web-app   demo-registry.com/build-service/tanzu-java-web-app-default@sha256:11299229f883996dd8229ef6f1b644e0ec1758645953c23edade68ad7ca49dcb   True

NAME                                                             READY   REASON   AGE
podintent.conventions.apps.tanzu.vmware.com/tanzu-java-web-app   True             7m23s

NAME                                      DESCRIPTION           SINCE-DEPLOY   AGE
app.kappctrl.k14s.io/tanzu-java-web-app   Reconcile succeeded   14s            6m19s

NAME                                             URL                                             LATESTCREATED              LATESTREADY                READY   REASON
service.serving.knative.dev/tanzu-java-web-app   http://tanzu-java-web-app.default.example.com   tanzu-java-web-app-00001   tanzu-java-web-app-00001 # Please edit the object below. Lines beginning with a '#' will be ignored,

That’s all for this post, In the upcoming TAP part #, I will be talking about how easily you can make the changes on this application and live update using Tanzu plugin for VSCode.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s