mac + docker 安装etcd & apisix-dashboard

背景

本地需要搭建apisix开发环境,进行一些功能开发。像依赖的etcd、可视化服务apisix-dashboard可以通过docker部署启动。

前提

docker安装:https://docs.docker.com/desktop/mac/install

etcd安装

1. 拉取bitnami/etcd镜像

 docker pull bitnami/etcd

2. 启动etcd

docker run -it --name etcd-server \
-p 2379:2379 -p 2380:2380 \
--env ALLOW_NONE_AUTHENTICATION=yes \
-d bitnami/etcd

通过访问宿主机本身端口2379即可访问etcd

3. 可视化etcd管理平台etcd-manager安装

本机没有etcd环境,并且对etcd命令查看数据不方便,可以安装etcd管理平台。

从github地址https://github.com/gtamas/etcdmanager 找到安装包进行安装即可。

mac + docker 安装etcd & apisix-dashboard

 配置ip和端口就可以使用了,在manage keys菜单栏查看数据

apisix-dashboard安装

1. 拉取apache/apisix-dashboard官方镜像

docker pull apache/apisix-dashboard

2. 创建配置文件

dashboard和etcd不在同一个实例上,所以要修改conf.yaml默认的etcd配置。

创建一个新的conf.yaml配置,没配置的选项默认使用apisix-dashboard提供的配置。

创建命令:
vim ~/docker/apisix/apisix-dashboard/conf.yaml
配置内容:

先通过ifconfig获取宿主机ip

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

conf:
  listen:
    host: 0.0.0.0     # `manager api` listening ip or host name
    port: 9000          # `manager api` listening port
  allow_list:
  etcd:
    endpoints:          # supports defining multiple etcd host addresses for an etcd cluster
      - 192.168.0.106:2379  #ip为宿主机ip
                          # yamllint disable rule:comments-indentation
                          # etcd basic auth info
    # username: "root"    # ignore etcd username if not enable etcd auth
    # password: "123456"  # ignore etcd password if not enable etcd auth
authentication:
  secret:
    secret              # secret for jwt token generation.
                        # NOTE: Highly recommended to modify this value to protect `manager api`.
                        # if it's default value, when `manager api` start, it will generate a random string to replace it.
  expire_time: 3600000     # 本地测试,不想一直输入密码,特地设置长了些
  users:                # yamllint enable rule:comments-indentation
    - username: admin   # username and password for login `manager api`
      password: admin
    - username: user
      password: user

3. 启动dashboard

docker run -d \
-p 9000:9000 \
-v ~/docker/apisix/apisix-dashboard/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml \
apache/apisix-dashboard

4. 访问 dashboard

打开浏览器,地址栏输入http://127.0.0.1:9000/

mac + docker 安装etcd & apisix-dashboard

 输入账号admin/admin登录

 

 

 

上一篇:Apache APISIX 社区周报 | 2021 10.1-10.14


下一篇:apisix ~ 1