
前提条件
Aliware
-
安装 Docker v20.10.5+ (runc >= v1.0.0-rc93) 或者你的操作系统是 Linux。 -
VelaD[4],一个轻量级的部署 KubeVela 和 Kubernetes 的工具。
准备集群
Aliware
安装 KubeVela 控制平面
velad install
将新创建的集群导入到环境变量
export KUBECONFIG=$(velad kubeconfig --name default --host)
vela cluster join <path-to-kubeconfig-of-cluster> --name foo
用 velad 创建一个名为 foo 的集群,并加入到控制平面
velad install --name foo --cluster-onlyvela cluster join $(velad kubeconfig --name foo --internal) --name foo
启用 velaux 插件,获得 UI 控制台
vela addon enable velaux
启用 fluxcd 插件获得 helm chart 交付能力
vela addon enable fluxcd
vela addon enable fluxcd --clusters foo
$ vela cluster lsCLUSTER ALIAS TYPE ENDPOINT ACCEPTED LABELSlocal Internal - truefoo X509Certificate https://172.20.0.6:6443 true
多集群部署
Aliware
cat <<EOF | vela up -f -apiVersion: core.oam.dev/v1beta1kind: Applicationmetadata:name: helm-hellospec:components:- name: hellotype: helmproperties:repoType: "helm"url: "https://jhidalgo3.github.io/helm-charts/"chart: "hello-kubernetes-chart"version: "3.0.0"policies:- name: foo-cluster-onlytype: topologyproperties:clusters: ["foo"]EOF
vela status helm-hello
About:Name: helm-helloNamespace: defaultCreated at: 2022-06-09 19:14:57 +0800 CSTStatus: runningWorkflow:mode: DAGfinished: trueSuspend: falseTerminated: falseSteps- id:vtahj5zrz4name:deploy-foo-cluster-onlytype:deployphase:succeededmessage:Services:- Name: helloCluster: foo Namespace: defaultType: helmHealthy Fetch repository successfully, Create helm release successfullyNo trait applied
$ vela status helm-hello --treeCLUSTER NAMESPACE RESOURCE STATUSfoo ─── default ─┬─ HelmRelease/hello updated└─ HelmRepository/hello updated
使用 UI 控制台查看部署状态
Aliware
-
检查来自不同集群的实例状态和事件:
-
检查来自不同集群的实例日志:
-
检查资源拓扑关系和状态:
使用 Override 配置进行部署
Aliware
cat <<EOF | vela up -f -apiVersion: core.oam.dev/v1beta1kind: Applicationmetadata:name: helm-hellospec:components:- name: hellotype: helmproperties:repoType: "helm"url: "https://jhidalgo3.github.io/helm-charts/"chart: "hello-kubernetes-chart"version: "3.0.0"policies:- name: topology-localtype: topologyproperties:clusters: ["local"]- name: topology-footype: topologyproperties:clusters: ["foo"]- name: override-localtype: overrideproperties:components:- name: helloproperties:values:configs:MESSAGE: Welcome to Control Plane Cluster!- name: override-footype: overrideproperties:components:- name: helloproperties:values:configs:MESSAGE: Welcome to Your New Foo Cluster!workflow:steps:- name: deploy2localtype: deployproperties:policies: ["topology-local", "override-local"]- name: manual-approvaltype: suspend- name: deploy2footype: deployproperties:policies: ["topology-foo", "override-foo"]EOF
$ vela status helm-helloAbout:Name: helm-helloNamespace: defaultCreated at: 2022-06-09 19:38:13 +0800 CSTStatus: workflowSuspendingWorkflow:mode: StepByStepfinished: falseSuspend: trueTerminated: falseSteps- id:ww4cydlveename:deploy2localtype:deployphase:succeededmessage:- id:xj6hu97e1ename:manual-approvaltype:suspendphase:succeededmessage:Services:- Name: helloCluster: local Namespace: defaultType: helmHealthy Fetch repository successfully, Create helm release successfullyNo trait applied
vela port-forward helm-hello
vela workflow resume helm-hello
$ vela status helm-hello --tree --detailCLUSTER NAMESPACE RESOURCE STATUS APPLY_TIME DETAILfoo ─── default ─┬─ HelmRelease/hello updated 2022-06-09 19:38:13 Ready: True Status: Release reconciliation succeeded Age: 64s└─ HelmRepository/hello updated 2022-06-09 19:38:13 URL: https://jhidalgo3.github.io/helm-charts/ Age: 64s Ready: TrueStatus: stored artifact for revision 'ab876069f02d779cb4b63587af1266464818ba3790c0ccd50337e3cdead44803'local ─── default ─┬─ HelmRelease/hello updated 2022-06-09 19:38:13 Ready: True Status: Release reconciliation succeeded Age: 7m34s└─ HelmRepository/hello updated 2022-06-09 19:38:13 URL: https://jhidalgo3.github.io/helm-charts/ Age: 7m34s Ready: TrueStatus: stored artifact for revision 'ab876069f02d779cb4b63587af1266464818ba3790c0ccd50337e3cdead44803'
vela port-forward helm-hello
? You have 2 deployed resources in your app. Please choose one: [Use arrows to move, type to filter]> Cluster: foo | Namespace: default | Kind: HelmRelease | Name: helloCluster: local | Namespace: default | Kind: HelmRelease | Name: hello
$ curl http://127.0.0.1:8080/...snip...<div id="message">Welcome to Your New Foo Cluster!</div>...snip...
为不同环境指定不同的 Value 文件
Aliware
$ tree ./hello-kubernetes-chart./hello-kubernetes-chart├── Chart.yaml├── templates│ ├── NOTES.txt│ ├── _helpers.tpl│ ├── config-map.yaml│ ├── deployment.yaml│ ├── hpa.yaml│ ├── ingress.yaml│ ├── service.yaml│ ├── serviceaccount.yaml│ └── tests│ └── test-connection.yaml├── values-production.yaml└── values.yaml
cat <<EOF | vela up -f -apiVersion: core.oam.dev/v1beta1kind: Applicationmetadata:name: hello-kubernetesspec:components:- name: hello-kubernetestype: helmproperties:repoType: "helm"url: "https://wangyikewxgm.github.io/my-charts/"chart: "hello-kubernetes-chart"version: "0.1.0"policies:- name: topology-testtype: topologyproperties:clusters: ["local"]namespace: "test"- name: topology-prodtype: topologyproperties:clusters: ["local"]namespace: "prod"- name: override-prodtype: overrideproperties:components:- name: hello-kubernetesproperties:valuesFiles:- "values-production.yaml"workflow:steps:- name: deploy2testtype: deployproperties:policies: ["topology-test"]- name: deploy2prodtype: deployproperties:policies: ["topology-prod", "override-prod"]EOF
vela port-forward hello-kubernetes
清理
Aliware
-
清理 foo 集群
velad uninstall -n foo
-
清理默认集群
velad uninstall
不仅如此
Aliware
-
项目代码库:github.com/oam-dev/kubevela 欢迎 Star/Watch/Fork! -
项目官方主页与文档:kubevela.io ,从 1.1 版本开始,已提供中文、英文文档,更多语言文档欢迎开发者进行翻译。 -
项目钉钉群:23310022;Slack:CNCF #kubevela Channel -
加入微信群:请先添加以下 maintainer 微信号,表明进入 KubeVela 用户群:

