当前位置:   article > 正文

APISIX Dashboard中文文档(一)

apisix dashboard

2022年7月6日13:24:56

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

官方文档:https://apisix.apache.org/zh/docs/dashboard/USER_GUIDE/

用户指南

以下是模块快照的一部分。

仪表板#
我们通过在 iframe 中引用来支持监控页面。 在访问 Grafana 之前,请启用 allow_embedding=true,默认为 false。 由于安全策略,这会导致浏览器无法正确呈现 Grafana 页面。

image

路由#
Route 模块旨在通过 UI 控制路由,而不是调用 API。

列表#image

创建#image

image

image

image

image

设置#image

导入 OpenAPI 指南

概述#
OpenAPI 规范 (OAS) 为 RESTful API 定义了一个与语言无关的标准接口,它允许人类和计算机在不访问源代码、文档或通过网络流量检查的情况下发现和理解服务的功能。

Apache APISIX Dashboard 支持导入OpenApi3.0(我们将简称为 OAS3.0)文件,json并且yaml都支持,以创建一个或多个路由。目前我们支持大部分的 OpenApi 规范,但还是有一些区别,比如兼容性和扩展字段。

扩展字段#
APISIX Route 中有些字段是必填的,但 OAS3.0 的属性中没有包含,为了方便基于 OAS3.0 扩展自定义路由实体,我们增加了一些扩展字段,如上游、插件、主机等上。所有扩展都以 x-apisix 开头。

Extended fieldsAPISIX Route Properties
x-apisix-pluginsplugins
x-apisix-scriptscript
x-apisix-upstreamupstream
x-apisix-hosthost
x-apisix-hostshosts
x-apisix-remote_addrremote_addr
x-apisix-prioritypriority
x-apisix-varsvars
x-apisix-filter_funcfilter_func
x-apisix-labelslabels
x-apisix-enable_websocketenable_websocket
x-apisix-statusstatus
x-apisix-service_idservice_id
x-apisix-upstream_idupstream_id

请注意,我们只扩展了第一级字段,子级字段仍然保持不变。 以 x-apisix-upstream 为例。

  1. ...
  2. # 我们在 OAS3.0 中添加 x-apisix-upstream 作为扩展字段代表上游
  3. x-apisix-upstream:
  4. # x-apisix-upstream 的子字段仍然与上游的子字段保持一致
  5. type: roundrobin
  6. nodes:
  7. - host: 172.16.238.20
  8. port: 1980
  9. weight: 1
  10. ...

有关 APISIX 路由属性的更多详细信息,请参阅

OAS3.0 兼容性

当我们从 OAS3.0 导入路由时,会因为 APISIX 的 Route 中没有对应的字段而遗漏 OAS3.0 中的一些字段:

  1. API General Info:用于描述你的API的一般信息,有时,一个OAS3.0文件包含一系列 属于应用程序的 api,因此此信息不同于 api 的名称和额外的基本信息。

例子:

  1. # this part of information will be missed
  2. openapi: 3.0.0
  3. info:
  4. version: 1.0.0-oas3
  5. description: test desc
  6. license:
  7. name: Apache License 2.0
  8. url: 'http://www.apache.org/licenses/LICENSE-2.0'
  9. title: test title
  10. ...
  1. API 服务器和基本路径:上游 url + url 前缀(选项)

例子:

  1. # this part of information will be missed
  2. ...
  3. servers:
  4. - url: https://api.example.com/v1
  5. ...
  1. Path params: 路径中描述的 api 参数.

例子:

  1. # 不管 uri 中有多少路径参数
  2. # 从 OAS3.0 文件导入路由后,我们将得到带有 uri 的路由,如 `/get/*`
  3. ...
  4. paths:
  5. /get/{id}/{name}:
  6. delete:
  7. operationId: api1DELETE
  8. ...
  1. Query params: 查询中描述的 api 参数.

Example:

  1. ...
  2. paths:
  3. /users:
  4. get:
  5. summary: Get a user by ID
  6. # this part of information will be missed
  7. parameters:
  8. - in: path
  9. name: userId
  10. schema:
  11. type: integer
  12. required: true
  13. description: Numeric ID of the user to get
  14. ...
  1. Responses description and links: 定义 API 操作的响应.

Example:

  1. ...
  2. paths:
  3. /hello:
  4. get:
  5. description: hello world.
  6. operationId: hello
  7. x-apisix-service_id: service1
  8. # this part of information will be missed
  9. responses:
  10. '200':
  11. description: list response
  12. default:
  13. description: unexpected error
  14. ...

不同用户场景下OAS3.0配置示例

配置基本发布路由

提示:导入的路由默认的status为unpublished,表示该路由不能访问,如果要导入一个published的路由,需要在里面加上x-apisix-status: 1 你的OAS3.0文件

  1. openapi: 3.0.0
  2. info:
  3. version: 1.0.0-oas3
  4. description: test desc
  5. license:
  6. name: Apache License 2.0
  7. url: 'http://www.apache.org/licenses/LICENSE-2.0'
  8. title: test title
  9. paths:
  10. /hello: # route uri
  11. get: # route method
  12. description: hello world. # route desc
  13. operationId: hello # route name
  14. x-apisix-upstream: # route upstream
  15. type: roundrobin
  16. nodes:
  17. - host: 172.16.238.20
  18. port: 1980
  19. weight: 1
  20. x-apisix-status: 1 # the route will be published after imported
  21. responses:
  22. '200':
  23. description: list response
  24. default:
  25. description: unexpected error

使用插件配置路由

提示:扩展字段支持的大多数插件 x-apisix-plugins

  1. openapi: 3.0.0
  2. info:
  3. version: 1.0.0-oas3
  4. description: test desc
  5. license:
  6. name: Apache License 2.0
  7. url: 'http://www.apache.org/licenses/LICENSE-2.0'
  8. title: test title
  9. paths:
  10. /hello:
  11. get:
  12. description: hello world.
  13. operationId: hello
  14. x-apisix-upstream:
  15. type: roundrobin
  16. nodes:
  17. - host: 172.16.238.20
  18. port: 1980
  19. weight: 1
  20. x-apisix-plugins:
  21. limit-count:
  22. count: 2
  23. time_window: 60
  24. rejected_code: 503
  25. key: remote_addr
  26. policy: local
  27. responses:
  28. '200':
  29. description: list response
  30. default:
  31. description: unexpected error

配置带有参数验证的路由

提示:对于插件 request-validation,我们将使用 参数序列化 用于标头参数验证和 描述请求正文 用于 OAS3.0 中的正文参数验证

  1. openapi: 3.0.0
  2. info:
  3. version: "1"
  4. description: |-
  5. test desc
  6. license:
  7. name: Apache License 2.0
  8. url: http://www.apache.org/licenses/LICENSE-2.0
  9. title: |-
  10. test title
  11. paths:
  12. /hello:
  13. post:
  14. description: |-
  15. hello world.
  16. operationId: hello
  17. x-apisix-upstream:
  18. type: roundrobin
  19. nodes:
  20. - host: "172.16.238.20"
  21. port: 1980
  22. weight: 1
  23. parameters:
  24. - name: id
  25. in: header
  26. description: ID of pet to use
  27. required: true
  28. schema:
  29. type: string
  30. style: simple
  31. requestBody:
  32. content:
  33. 'application/x-www-form-urlencoded':
  34. schema:
  35. properties:
  36. name:
  37. description: Update pet's name
  38. type: string
  39. status:
  40. description: Updated status of the pet
  41. type: string
  42. required:
  43. - status
  44. responses:
  45. 200:
  46. description: list response
  47. default:
  48. description: unexpected error

使用身份验证插件配置路由

注意: 对于插件 basic-auth jwt-authkey-auth 我们将使用 Authentication 在 OAS3.0

  1. components:
  2. securitySchemes:
  3. basicAuth:
  4. type: http
  5. scheme: basic
  6. BearerAuth:
  7. type: http
  8. scheme: bearer
  9. bearerFormat: JWT
  10. ApiKeyAuth:
  11. type: apiKey
  12. in: header
  13. name: X-API-Key
  14. openapi: 3.0.0
  15. info:
  16. version: "1"
  17. description: |-
  18. test desc
  19. license:
  20. name: Apache License 2.0
  21. url: http://www.apache.org/licenses/LICENSE-2.0
  22. title: |-
  23. test title
  24. paths:
  25. /hello:
  26. post:
  27. description: |-
  28. hello world.
  29. operationId: hello
  30. x-apisix-upstream:
  31. type: roundrobin
  32. nodes:
  33. - host: "172.16.238.20"
  34. port: 1980
  35. weight: 1
  36. security:
  37. - basicAuth: []
  38. - ApiKeyAuth: []
  39. - BearerAuth: []
  40. responses:
  41. 200:
  42. description: list response
  43. default:
  44. description: unexpected error

配置现有服务或上游的路由

提示: 如果 APISIX 中不存在 service_idupstream_id,从配置文件导入路由会报错

  1. openapi: 3.0.0
  2. info:
  3. version: 1.0.0-oas3
  4. description: test desc
  5. license:
  6. name: Apache License 2.0
  7. url: 'http://www.apache.org/licenses/LICENSE-2.0'
  8. title: test title
  9. paths:
  10. /hello:
  11. get:
  12. description: hello world.
  13. operationId: hello
  14. x-apisix-service_id: service1
  15. responses:
  16. '200':
  17. description: list response
  18. default:
  19. description: unexpected error

配置多个路由

  1. info:
  2. title: RoutesExport
  3. version: 3.0.0
  4. openapi: 3.0.0
  5. paths:
  6. /get:
  7. delete:
  8. operationId: api1Delete
  9. requestBody: {}
  10. responses:
  11. default:
  12. description: ''
  13. x-apisix-enableWebsocket: false
  14. x-apisix-labels:
  15. API_VERSION: v2
  16. dev: test
  17. x-apisix-plugins:
  18. proxy-rewrite:
  19. disable: false
  20. scheme: https
  21. x-apisix-priority: 0
  22. x-apisix-status: 1
  23. x-apisix-upstream:
  24. nodes:
  25. - host: httpbin.org
  26. port: 443
  27. weight: 1
  28. type: roundrobin
  29. pass_host: node
  30. x-apisix-vars: []
  31. get:
  32. operationId: api1Get
  33. requestBody: {}
  34. responses:
  35. default:
  36. description: ''
  37. x-apisix-enableWebsocket: false
  38. x-apisix-labels:
  39. API_VERSION: v2
  40. dev: test
  41. x-apisix-plugins:
  42. proxy-rewrite:
  43. disable: false
  44. scheme: https
  45. x-apisix-priority: 0
  46. x-apisix-status: 1
  47. x-apisix-upstream:
  48. nodes:
  49. - host: httpbin.org
  50. port: 443
  51. weight: 1
  52. type: roundrobin
  53. pass_host: node
  54. x-apisix-vars: []
  55. /post:
  56. post:
  57. operationId: test_post
  58. requestBody: {}
  59. responses:
  60. default:
  61. description: ''
  62. security: []
  63. x-apisix-enableWebsocket: false
  64. x-apisix-labels:
  65. API_VERSION: v1
  66. version: v1
  67. x-apisix-plugins:
  68. proxy-rewrite:
  69. disable: false
  70. scheme: https
  71. x-apisix-priority: 0
  72. x-apisix-status: 1
  73. x-apisix-upstream:
  74. nodes:
  75. - host: httpbin.org
  76. port: 443
  77. weight: 1
  78. type: roundrobin
  79. pass_host: node
  80. x-apisix-vars: []

管理API 的 API 文档

Manager API 直接操作 ETCD 并为 Apache APISIX 提供数据管理,为前端或其他客户端提供 API.

License: Apache License 2.0

/apisix/admin/migrate/export

GET
简介

导出配置文件以进行迁移

参数

None.

返回

A file for download.

/apisix/admin/migrate/import

简介

导入配置文件以恢复配置

POST
参数 (FORM)
NameLocated inDescriptionRequiredSchema
modebody(form)import mode (return, skip or overwrite)Yesstring
filebody(form)file to uploadYesstring
返回
CodeDescriptionSchema
0import successApiError
20001Config conflictApiError

/apisix/admin/check_ssl_cert

POST
简介

验证 SSL 证书和密钥

参数
NameLocated inDescriptionRequiredSchema
certbodycert of SSLYesstring
keybodykey of SSLYesstring
返回
CodeDescriptionSchema
0SSL verify passedApiError
defaultunexpected errorApiError

/apisix/admin/check_ssl_exists

POST
简介

检查 SSL 是否存在

参数
NameLocated inDescriptionRequiredSchema
certbodycert of SSLYesstring
keybodykey of SSLYesstring
返回
CodeDescriptionSchema
0SSL existsApiError
defaultunexpected errorApiError

/apisix/admin/consumers

GET
简介

根据指定的页码和页面大小返回消费者列表,可以通过用户名搜索消费者。

参数
NameLocated inDescriptionRequiredSchema
pagequerypage numberNointeger
page_sizequerypage sizeNointeger
usernamequeryusername of consumerNostring
返回
CodeDescriptionSchema
0list response[ consumer ]
defaultunexpected errorApiError

/apisix/admin/notexist/routes

GET
简介

路由的返回结果通过名称和排除ID检查是否存在

参数
NameLocated inDescriptionRequiredSchema
namequeryname of routeNostring
excludequeryid of route that exclude checkingNostring
返回
CodeDescriptionSchema
0route not existsApiError
defaultunexpected errorApiError

/apisix/admin/routes

GET
简介

根据指定的页码和页面大小返回路由列表,可以按名称和uri搜索路由

参数
NameLocated inDescriptionRequiredSchema
pagequerypage numberNointeger
page_sizequerypage sizeNointeger
namequeryname of routeNostring
uriqueryuri of routeNostring
labelquerylabel of routeNostring
返回
CodeDescriptionSchema
0list response[ route ]
defaultunexpected errorApiError

/apisix/admin/services

GET
简介

根据指定的页码和页面大小返回服务列表,并可按名称搜索服务

参数
NameLocated inDescriptionRequiredSchema
pagequerypage numberNointeger
page_sizequerypage sizeNointeger
namequeryname of serviceNostring
返回
CodeDescriptionSchema
0list response[ service ]
defaultunexpected errorApiError

/apisix/admin/ssl

GET
简介

根据指定的页码和页面大小返回 SSL 列表,可以通过 sni 进行 SSL 搜索。

参数
NameLocated inDescriptionRequiredSchema
pagequerypage numberNointeger
page_sizequerypage sizeNointeger
sniquerysni of SSLNostring
返回
CodeDescriptionSchema
0list response[ ssl ]
defaultunexpected errorApiError

/apisix/admin/upstreams

GET
简介

根据指定的页码和页面大小返回上游列表,可以按名称搜索上游

参数
NameLocated inDescriptionRequiredSchema
pagequerypage numberNointeger
page_sizequerypage sizeNointeger
namequeryname of upstreamNostring
返回
CodeDescriptionSchema
0list response[ upstream ]
defaultunexpected errorApiError

/apisix/admin/user/login

POST
简介

用户登录.

参数
NameLocated inDescriptionRequiredSchema
usernamebodyuser nameYesstring
passwordbodypasswordYesstring
返回
CodeDescriptionSchema
0login successApiError
defaultunexpected errorApiError

Models

ApiError
NameTypeDescriptionRequired
codelongresponse codeNo
messagestringresponse messageNo
BaseInfo
NameTypeDescriptionRequired
create_timelongNo
idobjectNo
update_timelongNo
Consumer
NameTypeDescriptionRequired
create_timelongNo
descstringNo
idobjectNo
labelsobjectNo
pluginsobjectNo
update_timelongNo
usernamestringNo
LoginInput
NameTypeDescriptionRequired
passwordstringpasswordNo
usernamestringuser nameNo
Route
NameTypeDescriptionRequired
create_timelongNo
descstringNo
enable_websocketbooleanNo
filter_funcstringNo
hoststringNo
hosts[ string ]No
idobjectNo
labelsobjectNo
methods[ string ]No
namestringNo
pluginsobjectNo
prioritylongNo
remote_addrstringNo
remote_addrs[ string ]No
scriptobjectNo
service_idobjectNo
service_protocolstringNo
update_timelongNo
upstreamUpstreamDefNo
upstream_idobjectNo
uristringNo
uris[ string ]No
varsobjectNo
SSL
NameTypeDescriptionRequired
certstringNo
certs[ string ]No
create_timelongNo
exptimelongNo
idobjectNo
keystringNo
keys[ string ]No
labelsobjectNo
snistringNo
snis[ string ]No
statuslongNo
update_timelongNo
validity_endlongNo
validity_startlongNo
Service
NameTypeDescriptionRequired
create_timelongNo
descstringNo
enable_websocketbooleanNo
idobjectNo
labelsobjectNo
namestringNo
pluginsobjectNo
scriptstringNo
update_timelongNo
upstreamUpstreamDefNo
upstream_idobjectNo
Upstream
NameTypeDescriptionRequired
checksobjectNo
create_timelongNo
descstringNo
hash_onstringNo
idobjectNo
k8s_deployment_infoobjectNo
keystringNo
labelsobjectNo
namestringNo
nodesobjectNo
pass_hoststringNo
retrieslongNo
service_namestringNo
timeoutobjectNo
typestringNo
update_timelongNo
upstream_hoststringNo
UpstreamDef
NameTypeDescriptionRequired
checksobjectNo
descstringNo
hash_onstringNo
k8s_deployment_infoobjectNo
keystringNo
labelsobjectNo
namestringNo
nodesobjectNo
pass_hoststringNo
retrieslongNo
service_namestringNo
timeoutobjectNo
typestringNo
upstream_hoststringNo
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/214171
推荐阅读
相关标签
  

闽ICP备14008679号