This topic tells you about the Tanzu Apps CLI tanzu apps workload apply command.
Use the tanzu apps workload apply command to create and update workloads that are deployed in a cluster through a supply chain.
The tanzu apps workload apply and tanzu apps workload create commands have the same behavior and flags with the following exceptions:
tanzu apps workload create command fails if a workload with the same name preexists on the target cluster.update-strategy flag is only applicable to the tanzu apps workload apply command. The update-strategy flag is not applicable to the tanzu apps workload create command.In the output of the tanzu apps workload apply command, the specification for the workload is shown in YAML file format.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-tag tap-1.3 --type web
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | source:
11 + | git:
12 + | ref:
13 + | tag: tap-1.3
14 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
15 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
๐ Created workload "tanzu-java-web-app"
To see logs: "tanzu apps workload tail tanzu-java-web-app --timestamp --since 1h"
To get status: "tanzu apps workload get tanzu-java-web-app"
In the first section, the definition of workload is displayed. Itโs followed by a dialog box asking whether the workload should be created or updated. In the last section, if a workload is created or updated, some hints are displayed about the next steps.
--annotationSets the annotations to be applied to the workload. To specify more than one annotation set the flag multiple times. These annotations are passed as parameters to be processed in the supply chain.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-tag tap-1.3 --type web --annotation tag=tap-1.3 --annotation name="Tanzu Java Web"
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | params:
11 + | - name: annotations
12 + | value:
13 + | name: Tanzu Java Web
14 + | tag: tap-1.3
15 + | source:
16 + | git:
17 + | ref:
18 + | tag: tap-1.3
19 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
20 + | subPath: tanzu-java-web-app
To delete an annotation, use - after its name.
Example
tanzu apps workload apply tanzu-java-web-app --annotation tag-
๐ Update workload:
...
10, 10 | params:
11, 11 | - name: annotations
12, 12 | value:
13, 13 | name: Tanzu Java Web
14 - | tag: tap-1.3
15, 14 | source:
16, 15 | git:
17, 16 | ref:
18, 17 | tag: tap-1.3
...
โ Really update the workload "tanzu-java-web-app"? [yN]:
--app / -aThis is the application the workload is part of. This is part of the workload metadata section.
Example
tanzu apps workload apply tanzu-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-tag tap-1.3 --type web --app tanzu-java-web-app
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | app.kubernetes.io/part-of: tanzu-java-web-app
7 + | apps.tanzu.vmware.com/workload-type: web
8 + | name: tanzu-app
9 + | namespace: default
10 + |spec:
11 + | source:
12 + | git:
13 + | ref:
14 + | tag: tap-1.3
15 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
16 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
๐ Created workload "tanzu-app"
To see logs: "tanzu apps workload tail tanzu-app --timestamp --since 1h"
To get status: "tanzu apps workload get tanzu-app"
--build-envSets environment variables to use in the build phase by the build resources in the supply chain.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-tag tap-1.3 --type web --build-env JAVA_VERSION=1.8
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | build:
11 + | env:
12 + | - name: JAVA_VERSION
13 + | value: "1.8"
14 + | source:
15 + | git:
16 + | ref:
17 + | tag: tap-1.3
18 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
19 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
To delete a build environment variable, use - after its name.
Example
tanzu apps workload apply tanzu-java-web-app --build-env JAVA_VERSION-
๐ Update workload:
...
6, 6 | apps.tanzu.vmware.com/workload-type: web
7, 7 | name: tanzu-java-web-app
8, 8 | namespace: default
9, 9 |spec:
10 - | build:
11 - | env:
12 - | - name: JAVA_VERSION
13 - | value: "1.8"
14, 10 | source:
15, 11 | git:
16, 12 | ref:
17, 13 | tag: tap-1.3
...
โ Really update the workload "tanzu-java-web-app"? [yN]:
--debugSets the parameter variable debug to true in the workload.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --debug
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | params:
11 + | - name: debug
12 + | value: "true"
13 + | source:
14 + | git:
15 + | ref:
16 + | branch: main
17 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
18 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
--dry-runPrepares all the steps to submit the workload to the cluster and stops before sending it, showing an output of the final structure of the workload.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-tag tap-1.3 --type web --build-env JAVA_VERSION=1.8 --param-yaml server=$'port: 8080\nmanagement-port: 8181' --dry-run
---
apiVersion: carto.run/v1alpha1
kind: Workload
metadata:
creationTimestamp: null
labels:
apps.tanzu.vmware.com/workload-type: web
name: tanzu-java-web-app
namespace: default
spec:
build:
env:
- name: JAVA_VERSION
value: "1.8"
params:
- name: server
value:
management-port: 8181
port: 8080
source:
git:
ref:
tag: tap-1.3
url: https://github.com/vmware-tanzu/application-accelerator-samples
subPath: tanzu-java-web-app
status:
supplyChainRef: {}
--env / -eSets the environment variables to the workload so the supply chain resources can used it to deploy the workload application.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-tag tap-1.3 --type web --env NAME="Tanzu Java App"
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | env:
11 + | - name: NAME
12 + | value: Tanzu Java App
13 + | source:
14 + | git:
15 + | ref:
16 + | tag: tap-1.3
17 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
18 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
To unset an environment variable, use - after its name.
tanzu apps workload apply tanzu-java-web-app --env NAME-
๐ Update workload:
...
6, 6 | apps.tanzu.vmware.com/workload-type: web
7, 7 | name: tanzu-java-web-app
8, 8 | namespace: default
9, 9 |spec:
10 - | env:
11 - | - name: NAME
12 - | value: Tanzu Java App
13, 10 | source:
14, 11 | git:
15, 12 | ref:
16, 13 | tag: tap-1.3
...
โ Really update the workload "tanzu-java-web-app"? [yN]:
--file, -fSets the workload specification file to create the workload. This comes from any other workload specification passed by flags to the command set or overrides what is in the file. Another way to use this flag is by using - in the command to receive workload definition through stdin. See Working with YAML Files for an example.
Example
tanzu apps workload apply tanzu-java-web-app -f java-app-workload.yaml --param-yaml server=$'port: 9090\nmanagement-port: 9190'
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | build:
11 + | env:
12 + | - name: JAVA_VERSION
13 + | value: "1.8"
14 + | params:
15 + | - name: server
16 + | value:
17 + | management-port: 9190
18 + | port: 9090
19 + | source:
20 + | git:
21 + | ref:
22 + | tag: tap-1.3
23 + | url: url: https://github.com/vmware-tanzu/application-accelerator-samples
24 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
--git-repoThe Git repository from which the workload is created. You can specify --git-tag, or --git-commit.
--git-branchThe branch in a Git repository from where the workload is created. This is specified with a commit or a tag.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | source:
11 + | git:
12 + | ref:
13 + | branch: main
14 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
15 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
--git-tagThe tag in a Git repository from which the workload is created. This is used with --git-commit or --git-branch.
--git-commitCommit in Git repository from where the workload is resolved. Can be used with --git-branch or git-tag.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-tag tap-1.3 --git-commit 1c4cf82e499f7e46da182922d4097908d4817320 --type web
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | source:
11 + | git:
12 + | ref:
13 + | commit: 1c4cf82e499f7e46da182922d4097908d4817320
14 + | tag: tap-1.3
15 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
16 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
--image / -iSets the OSI image to be used as the workload application source instead of a Git repository
Example
tanzu apps workload apply tanzu-java-web-app --image private.repo.domain.com/tanzu-java-web-app --type web
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | build:
11 + | env:
12 + | - name: JAVA_VERSION
13 + | value: "1.8"
14 + | params:
15 + | - name: server
16 + | value:
17 + | management-port: 9190
18 + | port: 9090
19 + | source:
20 + | git:
21 + | ref:
22 + | tag: tap-1.3
23 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
24 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
--label / -lSets the label to be applied to the workload. To specify more than one label, set the flag multiple times.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --label stage=production
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | stage: production
8 + | name: tanzu-java-web-app
9 + | namespace: default
10 + |spec:
11 + | source:
12 + | git:
13 + | ref:
14 + | branch: main
15 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
16 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
To unset labels, use - after their name.
Example
tanzu apps workload apply tanzu-java-web-app --label stage-
๐ Update workload:
...
3, 3 |kind: Workload
4, 4 |metadata:
5, 5 | labels:
6, 6 | apps.tanzu.vmware.com/workload-type: web
7 - | stage: production
8, 7 | name: tanzu-java-web-app
9, 8 | namespace: default
10, 9 |spec:
11, 10 | source:
...
โ Really update the workload "tanzu-java-web-app"? [yN]:
--limit-cpuThe maximum CPU the workload pods are allowed to use.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --limit-cpu .2
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | resources:
11 + | limits:
12 + | cpu: 200m
13 + | source:
14 + | git:
15 + | ref:
16 + | branch: main
17 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
18 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
--limit-memoryThe maximum memory the workload pods are allowed to use.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --limit-memory 200Mi
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | resources:
11 + | limits:
12 + | memory: 200Mi
13 + | source:
14 + | git:
15 + | ref:
16 + | branch: main
17 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
18 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
--live-updateEnable this to deploy the workload once, save changes to the code, and see those changes reflected in the workload running on the cluster.
Example
An example with a Spring Boot application:
Clone the repository by running:
git clone https://github.com/vmware-tanzu/application-accelerator-samples
Change into the tanzu-java-web-app directory.
Tiltfile, first change the SOURCE_IMAGE variable to use your registry and project.At the very end of the file add:
allow_k8s_contexts('your-cluster-name')
Inside the directory, run:
tanzu apps workload apply tanzu-java-web-app --live-update --local-path . -s
gcr.io/my-project/tanzu-java-web-app-live-update -y
Expected output:
The files and directories listed in the .tanzuignore file are being excluded from the uploaded source code.
Publishing source in "." to "gcr.io/my-project/tanzu-java-web-app-live-update"...
๐ฅ Published source
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | name: tanzu-java-web-app
6 + | namespace: default
7 + |spec:
8 + | params:
9 + | - name: live-update
10 + | value: "true"
11 + | source:
12 + | image: gcr.io/my-project/tanzu-java-web-app-live-update:latest@sha256:3c9fd738492a23ac532a709301fcf0c9aa2a8761b2b9347bdbab52ce9404264b
๐ Created workload "tanzu-java-web-app"
To see logs: "tanzu apps workload tail tanzu-java-web-app --timestamp --since 1h"
To get status: "tanzu apps workload get tanzu-java-web-app"
Run Tilt to deploy the workload.
tilt up
Tilt started on http://localhost:10350/
v0.23.6, built 2022-01-14
(space) to open the browser
(s) to stream logs (--stream=true)
(t) to open legacy terminal mode (--legacy=true)
(ctrl-c) to exit
Tilt started on http://localhost:10350/
v0.23.6, built 2022-01-14
Initial Build โข (Tiltfile)
Loading Tiltfile at: /path/to/repo/tanzu-java-web-app/Tiltfile
Successfully loaded Tiltfile (1.500809ms)
tanzu-java-wโฆ โ
tanzu-java-wโฆ โ Initial Build โข tanzu-java-web-app
tanzu-java-wโฆ โ WARNING: Live Update failed with unexpected error:
tanzu-java-wโฆ โ Cannot extract live updates on this build graph structure
tanzu-java-wโฆ โ Falling back to a full image build + deploy
tanzu-java-wโฆ โ STEP 1/1 โ Deploying
tanzu-java-wโฆ โ Objects applied to cluster:
tanzu-java-wโฆ โ โ tanzu-java-web-app:workload
tanzu-java-wโฆ โ
tanzu-java-wโฆ โ Step 1 - 8.87s (Deploying)
tanzu-java-wโฆ โ DONE IN: 8.87s
tanzu-java-wโฆ โ
tanzu-java-wโฆ โ
tanzu-java-wโฆ โ Tracking new pod rollout (tanzu-java-web-app-build-1-build-pod):
tanzu-java-wโฆ โ โ Scheduled - (โฆ) Pending
tanzu-java-wโฆ โ โ Initialized - (โฆ) Pending
tanzu-java-wโฆ โ โ Ready - (โฆ) Pending
...
--local-pathSets the path to a source in the local machine from where the workload creates an image to use as an application source. The local path may be a directory, a JAR, a ZIP, or a WAR file. Java/Spring Boot compiled binaries are also supported. This flag must be used with --source-image flag.
If Java/Spring compiled binary is passed instead of source code, the command takes less time to apply the workload since the build pack skips the compiling steps and start uploading the image.
When working with local source code, you can exclude files from the source code to be uploaded within the image by creating a file .tanzuignore at the root of the source code. The .tanzuignore file contains a list of file paths to exclude from the image including the file itself. The directories must not end with the system path separator (/ or \). If the file contains directories that are not in the source code, they are ignored. Lines starting with a # hashtag are also ignored.
--maven-artifactThis artifact is an output of a Maven project build. This flag must be used with --maven-version and --maven-group.
Example
tanzu apps workload apply petc-mvn --maven-artifact petc --maven-version 2.6.1 --maven-group demo.com
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | name: petc-mvn
6 + | namespace: default
7 + |spec:
8 + | params:
9 + | - name: maven
10 + | value:
11 + | artifactId: petc
12 + | groupId: demo.com
13 + | version: 2.6.1
โ Do you want to create this workload? [yN]:
--maven-groupThis group identifies the project across all other Maven projects.
--maven-typeThis specifies the type of artifact that the Maven project produces. This flag is optional and is set by default as jar by the supply chain.
--maven-versionDefinition of the current version of the Maven project.
--source-image, -sRegistry path where the local source code is uploaded as an image.
Example
tanzu apps workload apply spring-pet-clinic --local-path /home/user/workspace/spring-pet-clinic --source-image gcr.io/spring-community/spring-pet-clinic --type web
โ Publish source in "/home/user/workspace/spring-pet-clinic" to "gcr.io/spring-community/spring-pet-clinic"? It may be visible to others who can pull images from that repository Yes
The files and/or directories listed in the .tanzuignore file are being excluded from the uploaded source code.
Publishing source in "/home/user/workspace/spring-pet-clinic" to "gcr.io/spring-community/spring-pet-clinic"...
๐ฅ Published source
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: spring-pet-clinic
8 + | namespace: default
9 + |spec:
10 + | source:
11 + | image:gcr.io/spring-community/spring-pet-clinic:latest@sha256:5feb0d9daf3f639755d8683ca7b647027cfddc7012e80c61dcdac27f0d7856a7
โ Do you want to create this workload? [yN]:
--namespace, -nSpecifies the namespace in which the workload is created or updated in.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --namespace my-namespace
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: my-namespace
9 + |spec:
10 + | source:
11 + | git:
12 + | ref:
13 + | branch: main
14 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
15 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
--param / -pAdditional parameters to be sent to the supply chain, the value is sent as a string. For complex YAML and JSON objects use --param-yaml.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --param port=9090 --param management-port=9190
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | params:
11 + | - name: port
12 + | value: "9090"
13 + | - name: management-port
14 + | value: "9190"
15 + | source:
16 + | git:
17 + | ref:
18 + | branch: main
19 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
20 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
To unset parameters, use - after their name.
Example
tanzu apps workload apply tanzu-java-web-app --param port-
๐ Update workload:
...
7, 7 | name: tanzu-java-web-app
8, 8 | namespace: default
9, 9 |spec:
10, 10 | params:
11 - | - name: port
12 - | value: "9090"
13, 11 | - name: management-port
14, 12 | value: "9190"
15, 13 | source:
16, 14 | git:
...
โ Really update the workload "tanzu-java-web-app"? [yN]:
--param-yamlAdditional parameters to be sent to the supply chain, the value is sent as a complex object.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --param-yaml server=$'port: 9090\nmanagement-port: 9190'
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | params:
11 + | - name: server
12 + | value:
13 + | management-port: 9190
14 + | port: 9090
15 + | source:
16 + | git:
17 + | ref:
18 + | branch: main
19 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
20 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
To unset parameters, use - after their name.
Example
tanzu apps workload apply tanzu-java-web-app --param-yaml server-
๐ Update workload:
...
6, 6 | apps.tanzu.vmware.com/workload-type: web
7, 7 | name: tanzu-java-web-app
8, 8 | namespace: default
9, 9 |spec:
10 - | params:
11 - | - name: server
12 - | value:
13 - | management-port: 9190
14 - | port: 9090
15, 10 | source:
16, 11 | git:
17, 12 | ref:
18, 13 | branch: main
...
โ Really update the workload "tanzu-java-web-app"? [yN]:
--registry-ca-certRefers to the path of the self-signed certificate needed for the custom/private registry. This is also populated with a default value through environment variables. If the environment variable TANZU_APPS_REGISTRY_CA_CERT is set, itโs not necessary to use it in the command.
See Custom registry credentials for the currently supported environment variables.
Example
tanzu apps workload apply my-workload --local-path . -s registry.url.nip.io/my-package/my-image --type web --registry-ca-cert path/to/cacert/mycert.nip.io.crt --registry-username my-username --registry-password my-password
โ Publish source in "." to "registry.url.nip.io/my-package/my-image"? It may be visible to others who can pull images from that repository Yes
Publishing source in "." to "registry.url.nip.io/my-package/my-image"...
๐ฅ Published source
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: my-workload
8 + | namespace: default
9 + |spec:
10 + | source:
11 + | image: registry.url.nip.io/my-package/my-image:latest@sha256:caeb7e3a0e3ae0659f74d01095b6fdfe0d3c4a12856a15ac67ad6cd3b9e43648
โ Do you want to create this workload? [yN]:
--registry-passwordIf credentials are needed, the user name and password values are set through the --registry-password flag. The value of this flag can also be specified through TANZU_APPS_REGISTRY_PASSWORD.
--registry-tokenUsed for token authentication in the private registry. This flag is set as TANZU_APPS_REGISTRY_TOKEN environment variable.
--registry-usernameOften used with --registry-password to set private registry credentials. Can be provided using TANZU_APPS_REGISTRY_USERNAME environment variable to avoid setting it every time in the command.
--request-cpuRefers to the minimum CPU the workload pods request to use.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --request-cpu .3
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | resources:
11 + | requests:
12 + | cpu: 300m
13 + | source:
14 + | git:
15 + | ref:
16 + | branch: main
17 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
18 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
--request-memoryRefers to the minimum memory the workload pods are requesting to use.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --request-memory 300Mi
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | resources:
11 + | requests:
12 + | memory: 300Mi
13 + | source:
14 + | git:
15 + | ref:
16 + | branch: main
17 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
18 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
--service-accountRefers to the service account to associate with the workload. A service account provides an identity for a workload object.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --service-account petc-serviceaccount
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | serviceAccountName: petc-serviceaccount
11 + | source:
12 + | git:
13 + | ref:
14 + | branch: main
15 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
16 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]:
To unset a service account, pass empty string.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --service-account ""
๐ Update workload:
...
6, 6 | apps.tanzu.vmware.com/workload-type: web
7, 7 | name: tanzu-java-web-app
8, 8 | namespace: default
9, 9 |spec:
10 - | serviceAccountName: petc-serviceaccount
11, 10 | source:
12, 11 | git:
13, 12 | ref:
14, 13 | branch: main
...
โ Really update the workload "tanzu-java-web-app"? [yN]:
--service-refBinds a service to a workload to provide the information from a service resource to an application.
Note For more information see Tanzu Application Platform documentation.
Example
tanzu apps workload apply rmq-sample-app --git-repo https://github.com/jhvhs/rabbitmq-sample --git-branch main --service-ref "rmq=rabbitmq.com/v1beta1:RabbitmqCluster:example-rabbitmq-cluster-1"
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | name: rmq-sample-app
6 + | namespace: default
7 + |spec:
8 + | serviceClaims:
9 + | - name: rmq
10 + | ref:
11 + | apiVersion: rabbitmq.com/v1beta1
12 + | kind: RabbitmqCluster
13 + | name: example-rabbitmq-cluster-1
14 + | source:
15 + | git:
16 + | ref:
17 + | branch: main
18 + | url: https://github.com/jhvhs/rabbitmq-sample
โ Do you want to create this workload? [yN]:
To delete service binding, use the service name followed by -.
Example
tanzu apps workload apply rmq-sample-app --service-ref rmq-
๐ Update workload:
...
4, 4 |metadata:
5, 5 | name: rmq-sample-app
6, 6 | namespace: default
7, 7 |spec:
8 - | serviceClaims:
9 - | - name: rmq
10 - | ref:
11 - | apiVersion: rabbitmq.com/v1beta1
12 - | kind: RabbitmqCluster
13 - | name: example-rabbitmq-cluster-1
14, 8 | source:
15, 9 | git:
16, 10 | ref:
17, 11 | branch: main
...
โ Really update the workload "rmq-sample-app"? [yN]:
--sub-pathDefines which path is used as the root path to create and update the workload.
Example
Git repository
tanzu apps workload apply subpathtester --git-repo https://github.com/path-to-repo/my-repo --git-branch main --type web --sub-path my-subpath
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: subpathtester
8 + | namespace: default
9 + |spec:
10 + | source:
11 + | git:
12 + | ref:
13 + | branch: main
14 + | url: https://github.com/path-to-repo/my-repo
15 + | subPath: my-subpath
โ Do you want to create this workload? [yN]:
Local path
In the directory of the project you want to create the workload from
tanzu apps workload apply my-workload --local-path . -s gcr.io/my-registry/my-workload-image --sub-path subpath_folder
โ Publish source in "." to "gcr.io/my-registry/my-workload-image"? It may be visible to others who can pull images from that repository Yes
Publishing source in "." to "gcr.io/my-registry/my-workload-image"...
๐ฅ Published source
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | name: myworkload
6 + | namespace: default
7 + |spec:
8 + | source:
9 + | image: gcr.io/my-registry/my-workload-image:latest@sha256:f28c5fedd0e902800e6df9605ce5e20a8e835df9e87b1a0aa256666ea179fc3f
10 + | subPath: subpath_folder
โ Do you want to create this workload? [yN]:
--tailPrints the logs of the workload creation in every step.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --tail
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | source:
11 + | git:
12 + | ref:
13 + | branch: main
14 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
15 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]: y
๐ Created workload "tanzu-java-web-app"
To see logs: "tanzu apps workload tail tanzu-java-web-app --timestamp --since 1h"
To get status: "tanzu apps workload get tanzu-java-web-app"
Waiting for workload "tanzu-java-web-app" to become ready...
+ tanzu-java-web-app-build-1-build-pod โบ prepare
tanzu-java-web-app-build-1-build-pod[prepare] Build reason(s): CONFIG
tanzu-java-web-app-build-1-build-pod[prepare] CONFIG:
tanzu-java-web-app-build-1-build-pod[prepare] + env:
tanzu-java-web-app-build-1-build-pod[prepare] + - name: BP_OCI_SOURCE
tanzu-java-web-app-build-1-build-pod[prepare] + value: main/d381fb658cb435a04e2271ca85bd3e8627a5e7e4
tanzu-java-web-app-build-1-build-pod[prepare] resources: {}
tanzu-java-web-app-build-1-build-pod[prepare] - source: {}
tanzu-java-web-app-build-1-build-pod[prepare] + source:
tanzu-java-web-app-build-1-build-pod[prepare] + blob:
tanzu-java-web-app-build-1-build-pod[prepare] + url: http://source-controller.flux-system.svc.cluster.local./gitrepository/default/tanzu-java-web-app/1c4cf82e499f7e46da182922d4097908d4817320.tar.gz
...
...
...
--tail-timestampPrints the logs of the workload creation in every step adding the time in which the log is occurring.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web --tail-timestamp
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | source:
11 + | git:
12 + | ref:
13 + | branch: main
14 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
15 + | subPath: tanzu-java-web-app
โ Do you want to create this workload? [yN]: y
๐ Created workload "tanzu-java-web-app"
To see logs: "tanzu apps workload tail tanzu-java-web-app --timestamp --since 1h"
To get status: "tanzu apps workload get tanzu-java-web-app"
Waiting for workload "tanzu-java-web-app" to become ready...
+ tanzu-java-web-app-build-1-build-pod โบ prepare
tanzu-java-web-app-build-1-build-pod[prepare] 2022-06-15T11:28:01.348418803-05:00 Build reason(s): CONFIG
tanzu-java-web-app-build-1-build-pod[prepare] 2022-06-15T11:28:01.364719405-05:00 CONFIG:
tanzu-java-web-app-build-1-build-pod[prepare] 2022-06-15T11:28:01.364761781-05:00 + env:
tanzu-java-web-app-build-1-build-pod[prepare] 2022-06-15T11:28:01.364771861-05:00 + - name: BP_OCI_SOURCE
tanzu-java-web-app-build-1-build-pod[prepare] 2022-06-15T11:28:01.364781718-05:00 + value: main/d381fb658cb435a04e2271ca85bd3e8627a5e7e4
tanzu-java-web-app-build-1-build-pod[prepare] 2022-06-15T11:28:01.364788374-05:00 resources: {}
tanzu-java-web-app-build-1-build-pod[prepare] 2022-06-15T11:28:01.364795451-05:00 - source: {}
tanzu-java-web-app-build-1-build-pod[prepare] 2022-06-15T11:28:01.365344965-05:00 + source:
tanzu-java-web-app-build-1-build-pod[prepare] 2022-06-15T11:28:01.365364101-05:00 + blob:
tanzu-java-web-app-build-1-build-pod[prepare] 2022-06-15T11:28:01.365372427-05:00 + url: http://source-controller.flux-system.svc.cluster.local./gitrepository/default/tanzu-java-web-app/1c4cf82e499f7e46da182922d4097908d4817320.tar.gz
...
...
...
--type / -tSets the type of workload by adding the label apps.tanzu.vmware.com/workload-type, which is used as a matcher by supply chains. Use the TANZU_APPS_TYPE environment variable to have a default value for this flag.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-branch main --type web
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: tanzu-java-web-app
8 + | namespace: default
9 + |spec:
10 + | source:
11 + | git:
12 + | ref:
13 + | branch: main
14 + | url: https://github.com/vmware-tanzu/application-accelerator-samples
15 + | subPath: tanzu-java-web-app
--update-strategyNoteThis flag is only applicable to the
tanzu apps workload applycommand. It is not applicable to thetanzu apps workload createcommand.
Example
Assuming there is a workload created from a file, which has in its spec the following:
...
spec:
resources:
requests:
memory: 1Gi
limits: # delete this line
memory: 1Gi # delete this line
cpu: 500m # delete this line
...
If the workload file is changed as specified in the comments, there are two ways to update the workload running in the cluster.
One, with merge update strategy.
tanzu apps workload apply -f ./spring-petclinic.yaml # defaulting to merge
โ WARNING: Configuration file update strategy is changing. By default, provided configuration files will replace rather than merge existing configuration. The change will take place in the January 2024 TAP release (use "--update-strategy" to control strategy explicitly).
Workload is unchanged, skipping update
The other, with replace update strategy, which will completely overwrite the workload in the cluster according to the new specifications in the file.
tanzu apps workload apply -f ./spring-petclinic.yaml --update-strategy replace
โ WARNING: Configuration file update strategy is changing. By default, provided configuration files will replace rather than merge existing configuration. The change will take place in the January 2024 TAP release (use "--update-strategy" to control strategy explicitly).
๐ Update workload:
...
8, 8 | name: spring-petclinic
9, 9 | namespace: default
10, 10 |spec:
11, 11 | resources:
12 - | limits:
13 - | cpu: 500m
14 - | memory: 1Gi
15, 12 | requests:
16, 13 | memory: 1Gi
17, 14 | source:
18, 15 | git:
...
โ Really update the workload "spring-petclinic"? [yN]:
--waitHolds the command until the workload is ready.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-tag tap-1.3 --type web --wait
๐ Update workload:
...
10, 10 | source:
11, 11 | git:
12, 12 | ref:
13, 13 | branch: main
14 + | tag: tap-1.3
14, 15 | url: https://github.com/vmware-tanzu/application-accelerator-samples
15, 16 | subPath: tanzu-java-web-app
โ Really update the workload "tanzu-java-web-app"? Yes
๐ Updated workload "tanzu-java-web-app"
To see logs: "tanzu apps workload tail tanzu-java-web-app --timestamp --since 1h"
To get status: "tanzu apps workload get tanzu-java-web-app"
Waiting for workload "tanzu-java-web-app" to become ready...
Workload "tanzu-java-web-app" is ready
--wait-timeoutSets a timeout to wait for the workload to become ready.
Example
tanzu apps workload apply tanzu-java-web-app --git-repo https://github.com/vmware-tanzu/application-accelerator-samples --sub-path tanzu-java-web-app --git-tag tap-1.3-take1 --type web --wait --wait-timeout 1m
๐ Update workload:
...
10, 10 | source:
11, 11 | git:
12, 12 | ref:
13, 13 | branch: main
14 - | tag: tap-1.3
14 + | tag: tap-1.3-take1
15, 15 | url: https://github.com/vmware-tanzu/application-accelerator-samples
16, 16 | subPath: tanzu-java-web-app
โ Really update the workload "tanzu-java-web-app"? Yes
๐ Updated workload "tanzu-java-web-app"
To see logs: "tanzu apps workload tail tanzu-java-web-app --timestamp --since 1h"
To get status: "tanzu apps workload get tanzu-java-web-app"
Waiting for workload "tanzu-java-web-app" to become ready...
Workload "tanzu-java-web-app" is ready
--yes, -yAssumes --yes on all the survey prompts.
Example
tanzu apps workload apply spring-pet-clinic --local-path/home/user/workspace/spring-pet-clinic --source-image gcr.io/spring-community/spring-pet-clinic --type web -y
The files and/or directories listed in the .tanzuignore file are being excluded from the uploaded source code.
Publishing source in "/Users/dalfonso/Documents/src/java/tanzu-java-web-app" to "gcr.io/spring-community/spring-pet-clinic"...
๐ฅ Published source
๐ Create workload:
1 + |---
2 + |apiVersion: carto.run/v1alpha1
3 + |kind: Workload
4 + |metadata:
5 + | labels:
6 + | apps.tanzu.vmware.com/workload-type: web
7 + | name: spring-pet-clinic
8 + | namespace: default
9 + |spec:
10 + | source:
11 + | image: gcr.io/spring-community/spring-pet-clinic:latest@sha256:5feb0d9daf3f639755d8683ca7b647027cfddc7012e80c61dcdac27f0d7856a7
๐ Created workload "spring-pet-clinic"
To see logs: "tanzu apps workload tail spring-pet-clinic --timestamp --since 1h"
To get status: "tanzu apps workload get spring-pet-clinic"