以下是使用Docker部署WSO2 API Manager(WSO2 APIM)的详细步骤,分为快速测试部署和生产级部署两种场景:
适用于快速体验,数据保存在容器内(重启后丢失):
# 拉取官方镜像(以最新版本为例)
docker pull wso2/wso2am:4.2.0
# 运行容器(映射管理端口和网关端口)
* 9443:9443 # 管理控制台(Publisher/Dev Portal)
* 8243:8243 # API Gateway HTTPS端口
* 8280:8280 # API Gateway HTTP端口
docker run -d
--name wso2-apim
-p 9443:9443
-p 8243:8243
-p 8280:8280
harbor.pkulaw.cn:8443/library/wso2am/wso2am:4.2.0-alpine
docker run -it -d
--name wso2-apim
-p 9443:9443
-p 8243:8243
-p 8280:8280
--user root
--privileged=true
-v /root/carbon/carbon.xml:/home/wso2carbon/wso2am-4.2.0/repository/conf/carbon.xml
harbor.pkulaw.cn:8443/library/wso2am/wso2am:4.2.0-alpine
# 访问管理界面
默认账号:admin/admin
地址:https://localhost:9443/devportal
推荐使用Docker Compose部署,支持持久化数据和外部数据库(以MySQL为例):
创建docker-compose.yml
文件
version: '3.8'
services:
mysql-db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wso2am_db
volumes:
- mysql-data:/var/lib/mysql
networks:
- apim-network
wso2-apim:
image: wso2/wso2am:4.2.0
depends_on:
- mysql-db
ports:
- "9443:9443"
- "8243:8243"
- "8280:8280"
volumes:
- apim-configs:/home/wso2carbon/wso2am-4.2.0/repository/conf
- apim-logs:/home/wso2carbon/wso2am-4.2.0/repository/logs
environment:
# 配置MySQL连接(覆盖默认H2)
- DB_HOST=mysql-db
- DB_PORT=3306
- DB_USER=root
- DB_PASSWORD=root
networks:
- apim-network
volumes:
mysql-data:
apim-configs:
apim-logs:
networks:
apim-network:
driver: bridge
初始化MySQL数据库
下载官方SQL脚本并执行:
# 下载APIM数据库脚本
wget https://raw.githubusercontent.com/wso2/docker-apim/master/docker-compose/apim-with-analytics/mysql/scripts/apimgt.sql
# 进入MySQL容器执行初始化
docker exec -i mysql-db mysql -uroot -proot wso2am_db
启动服务
docker-compose up -d
/repository/conf
目录,避免容器重启后配置丢失。/repository/logs
目录,便于排查问题。repository/conf/deployment.toml
,配置MySQL连接:[database.apim_db]
type = "mysql"
url = "jdbc:mysql://mysql-db:3306/wso2am_db"
username = "root"
password = "root"
wso2-apim
服务并配置共享数据库和注册表(参考官方集群指南)。docker logs -f wso2-apim
9443
、8243
、8280
端口未被占用。deployment.toml
中的连接参数。helm repo add wso2 https://helm.wso2.com && helm repo update
helm install wso2 wso2/am-single-node --version 4.2.0-alpine --namespace default
#查看helm仓库里有哪些景象
[root@cicd001 ~]# helm repo list
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/test-config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/test-config
NAME URL
apisix https://charts.apiseven.com
wso2 https://helm.wso2.com
graviteeio https://helm.gravitee.io
root@cicd001 ~]# helm search repo wso2
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/test-config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/test-config
NAME CHART VERSION APP VERSION DESCRIPTION
wso2/apim-apk-agent 1.3.0 1.3.0 A Helm chart for deploying apim-apk-agent
wso2/apk-helm 1.3.0 1.3.0 A Helm chart for APK components
wso2/kubernetes-pipeline 1.2.0 1.2.0 A Helm chart to deploy a CI/CD Pipeline in a Ku...
wso2/mysql 1.6.9 5.7.30 Fast, reliable, scalable, and easy to use open-...
wso2/nfs-server-provisioner 1.1.0 2.3.0 nfs-server-provisioner is an out-of-tree dynami...
wso2/spinnaker 2.2.6 1.16.2 Open source, multi-cloud continuous delivery pl...
# 由于docker景象国内云无法下载,需要我们修改景象地址,所以需要手动编辑values.yaml文件
helm pull wso2/am-single-node:4.2.0-alpine #可能没有这个景象,那么需要下载原代码来修改values.yaml
tar -xvf apim-4.7.2.tgz
helm upgrade wso2 ./am-single -f ./am-single/values.yaml -i -n default
Sign in to the Management Console (https://:9443/carbon).
Navigate to service providers list.
SP list
Click on the Edit button of API Publisher service provider
SP list
Navigate to Inbound Authentication Configuration > OAuth/OpenID Connect Configuration and click on OAuth application edit button.
OAuth app edit
See the Callback Url regex value configured under Application Settings. You will observe that the callback URL value is having a different hostname(localhost or previous hostname which was configured before the hostname change).
regexp=(https://localhost:9443/publisher/services/auth/callback/login|https://localhost:9443/publisher/services/auth/callback/logout)
Then replace the callback URL hostname with the current hostname of the server. For example, if the current hostname of the server is apim.wso2.com, the callback URL regex has to be changes as follows.
regexp=(https://apim.wso2.com:9443/publisher/services/auth/callback/login|https://apim.wso2.com:9443/publisher/services/auth/callback/logout)
参与评论
手机查看
返回顶部