TAP on EKS (beta-4) : Part 4 – Live update the Application

Reading Time: 5 mins

Overview

In my previous post, application workload was deployed and able to access the app successfully. Now let me take you through the steps to iterate the application and test code changes on the cluster. Tanzu Developer Tools for VSCode, VMware Tanzu’s official IDE extension for VSCode helps you develop & receive fast feedback on the Tanzu Application Platform. VSCode extension enables live updates of application while it runs on the cluster and lets you debug your application directly on the cluster.

Install VS Code and Tanzu CLI

  • Download VS code here, and install in your local machine.

Install Tanzu CLI

  • Login to Tanzu Network, click on folder tanzu-cli-0.12.0 and download tanzu framework bundle (select appropriate file based on OS type)

# Create a directory named tanzu:

mkdir $HOME/tanzu

# unpack the downloaded TAR file into the tanzu directory

tar -xvf tanzu-framework-darwin-amd64.tar -C $HOME/tanzu

# Install the CLI core:

cd $HOME/tanzu
install cli/core/v0.12.0/tanzu-core-darwin_amd64 /usr/local/bin/tanzu

# Confirm installation of the CLI core:

tanzu version

Tanzu Extension for Visual Studio Code

  • Download Tanzu Extension from Tanzu Network
  • Open VS Code, navigate to the Extensions menu (⇧⌘X), then from Views and More Actions menu (…) select Install from VSIX… Select the tanzu-vscode-extension.vsix file downloaded from Tanzunet.

Note: Upon installation, accept the dialog box to install the Extension Pack for Java and the YAML Language Support by Red Hat. These are required dependencies for debugging, live-reloading, and enabling snippets.

  • When you do not already have a Java Development Kit(JDK) installed, the Java extension pack prompts you to install one. When the JDK and Language Support for Java are configured correctly, you see that the integrated development environment creates a directory “target” where the code is compiled. Ensure to install latest JDK version.

Install Tilt

Tilt is an open-source tool that aims to provide a productive software development environment for anyone whose deployment target is Kubernetes.

Tilt not only helps with orchestrating the deployment of changes for testing, but the live_update allows to start testing the changes without needing to wait for image builds. Tilt enables to move from painstakingly long dev and test cycles to rapid iterative development across the project life cycle.

  • Refer to doc for Installing Tilt in your local machine, follow the appropriate steps based on the operating system you use.

Configure Tanzu Extension and Tilt

  • With ref to post, where we downloaded the zip bundle from Accelerator and pushed to git repo. For this demo, I moved to repo
  • Open VS Code, File > Open Folder > Select the folder

Run Application locally

  • Select .java file > Run > Start Debugging

  • Open Browser > access the url: localhost:8080
  • Output should match the text given in .java file.

 

Configure Extensions

  • Navigate to Extensions > Tanzu > gear icon – as shown below > Extension Settings

Configure Tiltfile to use EKS Cluster

  • By default, Tilt automatically allows Minikube, Docker for Desktop, Microk8s, Red Hat CodeReady Containers, Kind, K3D, and Krucible. In order to allow EKS cluster, add below line to the Tiltfile:
  • In VS Code > Explorer > Tiltfile
# Syntax: 

allow_k8s_contexts('context-name')

# How to get context name ?

kubectl config get-contexts

#Example:

allow_k8s_contexts('arn:aws:eks:ap-south-1:77804600:cluster/tap-demo-cluster')

Live Update

In earlier posts, we have deployed a web application and now let’s do a live update on the cluster.

  • In VS Code Explorer > .java (In this demo it is HelloController.java which in under /src/main/java/com/example/springboot) > modified the string as shown below:
  • Save

  • From the Command Palette (⇧⌘P), type in and select Tanzu: Live Update Start. Tanzu Logs opens up in the Output tab and you will see output from the Tanzu Application Platform and from Tilt indicating that the container is being built and deployed. Because this is your first time starting live update for this application, it might take 1-3 minutes for the workload to be deployed and the Knative service to become available.
  • Access tilt url
  • You can see the progress in VS Code Terminal or in Tilt as shown below:

  • If this is your first update, wait for 2-3 mins and access the webapp url to see the reflected changes.
  • Refer to post if you want the know the url.

  • Next subsequent changes should be completed in few secs:

  • From the Command Palette (⇧⌘P), type in and select Tanzu: Live Update Stop to stop the live update