kubevela.github.io/docs/installation/standalone.mdx

441 lines
15 KiB
Plaintext

---
title: Standalone Installation
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
## Overview
This documents will show you how to install KubeVela in standalone mode. There are two options:
1. [Local machine](#local): Install on a local machine based on Linux, macOS or Windows operating system.
2. [Remote Linux server](#remote): Install on a remote Linux server with accessible IP address.
:::tip
Install KubeVela on a remote server with non-linux operating system is not fully tested.
:::
### About VelaD
We'll use [VelaD](https://github.com/kubevela/velad) to install KubeVela in standalone mode. VelaD is a CLI tool that
packages KubeVela with all dependencies for minimal installation and VelaUX.
VelaD enables you to run KubeVela on any of docker compatible environments or Linux system.
- VelaD leverages [K3s](https://rancher.com/docs/k3s/latest/en/quick-start/) and [k3d](https://k3d.io/) to manage Kubernetes automatically. Users needn't care the details about Kubernetes.
- KubeVela along with all related images, and `vela` command line are packaged together that enables air-gapped installation of KubeVela and VelaUX.
:::caution
Installation with standalone mode is suited for development and testing purpose best that you don't even aware of the Kubernetes inside. If you want to use it in production, you need to understand and maintain the K3s for Kubernetes management well.
:::
## Install in a local machine {#local}
### 1. Prepare environment
VelaD support installing KubeVela on machines based on these OS: Linux, macOS, Windows.
**Requirements**
1. If you are using Linux or macOS, make sure your machine have `curl` installed.
2. If you are using macOS or Windows, make sure you've already installed [Docker](https://www.docker.com/products/docker-desktop).
3. Make sure the docker daemon is up and running.
### 2. Install VelaD and Setup KubeVela
#### Download VelaD
It will download and place the binary in your system `PATH`,
<Tabs className="unique-tabs" groupId="os">
<TabItem label="Linux/MacOS Script" value="script">
You may be required for root privilege during the installation process if not using root.
If you don't need the automation with root access, you can download from the [release page](https://github.com/kubevela/velad/releases) and uncompress manually.
```shell
curl -fsSl https://kubevela.io/script/install-velad.sh | bash
```
Check `velad` installed in `/usr/local/bin/`
</TabItem>
<TabItem label="Linux/MacOS with asdf-vm" value="asdf-vm">
If you are using the [asdf version manager](https://asdf-vm.com/), you can install `velad` with:
```shell script
# Add the velad plugin for asdf
asdf plugin add velad
# List all installable versions
asdf list-all velad
# Install the desired version (could be "latest")
asdf install velad <version>
# set it as the global version, unless a project declares it otherwise locally
asdf global velad <version>
```
</TabItem>
<TabItem label="Windows" value="win">
Run following command in powershell with administrator privilege.
```powershell
powershell -Command "iwr -useb https://static.kubevela.net/script/install-velad.ps1 | iex"
```
Check `velad` installed in `C:\vela\`
:::info
VelaD helps install Vela CLI, which requires administrator privilege.
:::
<details>
<summary>Start powershell as administrator</summary>
1. Click on the 'Start' button to open the Start menu.
2. Scroll to the Windows PowerShell shortcut folder then, right click on the Windows Powershell option and select 'Run as administrator'.
</details>
</TabItem>
</Tabs>
#### Setup KubeVela
```shell
velad install
```
<details>
<summary>expected output</summary>
```
Preparing K3s images...
Successfully prepare k3s image: /Users/sunjianbo/.vela/velad/k3s/k3s-airgap-images-amd64.tgz
Successfully prepare k3d images
...snip...
KubeVela control plane has been successfully set up on your cluster.
If you want to enable dashboard, please run "vela addon enable /Users/sunjianbo/.vela/addons/velaux"
Keep the token below if you want to restart the control plane
K1075e7f6c77555e6ebdaf4854e4a2f39ae4287cfad23f27cdac5b33608d44633fe::server:zSpzbdbGzVxOwfBvvjgT
🚀 Successfully install KubeVela control plane
🔭 See available commands with `vela help`
```
</details>
#### Verify Installation
Export kubeconfig and list all built-in ComponentDefinition:
<Tabs className="unique-tabs" groupId="os">
<TabItem label="Linux/macOS" value="unix">
```shell
export KUBECONFIG=$(velad kubeconfig --host)
vela comp
```
</TabItem>
<TabItem label="Windows" value="win">
```powershell
$env:PATH += ";$HOME\.vela\bin;"
$env:KUBECONFIG = $(velad kubeconfig --host)
vela comp
```
</TabItem>
</Tabs>
:::tip
- When executing `velad install`, vela CLI (`vela`) is already installed and add to `PATH` automatically. So you can use it directly.
- A file uesd to configure access to clusters is called *kubeconfig file*
:::
<details>
<summary>expected output</summary>
```
NAME DEFINITION DESCRIPTION
config-helm-repository autodetects.core.oam.dev Config information to authenticate helm chart repository
daemon daemonsets.apps Describes daemonset services in Kubernetes.
cron-task cronjobs.batch Describes cron jobs that run code or a script to completion.
worker deployments.apps Describes long-running, scalable, containerized services
that running at backend. They do NOT have network endpoint
to receive external network traffic.
task jobs.batch Describes jobs that run code or a script to completion.
webservice deployments.apps Describes long-running, scalable, containerized services
that have a stable network endpoint to receive external
network traffic from customers.
config-image-registry autodetects.core.oam.dev Config information to authenticate image registry
k8s-objects autodetects.core.oam.dev K8s-objects allow users to specify raw K8s objects in
properties
raw autodetects.core.oam.dev Raw allow users to specify raw K8s object in properties.
This definition is DEPRECATED, please use 'k8s-objects'
instead.
ref-objects autodetects.core.oam.dev Ref-objects allow users to specify ref objects to use.
Notice that this component type have special handle logic.
```
</details>
Export kubeconfig and list all built-in ComponentDefinition:
### 3. Install VelaUX
VelaUX is a dashboard for KubeVela. It is a web application that runs in your cluster. You can access it with your browser.
This is optional if you don't use UI console of KubeVela.
<Tabs className="unique-tabs" groupId="os">
<TabItem label="Linux/macOS" value="unix">
```shell script
vela addon enable ~/.vela/addons/velaux
```
</TabItem>
<TabItem label="Windows" value="win">
```powershell
vela addon enable $HOME\.vela\addons\velaux
```
</TabItem>
</Tabs>
<details>
<summary>expected output</summary>
```
Addon: velaux enabled Successfully.
```
</details>
By default, velaux don't have any exposed port, you can view it by:
```shell
vela port-forward addon-velaux -n vela-system 8080:80
```
Choose `> local | velaux | velaux` for visit.
:::note
For more VelaUX options, refer to [VelaUX addon](../reference/addons/velaux.md) document for other advanced installation arguments.
:::
VelaUX needs authentication. The default username is `admin` and the password is **`VelaUX12345`**.
It requires you to override with a new password for the first login, please make sure to remember the new password.
### 4. Cleanup
This command will clean up KubeVela controllers along with the Kubernetes cluster, refer to [the advanced guide](../platform-engineers/advanced-install.mdx#uninstall) for more detailed steps.
```
velad uninstall
```
## Install on a remote Linux server {#remote}
This documents show you how to install KubeVela on a remote Linux server (e.g. aws EC2 or aliyun ECS) in standalone mode.
### 1. Prepare a machine
Prepare a Linux server, make sure it meets the following requirements:
**Requirements**
1. Make sure your machine have `curl` installed.
2. This server has a public IP, or you can access the server's IP if it's a on-premise server.
3. If you are using a cloud server, make sure you have opened the port 6443 in secure group.
### 2. Install VelaD and Setup KubeVela
#### Download VelaD
Following script will download and place the binary in your system `PATH`,
so you may be required for root privilege during the installation process.
If you don't need the automation with root access, you can download from the [release page](https://github.com/kubevela/velad/releases) and uncompress manually.
```shell
curl -fsSl https://kubevela.io/script/install-velad.sh | bash
```
Check `velad` installed in `/usr/local/bin/`
#### Setup KubeVela
Run the following command and replace the `$SERVER_PUBLIC_IP` with your server's public IP.
```shell
velad install --bind-ip=$SERVER_PUBLIC_IP
```
<details>
<summary>expected output</summary>
```
Preparing K3s images...
Successfully prepare k3s image: /Users/sunjianbo/.vela/velad/k3s/k3s-airgap-images-amd64.tgz
Successfully prepare k3d images
...snip...
KubeVela control plane has been successfully set up on your cluster.
If you want to enable dashboard, please run "vela addon enable /Users/sunjianbo/.vela/addons/velaux"
Keep the token below if you want to restart the control plane
K1075e7f6c77555e6ebdaf4854e4a2f39ae4287cfad23f27cdac5b33608d44633fe::server:zSpzbdbGzVxOwfBvvjgT
🚀 Successfully install KubeVela control plane
🔭 See available commands with `vela help`
🔑 To access the cluster, set KUBECONFIG:
export KUBECONFIG=$(velad kubeconfig --name default --host)
```
</details>
#### Verify Installation
Export kubeconfig and list all built-in ComponentDefinition:
```shell
export KUBECONFIG=$(velad kubeconfig --host)
vela comp
```
:::tip
- When executing `velad install`, vela CLI (`vela`) is already installed and add to `PATH` automatically. So you can use it directly.
Later we will access KubeVela on local machine, we will install vela CLI on local machine again.
- A file uesd to configure access to clusters is called *kubeconfig file*. Vela CLI also use this file to access KubeVela.
:::
<details>
<summary>expected output</summary>
```
NAME DEFINITION DESCRIPTION
config-helm-repository autodetects.core.oam.dev Config information to authenticate helm chart repository
daemon daemonsets.apps Describes daemonset services in Kubernetes.
cron-task cronjobs.batch Describes cron jobs that run code or a script to completion.
worker deployments.apps Describes long-running, scalable, containerized services
that running at backend. They do NOT have network endpoint
to receive external network traffic.
task jobs.batch Describes jobs that run code or a script to completion.
webservice deployments.apps Describes long-running, scalable, containerized services
that have a stable network endpoint to receive external
network traffic from customers.
config-image-registry autodetects.core.oam.dev Config information to authenticate image registry
k8s-objects autodetects.core.oam.dev K8s-objects allow users to specify raw K8s objects in
properties
raw autodetects.core.oam.dev Raw allow users to specify raw K8s object in properties.
This definition is DEPRECATED, please use 'k8s-objects'
instead.
ref-objects autodetects.core.oam.dev Ref-objects allow users to specify ref objects to use.
Notice that this component type have special handle logic.
```
</details>
### 3. Install VelaUX
VelaUX is a dashboard for KubeVela. It is a web application that runs in your cluster. You can access it with your browser.
Run this command on remote server.
```shell
vela addon enable ~/.vela/addons/velaux serviceType=NodePort
```
<details>
<summary>expected output</summary>
```
Addon: velaux enabled Successfully.
...
I0907 12:03:11.462606 98769 utils.go:156] find cluster gateway service vela-system/kubevela-cluster-gateway-service:9443
Please access addon-velaux from the following endpoints:
+---------+-----------+-------------------------------+----------------------------+-------+
| CLUSTER | COMPONENT | REF(KIND/NAMESPACE/NAME) | ENDPOINT | INNER |
+---------+-----------+-------------------------------+----------------------------+-------+
| local | apiserver | Service/vela-system/apiserver | apiserver.vela-system:8000 | true |
| local | velaux | Service/vela-system/velaux | http://47.252.17.47:30000 | false |
+---------+-----------+-------------------------------+----------------------------+-------+
```
</details>
By adding `serviceType=NodePort`, we are telling VelaUX to expose service with K8s
[NodePort](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport) type.
Check the endpoint of VelaUX with following command:
```shell
vela status addon-velaux -n vela-system --endpoint
```
It will show URL like `http://PUBLIC-IP:PORT` access that URL with your browser.
:::caution open the port
If you are using a cloud server, please open this port in secure group.
:::
:::note
For more VelaUX options, refer to [VelaUX addon](../reference/addons/velaux.md) document for other advanced installation arguments.
:::
VelaUX needs authentication. The default username is `admin` and the password is **`VelaUX12345`**.
It requires you to override with a new password for the first login, please make sure to remember the new password.
### 4. Access cluster From Local (Optional)
You can access KubeVela with your local machine. Make sure you add `--bind-ip` when executing `velad install` command in the last step on the server.
#### Copy KubeConfig
Following command will print the kubeconfig for your cluster. `--external` means printed kubeconfig can be used from other
machine (like your local machine).
```shell
cat $(velad kubeconfig --external)
```
Then you need to copy this kubeconfig to your local machine. Let's say you saving a file in `~/.kube/velad-config` in your local machine.
#### Install Vela CLI in Local
To access the cluster, you also need to install `vela` CLI in your local machine.
```shell
curl -fsSl https://kubevela.io/script/install.sh | bash
```
#### Access KubeVela
Export KUBECONFIG environment variable and list all built-in ComponentDefinition:
```shell
export KUBECONFIG=~/.kube/velad-config
vela comp
```
### 5. Cleanup
Run following command on remote server.
This command will clean up KubeVela controllers along with the Kubernetes cluster, refer to [the advanced guide](../platform-engineers/advanced-install.mdx#uninstall) for more detailed steps.
```shell
velad uninstall
```