395 lines
16 KiB
Plaintext
395 lines
16 KiB
Plaintext
---
|
||
title: 快速安装
|
||
---
|
||
|
||
import Tabs from "@theme/Tabs";
|
||
import TabItem from "@theme/TabItem";
|
||
|
||
> 如果是要升级现有的 KubeVela,请直接阅读[升级指南](./platform-engineers/advanced-install#升级).
|
||
|
||
> 1.2 版本已发布,欢迎试用。[去安装](/zh/docs/next/install)
|
||
|
||
## 1. 选择放置控制平面的集群
|
||
|
||
确保:
|
||
|
||
- Kubernetes 集群版本 >= v1.18.0
|
||
- 安装并配置 kubectl 命令行工具
|
||
|
||
KubeVela 得以成为控制平面,主要是依赖 Kubernetes 。它可以放置在任何托管 Kubernetes 作为底座的产品或你自己的集群中。
|
||
|
||
你可以使用 kind 或 minikube 在本地部署、测试 KubeVela,或者使用云厂商提供的 Kubernetes 服务做生产部署。
|
||
|
||
<Tabs
|
||
className="unique-tabs"
|
||
defaultValue="kind"
|
||
values={[
|
||
{label: 'Kind', value: 'kind'},
|
||
{label: 'RKE', value: 'rke'},
|
||
{label: 'Minikube', value: 'minikube'},
|
||
{label: 'Cloud Provider', value: 'cloudprovider'},
|
||
]}>
|
||
|
||
<TabItem value="minikube">
|
||
|
||
[安装 minikube](https://minikube.sigs.k8s.io/docs/start/) 后,创建一个集群:
|
||
|
||
```shell script
|
||
minikube start
|
||
```
|
||
|
||
安装 ingress 启用路由访问功能:
|
||
|
||
```shell script
|
||
minikube addons enable ingress
|
||
```
|
||
|
||
</TabItem>
|
||
|
||
<TabItem value="rke">
|
||
|
||
{" "}
|
||
|
||
<b>(1)安装 Docker (可选):</b>
|
||
|
||
RKE 的安装依赖于 Docker, 如未安装,请参考 [Docker 安装指南](https://docs.docker.com/engine/install/).
|
||
|
||
{" "}
|
||
|
||
<b>(2)安装 RKE 命令行:</b>
|
||
|
||
下载 RKE 二进制文件, [前往 RKE Release 页面](https://github.com/rancher/rke/releases).
|
||
|
||
如果你的网络受限无法下载(特别是中国用户),可直接使用下述方式安装:
|
||
|
||
```
|
||
wget https://static.kubevela.net/binary/rke/rke_linux-amd64 -O /usr/bin/rke
|
||
chmod +x /usr/bin/rke
|
||
```
|
||
|
||
{" "}
|
||
|
||
<b>(3)安装 Kubernetes 集群:</b>
|
||
|
||
```shell script
|
||
mkdir ~/rkeinit && cd ~/rkeinit
|
||
# 引导式配置,可参考 [RKE集群配置说明文档](https://rancher.com/docs/rke/latest/en/example-yamls/)。
|
||
rke config
|
||
# 安装集群
|
||
rke up
|
||
# 安装 Kubectl 命令行工具
|
||
mkdir ~/.kube
|
||
cp kube_config_cluster.yml ~/.kube/config
|
||
docker cp kubelet:/usr/local/bin/kubectl /usr/local/bin/kubectl
|
||
```
|
||
|
||
</TabItem>
|
||
|
||
<TabItem value="kind">
|
||
|
||
安装 [Kind 命令行工具](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)后,创建集群:
|
||
|
||
```shell script
|
||
cat <<EOF | kind create cluster --image=kindest/node:v1.18.15 --config=-
|
||
kind: Cluster
|
||
apiVersion: kind.x-k8s.io/v1alpha4
|
||
nodes:
|
||
- role: control-plane
|
||
kubeadmConfigPatches:
|
||
- |
|
||
kind: InitConfiguration
|
||
nodeRegistration:
|
||
kubeletExtraArgs:
|
||
node-labels: "ingress-ready=true"
|
||
extraPortMappings:
|
||
- containerPort: 80
|
||
hostPort: 80
|
||
protocol: TCP
|
||
- containerPort: 443
|
||
hostPort: 443
|
||
protocol: TCP
|
||
EOF
|
||
```
|
||
|
||
安装 ingress 启用路由访问功能:
|
||
|
||
```shell script
|
||
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml
|
||
```
|
||
|
||
</TabItem>
|
||
|
||
<TabItem value="cloudprovider">
|
||
|
||
- 阿里云 [ACK 服务](https://www.aliyun.com/product/kubernetes)
|
||
- AWS [EKS 服务](https://aws.amazon.com/cn/eks)
|
||
- Azure [AKS 服务](https://azure.microsoft.com/en-us/services/kubernetes-service)
|
||
- Google [GKE 服务](https://cloud.google.com/kubernetes-engine)
|
||
|
||
> 注意: 请确保云厂商的集群[已安装或启用 ingress-nginx](https://kubernetes.github.io/ingress-nginx/deploy/) 以保证路由访问功能可正常使用。
|
||
|
||
</TabItem>
|
||
</Tabs>
|
||
|
||
## 2. 安装 KubeVela
|
||
|
||
在安装之前,请确保 Helm 工具是可用的,如未安装,请参考 [安装说明](https://helm.sh/docs/intro/install/) 安装完成。
|
||
|
||
<details> <summary> 如果你的网络情况很难下载成功 Helm,请点击使用国内镜像来安装(仅适用于 linux-amd64) </summary>
|
||
|
||
```shell script
|
||
wget https://static.kubevela.net/binary/helm/helm-v3.7.0-linux-amd64 -O /usr/bin/helm
|
||
chmod +x /usr/bin/helm
|
||
```
|
||
|
||
</details>
|
||
|
||
1. 添加并更新 KubeVela Helm chart 仓库
|
||
|
||
```shell script
|
||
helm repo add kubevela https://charts.kubevela.net/core
|
||
helm repo update
|
||
```
|
||
|
||
2. 安装 KubeVela
|
||
|
||
```shell script
|
||
helm install --create-namespace -n vela-system kubevela kubevela/vela-core --set multicluster.enabled=true --wait
|
||
```
|
||
|
||
你可以参考 [`自定义安装`](./platform-engineers/advanced-install) 获取更多安装模式和功能。
|
||
|
||
3. 验证 chart 安装是否成功
|
||
|
||
```shell script
|
||
helm test kubevela -n vela-system
|
||
```
|
||
|
||
<details> <summary> 点击查看期望输出 </summary>
|
||
|
||
```shell
|
||
Pod kubevela-application-test pending
|
||
Pod kubevela-application-test pending
|
||
Pod kubevela-application-test running
|
||
Pod kubevela-application-test succeeded
|
||
NAME: kubevela
|
||
LAST DEPLOYED: Tue Apr 13 18:42:20 2021
|
||
NAMESPACE: vela-system
|
||
STATUS: deployed
|
||
REVISION: 1
|
||
TEST SUITE: kubevela-application-test
|
||
Last Started: Fri Apr 16 20:49:10 2021
|
||
Last Completed: Fri Apr 16 20:50:04 2021
|
||
Phase: Succeeded
|
||
TEST SUITE: first-vela-app
|
||
Last Started: Fri Apr 16 20:49:10 2021
|
||
Last Completed: Fri Apr 16 20:49:10 2021
|
||
Phase: Succeeded
|
||
NOTES:
|
||
Welcome to use the KubeVela! Enjoy your shipping application journey!
|
||
```
|
||
|
||
</details>
|
||
|
||
## 3. 【可选】安装 KubeVela CLI
|
||
|
||
KubeVela CLI 可以让你更便捷地来管理应用交付。不过,它不是必须使用的。
|
||
|
||
KubeVela CLI 也可以通过 [kubectl plugin](./platform-engineers/advanced-install#安装-kubectl-kubevela-cli-插件) 的方式来安装,或者通过二进制文件.
|
||
|
||
<Tabs
|
||
className="unique-tabs"
|
||
defaultValue="script"
|
||
values={[
|
||
{label: 'Script', value: 'script'},
|
||
{label: 'Homebrew', value: 'homebrew'},
|
||
{label: 'Download directly from releases', value: 'download'},
|
||
]}>
|
||
<TabItem value="script">
|
||
|
||
** macOS/Linux **
|
||
|
||
```shell script
|
||
curl -fsSl https://kubevela.io/script/install.sh | bash
|
||
```
|
||
|
||
**Windows**
|
||
|
||
```shell script
|
||
powershell -Command "iwr -useb https://kubevela.io/script/install.ps1 | iex"
|
||
```
|
||
|
||
</TabItem>
|
||
<TabItem value="homebrew">
|
||
|
||
**macOS/Linux**
|
||
|
||
先更新下你的 brew
|
||
|
||
```shell script
|
||
brew update
|
||
```
|
||
|
||
紧接着安装 KubeVela
|
||
|
||
```shell script
|
||
brew install kubevela
|
||
```
|
||
|
||
</TabItem>
|
||
<TabItem value="download">
|
||
|
||
- 通过[发布日志](https://github.com/oam-dev/kubevela/releases)下载最新的 `vela` 二进制文件。
|
||
- 解压二进制文件,并且在 `$PATH` 中配好环境变量,就搞定啦。
|
||
|
||
```shell script
|
||
sudo mv ./vela /usr/local/bin/vela
|
||
```
|
||
|
||
> [安装提示](https://github.com/oam-dev/kubevela/issues/625):
|
||
> 如果你使用的是 Mac 系统,它会弹出 “vela” 无法打开的警告,因为来自开发者的包无法验证。
|
||
>
|
||
> MacOS 对能够在系统中运行的软件,采取了更加严格的限制。你暂时可以通过打开 'System Preference' -> 'Security & Privacy' -> General 并点击 'Allow Anyway' 来解决这个问题。
|
||
|
||
</TabItem>
|
||
</Tabs>
|
||
|
||
## 4. 【可选】安装插件
|
||
|
||
KubeVela 支持一系列[开箱即用的插件](./platform-engineers/advanced-install#插件列表),建议你至少开启以下插件:
|
||
|
||
- Helm 以及 Kustomize 组件功能插件
|
||
|
||
```shell
|
||
vela addon enable fluxcd
|
||
```
|
||
|
||
- Terraform 插件
|
||
|
||
```shell
|
||
vela addon enable terraform
|
||
```
|
||
|
||
- 阿里云 Terraform Provider 插件
|
||
|
||
执行如下命令开启 Terraform 对阿里云的支持,可以[创建和消费云资源](./end-user/components/cloud-services/provider-and-consume-cloud-services):
|
||
|
||
其中,请参考[如何获取 Access Key](https://help.aliyun.com/knowledge_detail/38738.html)设置 Access Key,参考 [Region 列表](https://www.alibabacloud.com/help/doc-detail/72379.htm) 中的 `RegionId` 设置 `ALICLOUD_REGION`。
|
||
参数 `ALICLOUD_SECURITY_TOKEN` 是可选的,你可以通过 [这篇介绍](https://www.alibabacloud.com/help/zh/doc-detail/28756.htm) 设置。
|
||
|
||
```shell
|
||
vela addon enable terraform/provider-alibaba ALICLOUD_ACCESS_KEY=<xxx> ALICLOUD_SECRET_KEY=<yyy> ALICLOUD_REGION=<region>
|
||
```
|
||
|
||
- Azure Terraform Provider 插件
|
||
|
||
执行如下命令开启 Terraform 对 Azure 的支持,可以[创建和消费云资源](./end-user/components/cloud-services/provider-and-consume-cloud-services):
|
||
|
||
参考 [Authenticate Terraform to Azure](https://docs.microsoft.com/en-us/azure/developer/terraform/authenticate-to-azure?tabs=bash),设置如下参数。
|
||
|
||
```shell
|
||
vela addon enable terraform/provider-azure ARM_CLIENT_ID=<aaa> ARM_CLIENT_SECRET=<bbb> ARM_SUBSCRIPTION_ID=<ccc> ARM_TENANT_ID=<ddd>
|
||
```
|
||
|
||
- AWS Terraform Provider 插件
|
||
|
||
执行如下命令开启 Terraform 对 AWS 的支持,可以[创建和消费云资源](./end-user/components/cloud-services/provider-and-consume-cloud-services):
|
||
|
||
参考 [Authenticate Terraform to AWS](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#environment-variables),设置如下参数。
|
||
|
||
```shell
|
||
vela addon enable terraform/provider-aws AWS_ACCESS_KEY_ID=<aaa> AWS_SECRET_ACCESS_KEY=<bbb> AWS_DEFAULT_REGION=<region>
|
||
```
|
||
|
||
## 5. 查看已安装能力
|
||
|
||
> 如果没安装 vela 命令行工具,你也可以通过 `kubectl get comp -A` 和 `kubectl get trait -A` 代替.
|
||
|
||
- 通过 `vela` CLI 来看看有哪些组件类型:
|
||
|
||
```shell script
|
||
vela components
|
||
```
|
||
|
||
<details> <summary> 查看输出 </summary>
|
||
|
||
```console
|
||
NAME NAMESPACE WORKLOAD DESCRIPTION
|
||
alibaba-ack vela-system configurations.terraform.core.oam.dev Terraform configuration for Alibaba Cloud ACK cluster
|
||
alibaba-oss vela-system configurations.terraform.core.oam.dev Terraform configuration for Alibaba Cloud OSS object
|
||
alibaba-rds vela-system configurations.terraform.core.oam.dev Terraform configuration for Alibaba Cloud RDS object
|
||
helm vela-system autodetects.core.oam.dev Helm release is a group of K8s resources from either git
|
||
repository or Helm repo
|
||
kustomize vela-system autodetects.core.oam.dev Kustomize can fetching, building, updating and applying
|
||
Kustomize manifests from git repo.
|
||
raw vela-system autodetects.core.oam.dev raw allow users to specify raw K8s object in properties
|
||
task vela-system jobs.batch Describes jobs that run code or a script to completion.
|
||
webservice vela-system deployments.apps Describes long-running, scalable, containerized services
|
||
that have a stable network endpoint to receive external
|
||
network traffic from customers.
|
||
worker vela-system deployments.apps Describes long-running, scalable, containerized services
|
||
that running at backend. They do NOT have network endpoint
|
||
to receive external network traffic.
|
||
```
|
||
|
||
</details>
|
||
|
||
- 通过 `vela` CLI 来看看有哪些运维功能:
|
||
|
||
```shell script
|
||
vela traits
|
||
```
|
||
|
||
<details> <summary> 查看输出 </summary>
|
||
|
||
```console
|
||
NAME NAMESPACE APPLIES-TO CONFLICTS-WITH POD-DISRUPTIVE DESCRIPTION
|
||
annotations vela-system * true Add annotations on K8s pod for your workload which follows
|
||
the pod spec in path 'spec.template'.
|
||
configmap vela-system * true Create/Attach configmaps on K8s pod for your workload which
|
||
follows the pod spec in path 'spec.template'.
|
||
cpuscaler vela-system deployments.apps false Automatically scale the component based on CPU usage.
|
||
env vela-system * false add env on K8s pod for your workload which follows the pod
|
||
spec in path 'spec.template.'
|
||
expose vela-system false Expose port to enable web traffic for your component.
|
||
hostalias vela-system * false Add host aliases on K8s pod for your workload which follows
|
||
the pod spec in path 'spec.template'.
|
||
ingress vela-system false Enable public web traffic for the component.
|
||
ingress-1-20 vela-system false Enable public web traffic for the component, the ingress API
|
||
matches K8s v1.20+.
|
||
init-container vela-system deployments.apps true add an init container and use shared volume with pod
|
||
kustomize-json-patch vela-system false A list of JSON6902 patch to selected target
|
||
kustomize-patch vela-system false A list of StrategicMerge or JSON6902 patch to selected
|
||
target
|
||
kustomize-strategy-merge vela-system false A list of strategic merge to kustomize config
|
||
labels vela-system * true Add labels on K8s pod for your workload which follows the
|
||
pod spec in path 'spec.template'.
|
||
lifecycle vela-system * true Add lifecycle hooks for the first container of K8s pod for
|
||
your workload which follows the pod spec in path
|
||
'spec.template'.
|
||
node-affinity vela-system * true affinity specify node affinity and toleration on K8s pod for
|
||
your workload which follows the pod spec in path
|
||
'spec.template'.
|
||
pvc vela-system deployments.apps true Create a Persistent Volume Claim and mount the PVC as volume
|
||
to the first container in the pod
|
||
resource vela-system * true Add resource requests and limits on K8s pod for your
|
||
workload which follows the pod spec in path 'spec.template.'
|
||
rollout vela-system false rollout the component
|
||
scaler vela-system * false Manually scale K8s pod for your workload which follows the
|
||
pod spec in path 'spec.template'.
|
||
service-binding vela-system webservice,worker false Binding secrets of cloud resources to component env
|
||
sidecar vela-system * true Inject a sidecar container to K8s pod for your workload
|
||
which follows the pod spec in path 'spec.template'.
|
||
volumes vela-system deployments.apps true Add volumes on K8s pod for your workload which follows the
|
||
pod spec in path 'spec.template'.
|
||
```
|
||
|
||
</details>
|
||
|
||
以上的这些能力都是已经内置的,随取随用。而由于 KubeVela 从一开始就被设计成可编程的,你可以按玩乐高积木一样,添加任何你需要的功能。
|
||
|
||
## 下一步
|
||
|
||
- 安装完毕 KubeVela,开始动手编写[第一个应用部署计划](./quick-start)。
|
||
- 更多插件功能的安装,了解[自定义安装方式](./platform-engineers/advanced-install)安装。
|