This topic guides you through getting started with VMware Tanzu Developer Tools for Visual Studio.
Install Tanzu Developer Tools for Visual Studio.
Configure Local Source Proxy if you’re able to do so. For more information, see the Local Source Proxy documentation.
If you cannot use Local Source Proxy, use a source image registry. Before deploying a workload, you must authenticate with an image registry to store your source code. You can use the Docker CLI to authenticate or you can set environment variables that the Tanzu CLI can use to authenticate.
docker login $REGISTRY_HOSTNAME -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD
export TANZU_APPS_REGISTRY_CA_CERT=PATH-TO-CA-CERT.nip.io.crt
export TANZU_APPS_REGISTRY_PASSWORD=USERNAME
export TANZU_APPS_REGISTRY_USERNAME=PASSWORD
CA_CERT
is only needed for a custom or private registry.
For more information, see Workload creation fails due to authentication failure in Docker Registry.
The extension makes use of the following files within your project:
workload.yaml
catalog-info.yaml
Tiltfile
.tanzuignore
You can create these files by using the instructions in this topic, or use the files in the View an example project section.
There are two ways to create these files:
Your project must contain a file named workload.yaml
. For example, MyApp\Config\workload.yaml
.
workload.yaml
provides instructions to Supply Chain Choreographer for how to build and manage a workload. For more information, see Supply Chain Choreographer for Tanzu.
The Tanzu Developer Tools for Visual Studio extension requires at least one workload.yaml
file per project. workload.yaml
must be a single-document YAML file, not a multi-document YAML file.
To create a workload.yaml
file by using Visual Studio:
Config
.Config
folder and then click Add > New Item….See the following workload.yaml
example:
apiVersion: carto.run/v1alpa1
kind: Workload
metadata:
name: APP-NAME
labels:
apps.tanzu.vmware.com/workload-type: WORKLOAD-TYPE
app.kubernetes.io/part-of: APP-NAME
spec:
source:
git:
url: GIT-SOURCE-URL
ref:
branch: GIT-BRANCH-NAME
Where:
APP-NAME
is the name of your application. For example, my-app
.WORKLOAD-TYPE
is the type of workload for your app. For example, web
. For more information, see Workload types.GIT-SOURCE-URL
is the Git source code URL for your app. For example, github.com/mycompany/myapp
.GIT-BRANCH-NAME
is the branch of the Git source code you want to use. For example, main
.Alternatively, you can use the Tanzu CLI to create a workload.yaml
file. For more information, see Create or update a workload.
Your project must contain a file named catalog-info.yaml
. For example, MyApp\Catalog\catalog-info.yaml
.
catalog-info.yaml
enables the workloads created with Tanzu Developer Tools for Visual Studio to appear in Tanzu Developer Portal. For more information, see Overview of Tanzu Developer Portal.
To create a catalog-info.yaml
file by using Visual Studio:
Catalog
.Catalog
folder and then click Add > New Item….See the following catalog-info.yaml
example:
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: APP-NAME
description: APP-DESCRIPTION
tags:
- tanzu
annotations:
'backstage.io/kubernetes-label-selector': 'app.kubernetes.io/part-of=APP-NAME'
spec:
type: service
lifecycle: experimental
owner: default-team
Where:
APP-NAME
is the name of your application.APP-DESCRIPTION
is a description of your application.Your project must contain a file named Tiltfile
. For example, MyApp\Tiltfile
.
The Tiltfile
provides the configuration for Tilt to enable your project to Live Update on the Tanzu Application Platform-enabled Kubernetes cluster. For more information, see the Tilt documentation.
To create a Tiltfile
file by using Visual Studio:
See the following Tiltfile
example:
SOURCE_IMAGE = os.getenv("SOURCE_IMAGE", default='SOURCE-IMAGE-VALUE')
# For multi-module projects, set the LOCAL_PATH to the project root.
# For example, if your Tiltfile's path is .../my-project/module1/Tiltfile, then set LOCAL_PATH = ".."
LOCAL_PATH = os.getenv("LOCAL_PATH", default='.')
NAMESPACE = os.getenv("NAMESPACE", default='default')
LIVE_UPDATE_PATH = os.getenv("LIVE_UPDATE_PATH", default='bin/Debug/net6.0')
k8s_custom_deploy(
'APP-NAME',
apply_cmd="tanzu apps workload apply -f Config/workload.yaml --live-update" +
" --local-path " + LOCAL_PATH +
" --build-env BP_DEBUG_ENABLED=true" +
" --namespace " + NAMESPACE +
" --output yaml" +
" --yes",
delete_cmd="tanzu apps workload delete " + APP-NAME + " --namespace " + NAMESPACE + " --yes" ,
deps=['bin'],
container_selector='workload',
live_update=[
sync(LIVE_UPDATE_PATH, '/workspace')
]
)
k8s_resource('APP-NAME', port_forwards=["8080:8080"],
extra_pod_selectors=[{'carto.run/workload-name': 'APP-NAME', 'app.kubernetes.io/component': 'run'}])
allow_k8s_contexts('CONTEXT-NAME')
Where APP-NAME
is the name of your application
If your Tanzu Application Platform-enabled Kubernetes cluster is running on your local machine, you can remove the entire allow_k8s_contexts
line. For more information about this line, see the Tilt documentation.
Your project can contain a file named .tanzuignore
. When working with local source code, .tanzuignore
excludes files from the source code that is uploaded within the image. It has syntax similar to the .gitignore
file.
This file must be placed in the project root to work. For example, MyApp\.tanzuignore
.
To create a Tiltfile
file by using Visual Studio:
For an example, see the .tanzuignore
file in GitHub that is used for the sample Tanzu Java web app. You can use the file as it is or edit it for your needs.
Before you begin, you need a container image registry to use the sample application. There are two ways to view a sample application that demonstrates the necessary configuration files:
To view the example by using Application Accelerator:
Steeltoe Weather Forecast
in Application Accelerator.git clone
to clone the application-accelerator-samples repository from GitHub.weatherforecast-steeltoe
directory.Tiltfile
and replace your-registry.io/project
with your registry.