跳到主要内容

Test API Communication

Purpose: 一种内部测试方法,用于验证 API 是否在 Kong API Gateway 上正确部署并正常工作

Explanation:

Four typical call errors:
  • 当外部域名未在 DNS 服务器上注册或不正确时。
  • 当基础路径不正确时。
{
message: "没有与这些值匹配的路由"
}
  • 当后端 URL 不正确时。
{
message: "名称解析失败"
}
  • 后端应用程序未正常启动。
{
message: "从上游服务器接收到无效响应"
}
  • 其他上下文:检查网页浏览器 > 开发者工具

  • 如何检查您的 API 是否成功部署到 Kong API Gateway
# 访问 Kong API Gateway(任何 pod 只要在与 Kong Gateway 相同的集群中运行并支持 curl,就可以访问)
kubectl -n apim-dev exec --it {gateway pod name} -c fluent-bit /bin/bash

# 输入基础路径、子路径以在 Kong API Gateway API 代理的 80 端口进行验证
# 在 Header Host 中输入实际业务域名
# 如何测试就像您在与真实业务域名通信一样
curl -i -k http://{Kong-Service-Name}.{Kong-Namespace}:80/basePath/apiPath -H "Host: domain.com"