Using Tanzu Developer Tools for VS Code

Ensure the project that you want to use the extension with has the required files specified in Getting started with Tanzu Developer Tools for Visual Studio Code.

The extension requires only one Tiltfile and one workload.yaml per project. The workload.yaml must be a single-document YAML file, not a multidocument YAML file.

Configure for multiple projects in the workspace

When working with multiple projects in a single workspace, you can configure the extension settings on a per-project basis by using the drop-down menu in Settings.

The VS Code interface showing Tanzu Extension selected in the settings. The Project drop-down menu is expanded to show both projects in the current workspace.

Apply a workload

The extension enables you to apply workloads on your Kubernetes cluster that has Tanzu Application Platform.

To apply a workload from the Command Palette:

  1. Pressing ⇧⌘P on macOS or Ctrl+Shift+P on Windows to open the Command Palette.

  2. Run Tanzu: Apply Workload.

    Command palette open showing text Tanzu: Apply Workload

  3. If there are multiple projects with workloads, select the workload to apply.

    Apply Workload menu open showing workloads available to apply

    A notification appears showing that the workload was applied.

    Apply Workload notification showing workload has been applied

    A new workload appears on the Tanzu Workloads panel.

    Workload on Tanzu Workloads

    The workload panel shows the workloads running in the namespace that is defined in the current Kubernetes context.

  4. (Optional) See the context and namespace currently configured by running:

    kubectl config get-contexts
    
  5. (Optional) Set a namespace for the current context by running:

    kubectl config set-context --current --namespace=YOUR-NAMESPACE
    

    After the workload is deployed, the status on the Tanzu Workloads panel changes to Ready.

    Workload ready on Tanzu Workloads

To apply a workload from the context menu:

  1. Apply a workload from the context menu by right-clicking on your workload file and selecting Tanzu: Apply Workload.

    Context menu open showing text Tanzu: Apply Workload

    A notification appears showing that the workload was applied.

    Apply Workload notification showing workload has been applied

    A new workload appears on the Tanzu Workloads panel.

    Workload on the Tanzu Workloads panel

    The workload panel shows the workloads running in the namespace that is defined in the current Kubernetes context.

  2. (Optional) See the context and namespace currently configured by running:

    kubectl config get-contexts
    
  3. (Optional) Set a namespace for the current context by running:

    kubectl config set-context --current --namespace=YOUR-NAMESPACE
    

    After the workload is deployed, the status on the Tanzu Workloads panel changes to Ready.

    Workload ready on Tanzu Workloads

Debugging on the cluster

The extension enables you to debug your application on your Kubernetes cluster that has Tanzu Application Platform.

Debugging requires a workload.yaml file in your project. For information about creating a workload.yaml file, see Set up Tanzu Developer Tools.

Debugging on the cluster and Live Update cannot be used simultaneously. If you use Live Update for the current project, ensure that you stop the Tanzu Live Update Run Configuration before attempting to debug on the cluster. For more information, see Stop Live Update.

Start debugging on the cluster

To start debugging on the cluster:

  1. Add a breakpoint in your code.
  2. Right-click the workload.yaml file in your project.
  3. Select Debug ‘Tanzu Debug Workload…’ in the pop-up menu.

    The VS Code interface showing the Explorer tab with the workload.yaml file pop-up menu open and the Tanzu: Java Debug Start option highlighted

Stop Debugging on the cluster

To stop debugging on the cluster, do one of the following:

  • Click the stop button in the Debug overlay.

    The VS Code interface close-up on the debug overlay showing the stop rectangle icon and mouseover description

  • Press ⌘+J to open the panel and then click the trash can icon for the debug task running in the panel.

    The VS Code interface close-up on the tasks panel showing the delete trash can icon

Live Update

With the use of Live Update facilitated by Tilt, the extension enables you to deploy your workload once, save changes to the code, and see those changes reflected in the workload running on the cluster within seconds.

Live Update requires a workload.yaml file and a Tiltfile in your project. For information about how to create a workload.yaml and a Tiltfile, see Set up Tanzu Developer Tools.

Live Update and Debugging on the cluster cannot be used simultaneously. If you are currently debugging on the cluster, stop debugging before attempting to use Live Update.

Start Live Update

There are two ways to start live update:

  • Right-click your project’s Tiltfile and select Tanzu: Live Update Start.

    The VS Code interface showing the Explorer tab with the Tiltfile file right-click menu open and the Tanzu: Live Update Start option highlighted

  • Start the Command Palette (⇧⌘P) and run the Tanzu: Live Update Start command.

    Command palette open showing text Tanzu: Live Update Start

Stop Live Update

When Live Update stops, your application continues to run on the cluster, but the changes you made and saved in your editor are not present in your running application unless you redeploy your application to the cluster.

There are two ways to stop live update:

  • Right-click your project’s Tiltfile and select Tanzu: Live Update Stop.

    The VS Code interface showing the Explorer tab with the Tiltfile file right-click menu open and the Tanzu: Live Update Stop option highlighted

  • Press ⇧⌘P to start the Command Palette and then run Tanzu: Live Update Stop.

    Command palette open showing text Tanzu: Live Update Stop

Deactivate Live Update

You can remove the Live Update capability from your application entirely. This option can be useful in a troubleshooting scenario. Disabling Live Update redeploys your workload to the cluster and removes the Live Update capability.

To disable Live Update:

  1. Press ⇧⌘P to open the Command Palette.
  2. Run Tanzu: Live Update Disable.

    Command palette open showing text Tanzu: Live Update Disable

  3. Type the name of the workload for which you want to deactivate Live Update.

Live Update status

The current status of Live Update is visible on the right side of the status bar at the bottom of the VS Code window.

The VS Code interface showing the Tanzu Live Update Status section of the Status bar

The Live Update status bar entry shows the following states:

  • Live Update Stopped
  • Live Update Starting…
  • Live Update Running

To hide the Live Update status bar entry, right-click it and select Hide ‘Tanzu Developer Tools (Extension)’.

The VS Code interface showing the Tanzu Live Update Status section of the Status bar with the right-click menu open and the Hide Tanzu Developer Tools (Extension) option highlighted

Delete a workload

The extension enables you to delete workloads on your Kubernetes cluster that has Tanzu Application Platform.

To delete a workload:

  1. Open the Command Palette by pressing ⇧⌘P on macOS or Ctrl+Shift+P on Windows.

  2. Run Tanzu: Delete Workload.

    Command palette open showing text Tanzu: Delete Workload

  3. Select the workload to delete.

    Delete Workload menu open showing workloads available to delete

    If the Tanzu: Confirm Delete setting is enabled, a message appears that prompts you to delete the workload and not warn again, delete the workload, or cancel.

    Delete Confirmation Notification showing delete options

    A notification appears showing that the workload was deleted.

    Delete Workload Notification showing workload has been deleted

Switch namespaces

To switch the namespace where you created the workload:

  1. Go to Code > Preferences > Settings.
  2. Expand the Extensions section of the settings and select Tanzu.
  3. In the Namespace option, add the namespace you want to deploy to. This is the default namespace by default.

The VS Code settings scrolled to the Tanzu section within the Extensions section

Tanzu Workloads panel

The current state of the workloads is visible on the Tanzu Workloads panel in the bottom left corner of the VS Code window. The panel shows the current status of each workload, namespace, and cluster. It also shows whether Live Update and Debug are running, stopped, or disabled.

The Tanzu Workloads panel uses the cluster and namespace specified in the current kubectl context.

  1. View the current context and namespace by running:

    kubectl config get-contexts
    
  2. Set a namespace for the current context by running:

    kubectl config set-context --current --namespace=YOUR-NAMESPACE
    

    VS Code Workload Panel

check-circle-line exclamation-circle-line close-line
Scroll to top icon