Debugging Application
KubeVela supports several CLI commands for debugging your applications, they can work on control plane and help you access resources across multi-clusters. Which also means you can play with your pods in managed clusters directly on the hub cluster, without switching KubeConfig context. If you have multiple clusters in on application, the CLI command will ask you to choose one interactively.
Deploy an example app
The examples on this page use the application from Quick Start. Save it as first-app.yaml:
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: first-vela-app
spec:
components:
- name: express-server
type: webservice
properties:
image: oamdev/hello-world
ports:
- port: 8000
expose: true
traits:
- type: scaler
properties:
replicas: 1
policies:
- name: target-default
type: topology
properties:
# The cluster with name local is installed the KubeVela.
clusters: ["local"]
namespace: "default"
- name: target-prod
type: topology
properties:
clusters: ["local"]
# This namespace must be created before deploying.
namespace: "prod"
- name: deploy-ha
type: override
properties:
components:
- type: webservice
traits:
- type: scaler
properties:
replicas: 2
workflow:
steps:
- name: deploy2default
type: deploy
properties:
policies: ["target-default"]
- name: manual-approval
type: suspend
- name: deploy2prod
type: deploy
properties:
policies: ["target-prod", "deploy-ha"]
vela up -f first-app.yaml
List Apps
List all your applications.
vela ls
expected output
APP COMPONENT TYPE TRAITS PHASE HEALTHY STATUS CREATED-TIME
first-vela-app express-server webservice scaler workflowSuspending healthy Ready:1/1 2022-10-09 12:10:30 +0800 CST
Show status of app
vela statuscan give you an overview of your deployed multi-cluster application.
vela status first-vela-app
expected output
About:
Name: first-vela-app
Namespace: default
Created at: 2022-10-09 12:10:30 +0800 CST
Status: workflowSuspending
Workflow:
mode: StepByStep
finished: false
Suspend: true
Terminated: false
Steps
- id: g1jtl5unra
name: deploy2default
type: deploy
phase: succeeded
message:
- id: 6cq88ufzq5
name: manual-approval
type: suspend
phase: running
message:
Services:
- Name: express-server
Cluster: local Namespace: default
Type: webservice
Healthy Ready:1/1
Traits:
✅ scaler
vela status --podcan list the pod status of your application.
vela status first-vela-app --pod
expected output
CLUSTER COMPONENT POD NAME NAMESPACE PHASE CREATE TIME REVISION HOST
local express-server express-server-b768d95b7-qnwb4 default Running 2022-10-09T04:10:31Z izrj9f9wodrsepwyb9mcetz
vela status --endpointcan list the access endpoints of your application.
vela status first-vela-app --endpoint
expected output
Please access first-vela-app from the following endpoints:
+---------+----------------+--------------------------------+-----------------------------+-------+
| CLUSTER | COMPONENT | REF(KIND/NAMESPACE/NAME) | ENDPOINT | INNER |
+---------+----------------+--------------------------------+-----------------------------+-------+
| local | express-server | Service/default/express-server | express-server.default:8000 | true |
+---------+----------------+--------------------------------+-----------------------------+-------+
vela status --tree --detailcan list resources of your application.
vela status first-vela-app --tree --detail
expected output
CLUSTER NAMESPACE RESOURCE STATUS APPLY_TIME DETAIL
local ─── default ─┬─ Service/express-server updated 2022-10-09 12:10:30 Type: ClusterIP Cluster-IP: 10.43.212.235 External-IP: <none> Port(s): 8000/TCP Age: 6m44s
└─ Deployment/express-server updated 2022-10-09 12:10:30 Ready: 1/1 Up-to-date: 1 Available: 1 Age: 6m44s
Show logs of app
vela logsshows pod logs in managed clusters.
vela logs first-vela-app
expected output
+ express-server-b768d95b7-qnwb4 › express-server
express-server 2022-10-09T12:10:33.785549770+08:00 httpd started
Execute commands inside pod container
vela exechelps you execute commands in pods in managed clusters.
vela exec first-vela-app -it -- ls
expected output
bin dev etc home proc root sys tmp usr var www
Access port locally
vela port-forwardcan discover and forward ports of pods or services in managed clusters to your local endpoint.
vela port-forward first-vela-app 8001:8000
You can curl this app by curl http://127.0.0.1:8001/.
More CLI Details
Please refer to the CLI docs.