APISIX Dashboard中文文档(二)

2022年7月6日14:31:51

APISIX Dashboard中文文档(一)
APISIX Dashboard中文文档(二)
APISIX Dashboard中文文档(三)

基本部署

在 Linux 上安装 Apache APISIX Dashboard 很容易。
现在,我们提供 Docker 镜像和 RPM 安装包。

Docker

我们推荐使用 Docker 来运行 Dashboard:

docker pull apache/apisix-dashboard
docker run -d --name dashboard \
           -p 9000:9000        \
           -v <CONFIG_FILE>:/usr/local/apisix-dashboard/conf/conf.yaml \
           apache/apisix-dashboard

:::提示
请将 <CONFIG_FILE> 替换为您的配置文件路径。
:::

RPM

NOTE: 目前仅支持 CentOS 7。

安装

# 1. install RPM package
sudo yum install -y https://github.com/apache/apisix-dashboard/releases/download/v2.13/apisix-dashboard-2.13-0.el7.x86_64.rpm

启动

# run dashboard in the shell
sudo manager-api -p /usr/local/apisix/dashboard/

# or run dashboard as a service
systemctl start apisix-dashboard

在不更改配置的情况下,访问 http://127.0.0.1:9000 以使用带有 GUI 的仪表板,其中默认用户名和密码为 admin

Source

Dashboard 项目同时包含 manager-apiweb,但 web 是_可选_。

manager-apiweb 将包含在此构建指南产品中。

Prerequisites

在使用源代码构建之前,请确保在您的环境中安装了以下依赖项。

For manager-api:

  1. Golang 1.13+

Tip: 对于中国大陆地区的用户,可以使用以下命令加快模块下载速度

$ go env -w GOPROXY=https://goproxy.cn,direct

For web:

  1. Node.js current LTS (14.x+)
  2. Yarn

下载

git clone -b release/2.13 https://github.com/apache/apisix-dashboard.git && cd apisix-dashboard

构建

cd apisix-dashboard
make build

构建完成后,结果将存储在“输出”根目录中。

Note: make build 将构建 manager-apiweb,使用 make help 命令查看更多命令。

启动

1.构建完成后开始之前,请确保在您的环境中安装并运行以下依赖项。

  1. 根据你的部署环境检查和修改output/conf/conf.yaml中的配置信息。

  2. 启动仪表板

cd ./output

./manager-api
  1. 在不更改配置的情况下,访问 http://127.0.0.1:9000 以使用带有 GUI 的仪表板,其中默认用户名和密码为 admin

作为服务使用

使用源代码编译方法进行部署时,您需要自己处理服务管理。 我们为使用 Systemd 服务管理器的操作系统提供服务文件模板。

  1. 安装
mkdir -p /usr/local/apisix-dashboard
cp -rf ./output/* /usr/local/apisix-dashboard
  1. 创建服务单元

复制以下或者直接使用这个file,需要复制到 /usr/lib/systemd/system 目录并执行 systemctl daemon-reload 命令。

# copy service unit
cp ./api/service/apisix-dashboard.service /usr/lib/systemd/system/apisix-dashboard.service
systemctl daemon-reload

# or: If you need to modify the service unit, you can use the following command
echo "[Unit]
Description=apisix-dashboard
Conflicts=apisix-dashboard.service
After=network-online.target

[Service]
WorkingDirectory=/usr/local/apisix-dashboard
ExecStart=/usr/local/apisix-dashboard/manager-api -c /usr/local/apisix-dashboard/conf/conf.yaml" > /usr/lib/systemd/system/apisix-dashboard.service
  1. 管理服务

您可以使用以下命令来管理服务

# start apisix-dashboard
systemctl start apisix-dashboard

# stop apisix-dashboard
systemctl stop apisix-dashboard

# check apisix-dashboard status
systemctl status apisix-dashboard

构建 Docker 镜像

NOTE: 我们支持 Docker Image,请访问 DockerHub 了解更多信息。 以下步骤用于手动构建 Docker Image。

要使用 Docker 构建仪表板,您只需将 Dockerfile 文件从 根目录 下载到您的设备(无需下载所有源代码),然后按照本指南进行操作。

manager-apiweb 将包含在此构建指南产品中。

先决条件

在使用 Docker 构建镜像和启动容器之前,请确保在您的环境中安装并运行以下依赖项。

  1. Docker
  2. etcd 3.4.0+

构建

# 在 Dockerfile 所在目录(默认为项目根目录)执行 build 命令,手动指定标签。
$ docker build -t apisix-dashboard:$tag .

# 对于中国大陆的用户,可以提供`ENABLE_PROXY`参数来加速模块下载。
$ docker build -t apisix-dashboard:$tag . --build-arg ENABLE_PROXY=true

# 如果要使用最新的代码来构建,可以将 `APISIX_DASHBOARD_VERSION` 参数指定给 `master`。
# 该参数也可以指定为特定版本的分支名称,例如`v2.1.1`
$ docker build -t apisix-dashboard:$tag . --build-arg APISIX_DASHBOARD_VERSION=master

启动

1.准备配置文件

在启动容器之前,需要在host内部准备好配置文件conf.yaml来覆盖默认的【配置文件】(https://github.com/apache/apisix-dashboard/blob/master /api/conf/conf.yaml)在容器内。

Kindly note:

  • 只有当conf.listen.host0.0.0.0时,外网才能访问容器内的服务。
  • conf.etcd.endpoints 必须能够访问容器内的 etcd 服务。 例如:使用 host.docker.internal:2379 以便容器可以访问主机网络上的 etcd
  1. 启动仪表板
#/path/to/conf.yaml 需要一个指向上述配置文件的绝对路径。
$ docker run -d -p 9000:9000 -v /path/to/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml --name apisix-dashboard apisix-dashboard:$tag

3.检查容器是否启动成功

$ docker ps -a

如果容器 apisix-dashboard 没问题,请访问 http://127.0.0.1:9000 使用带 GUI 的仪表板,默认用户名和密码为 admin

  1. 停止
$ docker stop apisix-dashboard

其他

1.多次构建映像时不建议使用缓存。

$ docker build -t apisix-dashboard:$tag . --no-cache=true
  1. 不建议同时使用多个实例。 当使用多个实例时,每个实例都会生成并持有一个 JWT 令牌,这会导致验证冲突。

posted on 2022-07-06 14:51  zh7314  阅读(1723)  评论(0编辑  收藏  举报