Tanzu Platform SaaS

Configure applications for debugging (Preview)

Last Updated February 19, 2025

This topic explains how to configure Tanzu Platform to build your Java applications with debug enabled so that you can attach a debugger to inspect the applications while they are running.

Before you begin

Before you can deploy a Java application with debug enabled into a Space, you must:

  • Install Tanzu CLI v1.5.3 or later. See Installing the Tanzu CLI.

  • Log in to Tanzu Platform using the Tanzu CLI by running:

    tanzu login
    

Overview of steps

The following provides an overview of the steps to configure the platform to build and run applications with debug enabled:

  1. Create a custom build plan
  2. Deploy an application
  3. Connect the debugger

Create a custom build plan

Before developers can debug Java applications, a platform engineer must create a Project-level custom container app build plan so that applications deployed in the Project are built and run with debug enabled.

To create a custom build plan:

  1. Set the Project that you want to support debug as the context:

    tanzu project use PROJECT-NAME
    
  2. Retrieve the default ContainerAppBuildPlan from the Project:

    KUBECONFIG=~/.config/tanzu/kube/config kubectl get containerappbuildplans.build.tanzu.vmware.com simple.tanzu.vmware.com -oyaml
    
  3. Copy the output and paste it into a file named tanzu-debug.yaml.

  4. Make the following changes to tanzu-debug.yaml:

    1. For metadata.name, update the value to debug.tanzu.vmware.com.
    2. Delete the following fields under metadata:

      • creationTimestamp
      • generation
      • resourceVersion
      • uid
    3. In spec.postBuildSteps, add a namedTask after spring-boot.tanzu.vmware.com called tanzu-java-debug.

  5. Apply tanzu-debug.yaml by running:

    KUBECONFIG=~/.config/tanzu/kube/config kubectl apply -f tanzu-debug.yaml
    
  6. Create and allocate Spaces from this Project as required. Ensure that these Spaces are assigned to an Availability Target that has a single cluster.

    VMware recommends that you assign developers their own Spaces so that they can iterate on applications without affecting other developers iterating on the same application at the same time.

Deploy an application

To deploy an application and connect the debugger:

  1. Open the IntelliJ IDE.

  2. Install the Tanzu Platform Developer Tools plug-in from disk and restart the IDE (one-time only). You can download the plug-in ZIP file from the Broadcom Support Portal.

    The IntelliJ packaging format is ZIP. Do not unzip the file.

    Installing Tanzu Developer Tools plug-in in IntelliJ.

  3. Open your source code in the workspace.

  4. Open an IDE terminal window and run these commands (one-time only):

    tanzu project use PROJECT-NAME
    tanzu space use SPACE-NAME
    
  5. In the same IDE terminal window, at the root of the workspace, build and deploy the application:

    tanzu deploy
    

    Applications being debugged must run at scale 1 so that the debugger has a single replica to connect to.

  6. Verify that the application is running with debug enabled by inspecting the environment variables of the application:

    tanzu apps get APP-NAME
    

    If debug is enabled, BPL_DEBUG_ENABLED is set to true and BPL_DEBUG_PORT is set to 9005.

Connect the debugger

To connect the debugger:

  1. In the IntelliJ Project Explorer, find the ContainerApp YAML file for the application.

  2. Right-click the ContainerApp YAML file and click Tanzu > Debug.

    Connecting the debugger in the IntelliJ Project Explorer.

  3. (Optional) If the Space does not have ingress configured, you can create additional port forwards to the application’s endpoints to provide access through a browser. For example, http://localhost:8080 and other debugging tools.

    tanzu apps port-forward APP-NAME –port 8080:8080
    
  4. To disconnect the debugger and end the debug session, click Stop in the Debug panel or on the toolbar. You can reconnect the session by following steps 1 and 2.