This is a sample of a Java Spring app that works with Tilt and the Tanzu Application Platform.
- kubectl CLI
- Tilt version >= v0.23.2
- Tanzu CLI and the apps plugin v0.2.0 which are provided as part of Tanzu Application Platform
- A cluster with Tanzu Application Platform, and the "Default Supply Chain", plus its dependencies. This supply chains is part of Tanzu Application Platform.
The workload is set up by default to autoconfigure the actuators. This results in that the Spring Actuators are available at TCP port 8081 and will be used by Application Live View.
Application Live View allows you see all health metrics in the TAP GUI. If you would like to have the Actuators available at TCP port 8080 you can set the
annotation apps.tanzu.vmware.com/auto-configure-actuators
to false
.
You can build using source from either a Git repository or from source on your local disk.
The instructions below use the latter option, where you build using the source from your local disk.
This is specified by adding a --local-path
option providing the path for the source, and a --source-image
option providing the OCI repository (e.g. registry.io/user/tanzu-java-web-app-source
) to use for publishing the local source code.
You can set this as an environment variable before running any of the commands below using:
export SOURCE_IMAGE=registry.io/user/tanzu-java-web-app-source
Start the app deployment by running:
tanzu apps workload create tanzu-java-web-app \
--file ./config/workload.yaml \
--local-path . \
--source-image "${SOURCE_IMAGE}"
You can use the IDE plugins for VSCode or IntelliJ IDEA to enable live update. You can also use the command line following these steps.
- Set the environment variable mentioned above specifying the repository to use for the source image. This is where the local source code will be written. As an example, use
export SOURCE_IMAGE=registry.io/user/tanzu-java-web-app-source
. - Start
Tilt
by runningtilt up
If you see an "Update error" message like the one below, then just follow the instructions and allow that context:
Stop! tap-beta2 might be production. If you're sure you want to deploy there, add: allow_k8s_contexts('tap-beta2') to your Tiltfile. Otherwise, switch k8s contexts and restart Tilt.
- You can hit the spacebar to open the Tilt UI in a browser.
You can build and deploy the config/workload-native.yaml
file using the Apply Workload option for Tanzu Developer Tools in your IDE.
You can also use the Tanzu CLI to build and deploy this sample as a GraalVM native image. With the Tanzu CLI, you can use the following command:
tanzu apps workload create tanzu-java-web-app \
--file ./config/workload-native.yaml \
--local-path .