1. 程式人生 > 其它 >mac + docker 安裝etcd & apisix-dashboard

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 找到安裝包進行安裝即可。

配置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/

輸入賬號admin/admin登入