Creating a Workload

This document describes how to create a workload from example source code with the Tanzu Application Platform.

Before You Begin

  • Kubectl has been installed guide
  • TAP components have been installed on a Kubernetes cluster guide
  • Your kubeconfig context has been set to the prepared cluster kubectl config use-context CONTEXT_NAME
  • You have the Tanzu CLI installed guide, with the apps plugin guide

Getting Started with an Example Workload

Start by naming the workload and specifying a source code location for the workload to be created from.

  1. Run:

    tanzu apps workload create pet-clinic --git-repo --git-branch main --type web  

    Respond Y to prompts to complete process


    • pet-clinic is the name that will be given to the workload
    • --git-repo is the location of the code to build the workload from
    • --git-branch (optional) specifies which branch in the repo to pull the code from
    • --type is used to distinguish the workload type

    The options available for specifying the workload are available in the command reference for workload create or by running tanzu apps workload create --help

Check Build Logs

Once the workload has been successfully created, you can tail the workload to view the build and runtime logs:

  1. Check logs by running:

    tanzu apps workload tail pet-clinic --since 10m --timestamp


    • pet-clinic is the name you gave the workload
    • --since (optional) is how long ago to start streaming logs from (default 1s)
    • --timestamp (optional) prints the timestamp with each log line

Get the Workload Status and Details

Once the workload build process has completed, a knative service will be created to run the workload. You can view workload details at anytime in the process but some details such as the workload URL will only be available once the workload is running:

  1. Check the workload details by running:

    tanzu apps workload get pet-clinic


    • pet-clinic is the name of the workload you would like details from.
  2. See the running workload When the workload has been created, tanzu apps workload get will include the URL for the running workload. Depending on the terminal you use you may be able to ctrl+click on the URL to view. If that doesn't work you can copy-paste the URL into your web browser to see the workload.

Create a Workload from Local Source

Additionally, it is possible to create a workload using code from a local folder.

  1. Inside the folder that contains the source code, execute the following:

    tanzu apps workload create pet-clinic --local-path . --source-image springio/petclinic

    Respond Y to the prompt about publishing local source if the image needs to be updated.


    • pet-clinic is the name that will be given to the workload
    • --local-path is pointing to the folder where the source code is located
    • --source-image is the registry path for the local source code

Bind a Service to a Workload

Multiple services can be configured for each workload. The cluster supply chain is in charge of provisioning those services.

  1. A way to bind a database service to a workload is:

    tanzu apps workload update pet-clinic --service-ref ""


    • pet-clinic is the name of the workload to be updated
    • --service-ref is the reference to the service using the format {name}={apiVersion}:{kind}:{name}. For more details, refer to update command

Next Steps

You can add environment variables, export definitions, and use flags with these commands, for example:

  1. Add some environment variables

    tanzu apps workload update pet-clinic --env foo=bar
  2. Export the workload definition (to check into git, or migrate to another environment)

    tanzu apps workload get pet-clinic --export
  3. Check out the flags available for the workload commands

    tanzu apps workload -h
    tanzu apps workload get -h
    tanzu apps workload create -h
check-circle-line exclamation-circle-line close-line
Scroll to top icon