Dry Run
The dry run feature is a very useful way to check the correctness of the application configuration and definitions. It will render the application and print the output resources that checked on the service side. If the definitions(component, trait) is invalid, the dry run will print the error message.
When you do the following things, you’d better use dry-run.
- Create or update an application.
- Create or update the definition, and dry run some example applications.
There is a simple application:
kind: ApplicationapiVersion: core.oam.dev/v1beta1metadata:name: webservice-appspec:components:- name: frontendtype: webserviceproperties:image: oamdev/testapp:v1cmd: ["node", "server.js"]ports:- port: 8080expose: truetraits:- type: scalerproperties:replicas: 1
Copy it and write a file app.yaml, execute the following command, and then the resources will be printed.
vela dry-run app.yaml
expected output
---# Application(webservice-app) -- Component(frontend)---apiVersion: apps/v1kind: Deploymentmetadata:annotations: {}labels:app.oam.dev/appRevision: ""app.oam.dev/component: frontendapp.oam.dev/name: webservice-appapp.oam.dev/namespace: defaultapp.oam.dev/resourceType: WORKLOADworkload.oam.dev/type: webservicename: frontendnamespace: defaultspec:replicas: 1selector:matchLabels:app.oam.dev/component: frontendtemplate:metadata:labels:app.oam.dev/component: frontendapp.oam.dev/name: webservice-appspec:containers:- command:- node- server.jsimage: oamdev/testapp:v1name: frontendports:- containerPort: 8080name: port-8080protocol: TCP---## From the auxiliary workloadapiVersion: v1kind: Servicemetadata:annotations: {}labels:app.oam.dev/appRevision: ""app.oam.dev/component: frontendapp.oam.dev/name: webservice-appapp.oam.dev/namespace: defaultapp.oam.dev/resourceType: TRAITtrait.oam.dev/resource: webserviceExposetrait.oam.dev/type: AuxiliaryWorkloadname: frontendnamespace: defaultspec:ports:- name: port-8080port: 8080targetPort: 8080selector:app.oam.dev/component: frontendtype: ClusterIP---
If we set the expose field of the port as false, the output resources do not include the Service. If we set the replicas field as “1”, the output will be an error message:
Error: validate application: ./app.yaml by dry-run: admission webhook "validating.core.oam.dev.v1beta1.applications" denied the request: field "schematic": Invalid value error encountered, cannot evaluate trait "scaler": invalid template of trait scaler after merge with parameter and context: parameter.replicas: conflicting values (*1 | int) and "1" (mismatched types int and string) (and 1 more errors).
This means the replicas field is int type but we provide a string value, this application configuration is not valid.
tip
Override/topology Policies and deploy workflow are supported in v1.7.0+ now. While there’re still some limitation that dry-run with policy and workflow will only take override, topology policies and deploy workflow step into considerations. Other workflow steps will be ignored.
Let’s take the following application as example, the application explicitly specify override, topology policies and deploy workflow step.
apiVersion: core.oam.dev/v1beta1kind: Applicationmetadata:name: first-vela-appspec:components:- name: express-servertype: webserviceproperties:image: oamdev/hello-worldports:- port: 8000expose: truetraits:- type: scalerproperties:replicas: 1policies:- name: target-defaulttype: topologyproperties:clusters: ["local"]namespace: "default"- name: target-prodtype: topologyproperties:clusters: ["local"]namespace: "prod"- name: deploy-hatype: overrideproperties:components:- type: webservicetraits:- type: scalerproperties:replicas: 5workflow:steps:- name: deploy2defaulttype: deployproperties:policies: ["target-default"]- name: manual-approvaltype: suspend- name: deploy2prodtype: deployproperties:policies: ["target-prod", "deploy-ha"]
Dry run will produce rendered results for both deploy2default and deploy2prod deploy steps as below:
expected output
---# Application(first-vela-app with topology target-default) -- Component(express-server)---apiVersion: apps/v1kind: Deploymentmetadata:annotations: {}labels:app.oam.dev/appRevision: ""app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appapp.oam.dev/namespace: defaultapp.oam.dev/resourceType: WORKLOADworkload.oam.dev/type: webservicename: express-servernamespace: defaultspec:replicas: 1selector:matchLabels:app.oam.dev/component: express-servertemplate:metadata:labels:app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appspec:containers:- image: oamdev/hello-worldname: express-serverports:- containerPort: 8000name: port-8000protocol: TCP---## From the auxiliary workloadapiVersion: v1kind: Servicemetadata:annotations: {}labels:app.oam.dev/appRevision: ""app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appapp.oam.dev/namespace: defaultapp.oam.dev/resourceType: TRAITtrait.oam.dev/resource: webserviceExposetrait.oam.dev/type: AuxiliaryWorkloadname: express-servernamespace: defaultspec:ports:- name: port-8000port: 8000targetPort: 8000selector:app.oam.dev/component: express-servertype: ClusterIP------# Application(first-vela-app with topology target-prod) -- Component(express-server)---apiVersion: apps/v1kind: Deploymentmetadata:annotations: {}labels:app.oam.dev/appRevision: ""app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appapp.oam.dev/namespace: defaultapp.oam.dev/resourceType: WORKLOADworkload.oam.dev/type: webservicename: express-servernamespace: defaultspec:replicas: 5selector:matchLabels:app.oam.dev/component: express-servertemplate:metadata:labels:app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appspec:containers:- image: oamdev/hello-worldname: express-serverports:- containerPort: 8000name: port-8000protocol: TCP---## From the auxiliary workloadapiVersion: v1kind: Servicemetadata:annotations: {}labels:app.oam.dev/appRevision: ""app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appapp.oam.dev/namespace: defaultapp.oam.dev/resourceType: TRAITtrait.oam.dev/resource: webserviceExposetrait.oam.dev/type: AuxiliaryWorkloadname: express-servernamespace: defaultspec:ports:- name: port-8000port: 8000targetPort: 8000selector:app.oam.dev/component: express-servertype: ClusterIP---
Each deploy workflow step with topology policy will render individual result.
It can be a bit redundant for you as you may just need to dry run for one environment at a time. The, you can use the external workflow feature like below.
Firstly, define policy and workflow as below in individual files:
The
target-prod.yamlandha.yamlcorresponding to theproductionenvironment.# target-prod.yamlapiVersion: core.oam.dev/v1alpha1kind: Policymetadata:name: target-prodtype: topologyproperties:clusters: ["local"]namespace: "prod"
# ha.yamlapiVersion: core.oam.dev/v1alpha1kind: Policymetadata:name: hatype: overrideproperties:components:- type: webservicetraits:- type: scalerproperties:replicas: 5
The
prod-workflow.yamlcan glue them together.# prod-workflow.yamlapiVersion: core.oam.dev/v1alpha1kind: Workflowmetadata:name: deploy-prodsteps:- type: deployname: deploy-prodproperties:policies: ["ha", "target-prod"]
Then the application can reference the workflow as below.
apiVersion: core.oam.dev/v1beta1kind: Applicationmetadata:name: first-vela-appspec:components:- name: express-servertype: webserviceproperties:image: oamdev/hello-worldports:- port: 8000expose: truetraits:- type: scalerproperties:replicas: 1workflow:ref: deploy-prod
The dry run command can be:
vela dry-run -f app.yaml -f target-prod.yaml -f ha.yaml -f prod-workflow.yaml
Then, the dry-run results will only contain resources in the production environment.
expected output
---# Application(first-vela-app with topology target-prod) -- Component(express-server)---apiVersion: apps/v1kind: Deploymentmetadata:annotations: {}labels:app.oam.dev/appRevision: ""app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appapp.oam.dev/namespace: defaultapp.oam.dev/resourceType: WORKLOADworkload.oam.dev/type: webservicename: express-servernamespace: defaultspec:replicas: 5selector:matchLabels:app.oam.dev/component: express-servertemplate:metadata:labels:app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appspec:containers:- image: oamdev/hello-worldname: express-serverports:- containerPort: 8000name: port-8000protocol: TCP---## From the auxiliary workloadapiVersion: v1kind: Servicemetadata:annotations: {}labels:app.oam.dev/appRevision: ""app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appapp.oam.dev/namespace: defaultapp.oam.dev/resourceType: TRAITtrait.oam.dev/resource: webserviceExposetrait.oam.dev/type: AuxiliaryWorkloadname: express-servernamespace: defaultspec:ports:- name: port-8000port: 8000targetPort: 8000selector:app.oam.dev/component: express-servertype: ClusterIP---
Moreover, you can use --merge flag to merge external policies and workflow when application file is not reference to them.
For example, you can define the application as below, the only difference is there’s no workflow field.
# app.yamlapiVersion: core.oam.dev/v1beta1kind: Applicationmetadata:name: first-vela-appspec:components:- name: express-servertype: webserviceproperties:image: oamdev/hello-worldports:- port: 8000expose: truetraits:- type: scalerproperties:replicas: 1
the workflow and policy can be defined the same way
# workflow.yamlapiVersion: core.oam.dev/v1alpha1kind: Workflowmetadata:name: deploy-demosteps:- type: deployname: deploy-prodproperties:policies: ["target-prod"]
# target-prod.yamlapiVersion: core.oam.dev/v1alpha1kind: Policymetadata:name: target-prodtype: topologyproperties:clusters: ["local"]namespace: "prod"
If you don’t use --merge flag in this way, it will report warnings as below.
vela dry-run -f app.yaml -f target-prod.yaml -f workflow.yaml
result with warning messages
WARNING: workflow deploy-demo not referenced by applicationWARNING: policy target-prod not referenced by application---# Application(default) -- Component(express-server)---apiVersion: apps/v1kind: Deploymentmetadata:annotations: {}labels:app.oam.dev/appRevision: ""app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appapp.oam.dev/namespace: defaultapp.oam.dev/resourceType: WORKLOADworkload.oam.dev/type: webservicename: express-servernamespace: defaultspec:replicas: 1selector:matchLabels:app.oam.dev/component: express-servertemplate:metadata:labels:app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appspec:containers:- image: oamdev/hello-worldname: express-serverports:- containerPort: 8000name: port-8000protocol: TCP---## From the auxiliary workloadapiVersion: v1kind: Servicemetadata:annotations: {}labels:app.oam.dev/appRevision: ""app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appapp.oam.dev/namespace: defaultapp.oam.dev/resourceType: TRAITtrait.oam.dev/resource: webserviceExposetrait.oam.dev/type: AuxiliaryWorkloadname: express-servernamespace: defaultspec:ports:- name: port-8000port: 8000targetPort: 8000selector:app.oam.dev/component: express-servertype: ClusterIP---
In this case, the policy and workflow do not take effect. Because those are not referenced by the application and being viewed as standalone files and ignored.
So to make those external files work, please provide “—merge” flag as below:
vela dry-run -f app.yaml -f target-prod.yaml -f workflow.yaml --merge
Then the application will be glued with external policies and workflows even no reference exists.
expected ouput
---# Application(first-vela-app with topology target-prod) -- Component(express-server)---apiVersion: apps/v1kind: Deploymentmetadata:annotations: {}labels:app.oam.dev/appRevision: ""app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appapp.oam.dev/namespace: defaultapp.oam.dev/resourceType: WORKLOADworkload.oam.dev/type: webservicename: express-servernamespace: defaultspec:replicas: 1selector:matchLabels:app.oam.dev/component: express-servertemplate:metadata:labels:app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appspec:containers:- image: oamdev/hello-worldname: express-serverports:- containerPort: 8000name: port-8000protocol: TCP---## From the auxiliary workloadapiVersion: v1kind: Servicemetadata:annotations: {}labels:app.oam.dev/appRevision: ""app.oam.dev/component: express-serverapp.oam.dev/name: first-vela-appapp.oam.dev/namespace: defaultapp.oam.dev/resourceType: TRAITtrait.oam.dev/resource: webserviceExposetrait.oam.dev/type: AuxiliaryWorkloadname: express-servernamespace: defaultspec:ports:- name: port-8000port: 8000targetPort: 8000selector:app.oam.dev/component: express-servertype: ClusterIP---
You can refer to the Dry run command for more command line use cases.

Clicking the Deploy button to open the workflow selector dialog. You could select a workflow(every workflow corresponding to an environment) and click the DryRun button to execute a dry run. If passed, the result is like this

The result report is different from the CLI, there is a complete application configuration that is generated from the application metadata, you could check it. Different environments may have different application configurations.
Last updated on Feb 9, 2023 by dependabot[bot]