This topic tells you how to build and deploy an application from source on Tanzu Platform for Kubernetes.
Before you can deploy an app in a Space, you must:
Install Tanzu CLI v1.4.0 or later. See Installing the Tanzu CLI.
Install the Tanzu CLI app-developer
plug-in group, if it is not present, by running:
tanzu plugin install --group vmware-tanzu/app-developer
If the app-developer
plug-in group is already installed, verify that you’re using the latest version of the build plug-in by running:
tanzu plugin upgrade build
Log in via Tanzu CLI
tanzu login
Install either Podman or Docker for Docker-compatible runtime for building your application
ImportantIf you use Podman, you must export the
DOCKER_HOST
environment variable. For example:export DOCKER_HOST=unix://$(podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}')
The following provides an overview of the steps to build and deploy an application.
Before you build your application, your must initialize a ContainerApp for it. The ContainerApp defines default build and runtime configuration for your application and is used as an input to tanzu build
. For more information about ContainerApps, see What is a ContainerApp.
To initialize a ContainerApp:
Navigate to the root of your source code:
cd YOUR-REPO-LOCATION
Initialize the ContainerApp by running and accepting suggested defaults (by pressing “Enter”):
tanzu app init
If you want to expose your application with a domain name, and route traffic to it from the domain name, answer yes
to the command prompt that asks about your application supporting HTTP traffic.
If want to expose your application with a domain name and route traffic from the domain name to the deployed application, see Adding HTTP Routing to an Application.
Configure the container image registry where you want generated images to be pushed. Run:
tanzu build config --containerapp-registry REGISTRY
Where REGISTRY
is your container image registry location. For example, my-registry.io/my-corp-apps/{name}
or my-registry.io/{contact.businessunit}/app-{name}
. Note that use of literal {name}
is required. Use the following templating in the registry URL to prevent image collisions:
{name}
: build command will substitute the name of your ContainerApp.{contact.FIELD}
: build command will substitute the value of spec.contact.FIELD
from your ContainerApp.Log into your container image registry if you have not already done so. For example:
docker login my-registry.io
You have two options for deploying your application:
tanzu deploy
command to build and deploy your app in one step.To deploy your application in your Space:
Set the project you want to use:
tanzu project use
Set the Space to use for your deployment by running:
tanzu space use
Build and deploy your application with a single command by running:
tanzu deploy
When you run tanzu deploy
, the following occurs:
Alternatively, you can build and deploy your application in two separate steps.
You might want to do this if, for example, you want to run pre-deployment analysis on the build output or want to build and deploy and application from existing CI workflows.
To build and deploy your application:
Set the project you want to use:
tanzu project use
Set the Space to use for your deployment by running:
tanzu space use
Build your application by running:
tanzu build --output-dir DIR-PATH
Where DIR-PATH
is the location where you want the build output.
NoteEarlier versions of
tanzu build
produced an additional secret resource in its output namedAPP-NAME-values
. These builds are now deprecated. Rebuild apps with the latest build plug-in, and do not deploy this secret in Tanzu Platform for Kubernetes Spaces anymore.
Deploy your application by running:
tanzu deploy --from-build DIR-PATH
Where DIR-PATH
is the same as the location you used in the tanzu build
command.