This topic tells you how to use the Tanzu Workload CLI plug-in to create your first Workload
.
{{> 'partials/supply-chain/beta-banner' }}
The Platform Engineer has already created some Supply Chains for you to use. The Supply Chains can pull the source code from the source repository and build it. The built artifact is then pushed to a GitOps repository determined by the Platform Engineer.
Install the following CLI tools on your local machine:
-
As a developer, the first thing you want to know is what
SupplyChains
are available to you, and what kinds ofWorkloads
you can create using thoseSupplyChain
. Run:tanzu workload kind list
Example output:
$ tanzu workload kind list KIND VERSION DESCRIPTION appbuildv1s.supplychains.tanzu.vmware.com v1alpha1 Supply chain that pulls the source code from git repo, builds it using buildpacks and package the output as Carvel package. 🔎 To generate a workload for one of these kinds, use 'tanzu workload generate'
The command output shows that you have a kind
appbuildv1s.supplychains.tanzu.vmware.com
that you can use to generate the workload. The Tanzu CLI also shows a hint on the next command to use in the process. -
For this tutorial, build your workload using the tanzu-java-web-app sample application. Use the
tanzu workload generate
command to create aWorkload
of kindAppBuildV1
. A selector is displayed if multiple kinds are available. If a single kind is available, it is used to generate the scaffold of theWorkload
. Run:tanzu workload generate tanzu-java-web-app
Example output:
apiVersion: supplychains.tanzu.vmware.com/v1alpha1 kind: AppBuildV1 metadata: name: tanzu-java-web-app spec: #! Configuration for the generated Carvel Package carvel: ... gitOps: ... #! Configuration for the registry to use registry: ... source: ... #! Kpack build specification build: ...
-
Pipe the output into a
workload.yaml
file. If you have more than one kind available in the cluster, you must provide a--kind
flag. The--kind
flag supports tab auto-completion. Run:tanzu workload generate tanzu-java-web-app --kind appbuildv1s.supplychains.tanzu.vmware.com > workload.yaml
-
Edit the
workload.yaml
file, add the appropriate values in the file for each required entry. For example:apiVersion: supplychains.tanzu.vmware.com/v1alpha1 kind: AppBuildV1 metadata: name: tanzu-java-web-app spec: gitOps: baseBranch: "main" subPath: "packages" url: GITOPS-REPO-PATH registry: repository: REPOSITORY-PATH server: REGISTRY-SERVER source: git: branch: "main" url: "https://github.com/vmware-tanzu/application-accelerator-samples.git" subPath: "tanzu-java-web-app" carvel: packageName: "tanzu-java-web-app" packageDomain: "tanzu.vmware.com"
Caution The Beta version of the Tanzu Supply Chain does not support Platform Engineer level overrides and defaults. Therefore, the
Workload
generate command also shows the entries that a Platform Engineer is supposed to set, like the registry details. When the overrides feature is available, a Platform Engineer can set Platform level values like the registry details, and those entries will not be a part of thegenerate
command output as that is something a Platform Engineer does not want a Developer to override. This results in a much smallerWorkload
spec and one that only has values that a Developer can provide for theSupplyChain
. As a result, there is a clear separation between the Platform Engineering role and the Developer role. -
Use the
tanzu workload apply
command to apply yourAppBuildV1
workload to the cluster. If your Workload yaml file is not namedworkload.yaml
, use the-f
flag to point to it. Run:tanzu workload apply
Example output:
🔎 Creating workload: 1 + |--- 2 + |apiVersion: supplychains.tanzu.vmware.com/v1alpha1 3 + |kind: AppBuildV1 4 + |metadata: 5 + | name: tanzu-java-web-app 6 + | namespace: dev 7 + |spec: 8 + | carvel: 9 + | packageDomain: tanzu.vmware.com 10 + | packageName: tanzu-java-web-app 11 + | gitOps: 12 + | baseBranch: main 13 + | subPath: packages 14 + | url: GITOPS-REPO-PATH 15 + | registry: 16 + | repository: REPOSITORY-PATH 17 + | server: REGISTRY-SERVER 18 + | source: 19 + | git: 20 + | branch: main 21 + | url: https://github.com/vmware-tanzu/application-accelerator-samples.git 22 + | subPath: tanzu-java-web-app Create workload tanzu-java-web-app from workload.yaml? [yN]: y ✓ Successfully created workload tanzu-java-web-app
The
AppBuildV1
workload is applied to the cluster. For this tutorial, use thedev
namespace. -
To see all the workloads of each kind running in your namespace, run:
tanzu workload list
Example output:
Listing workloads from the dev namespace NAME KIND VERSION AGE tanzu-java-web-app appbuildv1s.supplychains.tanzu.vmware.com v1alpha1 30m 🔎 To see more details about a workload, use 'tanzu workload get workload-name --kind workload-kind'
-
To see all the workloads running in all namespaces, run:
tanzu workload list -A`
-
To see how the
tanzu-java-web-app
workload in the workload list is progressing, run:tanzu workload get tanzu-java-web-app
Èxample output:
📡 Overview name: tanzu-java-web-app kind: appbuildv1s.supplychains.tanzu.vmware.com/tanzu-java-web-app namespace: dev age: 15m 🏃 Runs: ID STATUS DURATION AGE tanzu-java-web-app-run-454m5 Running 2m 2m 🔎 To view a run information, use 'tanzu workload run get run-id'
From the output, you see that a
WorkloadRun
namedtanzu-java-web-app-run-454m5
was created when you applied theAppBuildV1
workload and it's in theRunning
state. There are multiple reasons why a newWorkloadRun
is created for yourWorkload
, but few are developer triggered. Updates to yourWorkload
, like changing the values in theworkload.yaml
and reapplying to the cluster creates a newWorkloadRun
. Platform Engineering activities like updating the Buildpack builder images can also cause yourWorkload
to rebuild, creating a newWorkloadRun
with newer base images. Other activities like pushing new commits to the source code repository referenced by theWorkload
can also cause a new run of theWorkload
to build the latest source from your Git repository. -
Use the
tanzu workload run get
command to see more information about what stages your workload is going through. Use the optional--show-details
flag for a more detailed output. Run:tanzu workload run get tanzu-java-web-app-run-454m5 --show-details
Example output:
📡 Overview name: tanzu-java-web-app kind: appbuildv1s.supplychains.tanzu.vmware.com/tanzu-java-web-app run id: appbuildv1runs.supplychains.tanzu.vmware.com/tanzu-java-web-app-run-454m5 status: Running namespace: dev age: 14m 📓 Spec 1 + |--- 2 + |apiVersion: supplychains.tanzu.vmware.com/v1alpha1 3 + |kind: AppBuildV1 4 + |metadata: 5 + | name: tanzu-java-web-app 6 + | namespace: dev 7 + |spec: 8 + | carvel: 9 + | packageDomain: tanzu.vmware.com 10 + | packageName: tanzu-java-web-app 11 + | gitOps: 12 + | baseBranch: main 13 + | subPath: packages 14 + | url: GITOPS-REPO-PATH 15 + | registry: 16 + | repository: REPOSITORY-PATH 17 + | server: REGISTRY-SERVER 18 + | source: 19 + | git: 20 + | branch: main 21 + | url: https://github.com/vmware-tanzu/application-accelerator-samples.git 22 + | subPath: tanzu-java-web-app 🏃 Stages ├─ source-git-provider │ ├─ 📋 check-source - Success │ │ ├─ Duration: 31s │ │ └─ Results │ │ ├─ message: using git-branch: main │ │ ├─ sha: e4e23867bcffcbf7a165e2fefe3c48dc28b076d6 │ │ └─ url: https://github.com/vmware-tanzu/application-accelerator-samples.git │ └─ 📋 pipeline - Success │ ├─ Duration: 1m28s │ └─ Results │ ├─ url: IMAGE-URL │ └─ digest: IMAGE-SHA ├─ buildpack-build │ ├─ 📋 check-builders - Success │ │ ├─ Duration: 26s │ │ └─ Results │ │ ├─ builder-image: BUILDER-IMAGE-USED │ │ ├─ message: Builders resolved │ │ └─ run-image: RUN-IMAGE-USED │ └─ 📋 pipeline - Success │ ├─ Duration: 2m59s │ └─ Results │ ├─ url: IMAGE-URL │ └─ digest: IMAGE-SHA ├─ conventions │ └─ 📋 pipeline - Success │ ├─ Duration: 33s │ └─ Results │ ├─ url: IMAGE-URL │ └─ digest: IMAGE-SHA ├─ app-config-server │ └─ 📋 pipeline - Running │ └─ Duration: 22.37089s ├─ carvel-package │ └─ 📋 pipeline - Not Started └─ git-writer-pr └─ 📋 pipeline - Not Started
The output shows you:
- Overview of your workload like
name
,kind
, andnamespace
. - Last 2 successful
WorkloadRuns
- Last 1 failed
WorkloadRun
- All running
WorkloadRuns
- Error section from the last failed
WorkloadRun
When your
WorkloadRun
has gone through the Supply Chain, the output of theWorkload
andWorkloadRun
is as follows:Workload Run Output : tanzu workload run get tanzu-java-web-app-run-454m5 --show-details
Workload Get Output : tanzu workload get tanzu-java-web-app
- Overview of your workload like
Based on the description of the AppBuildV1
kind from the tanzu workload kind list
command,
the Supply chain pulls the source code from Git repository, builds it using buildpacks,
and packages the output as a Carvel package. That output is then shipped to the GitOps
repository that is configured by the Platform Engineer. In your Supply Chain, when the WorkloadRun
succeeds, you can see the URL for the pull request to the GitOps repository in the
tanzu workload run get --show-details
output in the gitops-pr
stage results.
You have deployed your first workload using Tanzu Supply Chains.
Check out these How to Guides for developers to learn more about Tanzu Supply Chains.