KubeVela — 现代应用交付平台
什么是 KubeVela
KubeVela 是 CNCF 孵化项目,基于 OAM(Open Application Model)规范,提供以应用为中心的多集群交付平台。
核心概念
Application(应用)
├── Component(组件):应用的组成部分
│ ├── Workload(工作负载类型)
│ └── Traits(运维特征)
└── Policy(策略):部署策略
└── Workflow(工作流):部署流程安装
bash
# 安装 vela CLI
curl -fsSl https://kubevela.io/script/install.sh | bash
# 安装 KubeVela
vela install
# 查看内置组件类型
vela components
vela traitsApplication 示例
yaml
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: my-app
namespace: production
spec:
components:
- name: frontend
type: webservice
properties:
image: my-frontend:v1.0
port: 3000
cpu: "0.5"
memory: "512Mi"
traits:
- type: scaler
properties:
replicas: 3
- type: ingress
properties:
domain: www.example.com
http:
"/": 3000
- name: backend
type: webservice
properties:
image: my-backend:v1.0
port: 8080
traits:
- type: hpa
properties:
min: 2
max: 10
cpuUtil: 70
policies:
- name: multi-cluster
type: topology
properties:
clusters: [cluster1, cluster2]
namespace: production
workflow:
steps:
- name: deploy-staging
type: deploy
properties:
policies: [staging-policy]
- name: approval
type: suspend # 等待人工审批
- name: deploy-production
type: deploy
properties:
policies: [production-policy]常用命令
bash
# 部署应用
vela up -f app.yaml
# 查看应用状态
vela status my-app -n production
# 查看应用拓扑
vela status my-app --tree
# 查看应用日志
vela logs my-app --component frontend
# 进入容器
vela exec my-app --component frontend -- sh
# 端口转发
vela port-forward my-app 8080:8080