This topic guides you through starting to iterate on your first application on Tanzu Application Platform (commonly known as TAP). You deployed the app in the previous how-to Deploy your first application.
In the previous Getting started how-to topic, Deploy your first application, you deployed your first application on Tanzu Application Platform. Now that you have developed a skeleton workload, you are ready to begin to iterate on your new application and test code changes on the cluster.
Tanzu Developer Tools for Visual Studio is VMware Tanzu’s official IDE extension for Visual Studio. It helps you develop and receive fast feedback on your workloads running on the Tanzu Application Platform.
The Visual Studio extension enables live updates of your application while running on the cluster and allows you to debug your application directly on the cluster.
For information about installing the prerequisites and the Tanzu Developer Tools for Visual Studio extension, see Install Tanzu Developer Tools for Visual Studio.
ImportantUse Tilt v0.30.12 or later for the sample application.
To prepare to iterate on your application, you must:
Tanzu Live Update uses Tilt. This requires a suitable Tiltfile
to exist at the root of your project.
Your Tiltfile
must be similar to the following:
SOURCE_IMAGE = os.getenv("SOURCE_IMAGE", default='your-registry.io/project/csharp-weatherforecast-source')
LOCAL_PATH = os.getenv("LOCAL_PATH", default='.')
NAMESPACE = os.getenv("NAMESPACE", default='default')
NAME = os.getenv("NAME", default='sample-app')
k8s_custom_deploy(
NAME,
apply_cmd="tanzu apps workload apply -f config/workload.yaml --update-strategy replace --debug --live-update" +
" --local-path " + LOCAL_PATH +
" --namespace " + NAMESPACE +
" --yes --output yaml",
delete_cmd="tanzu apps workload delete " + NAME + " --namespace " + NAMESPACE + " --yes",
deps=['./bin'],
container_selector='workload',
live_update=[
sync('./bin/Debug/net6.0', '/workspace')
]
)
k8s_resource('tanzu-java-web-app', port_forwards=["8080:8080"],
extra_pod_selectors=[{'carto.run/workload-name': 'sample-app', 'app.kubernetes.io/component': 'run'}])
After verifying your project has the required Tiltfile
, you are ready to set up your development environment.
You are now ready to iterate on your application.
Apply the workload to see your application running on the cluster:
In Solution Explorer, right-click any file under the application name and click Tanzu > Apply Workload.
In the dialog box, enter the following:
In the Local Path text box, provide the path to the directory containing the Weather Forecast app. The current directory is the default.
The local path value tells the Tanzu Developer Tools for Visual Studio extension which directory on your local file system to bring into the source image. For example, dot (.
) uses the working directory, or you can specify a full file path.
In the Namespace text box, provide the namespace to be associated with the workload on the cluster.
(Optional) In the Source Image text box, provide the destination image repository to publish the image containing your workload source code.
The source image value tells the Tanzu Developer Tools for Visual Studio extension where to publish the container image with your uncompiled source code, and what to name that image. The image must be published to a container image registry where you have write (push) access. For example, gcr.io/myteam/weather-forecast-source
.
NoteSee the documentation for the registry you’re using to find out which steps are necessary to authenticate and gain push access.
For example, if you use Docker, see the Docker documentation, or if you use Harbor, see the Harbor documentation.
The apply workload
command runs and opens a an output window in which you can monitor the output of the command. The apply workload
command can take a few minutes to deploy your application onto the cluster.
Live Update allows you to save changes to your code and see those changes reflected within seconds in the workload running on the cluster.
To enable Live Update for your application:
In Solution Explorer, right-click any file under the application name and click Tanzu > Start Live Update.
Live update can take up to three minutes while the workload deploys and the Knative service becomes available.
NoteDepending on the type of cluster you use, you might see an error similar to the following:
ERROR: Stop! cluster-name might be production. If you're sure you want to deploy there, add: allow_k8s_contexts('cluster-name') to your Tiltfile. Otherwise, switch k8scontexts and restart Tilt.
Follow the instructions and add the line,
allow_k8s_contexts('cluster-name')
to yourTiltfile
.
In the IDE, make a change to the source code.
Build your project.
The container is updated when the logs stop streaming. Go to your browser and refresh the page.
View the changes to your workload running on the cluster.
Either continue making changes, or stop the Live Update process when finished. To stop Live Update, in Solution Explorer, right-click any file under the application name and click Tanzu > Stop Live Update.
Debug the cluster either on the application or in your local environment.
To start debugging the cluster:
Set a breakpoint in your code.
In Solution Explorer, right-click any file under the application name and click Tanzu > Debug Workload.
To stop debugging the cluster:
You can use the delete action to remove your application from the cluster as follows:
In Solution Explorer, right-click any file under the application name and click Tanzu > Delete Workload.
In the confirmation dialog box that appears, click OK to delete the application from the cluster.