【问题标题】:API Gateway Ocelot and KubernetesAPI 网关 Ocelot 和 Kubernetes
【发布时间】:2021-12-11 11:35:21
【问题描述】:

我正在尝试使用 ocelot 网关访问我的 kubernetes 集群内的微服务“externalforum-api-svc”。我已经关注了文档,但它似乎不起作用。

谁能告诉我它有什么问题?

我想将 ocelot api 网关部署为 clusterIP 并使用 Ingress 从集群外部访问它,但是在尝试从集群内的 ocelot -> 服务重新路由时遇到此问题。

## 错误警告:Ocelot.Responder.Middleware.ResponderMiddleware[0] requestId: 0HMCO5SFMMOIQ:00000002, previousRequestId: no previous 请求 ID,消息:错误代码: UnableToFindServiceDiscoveryProviderError 消息:无法找到 类型的服务发现提供程序:在中发现的 consul 错误 响应者中间件。为请求设置错误响应 路径:/externalForumService,请求方法:GET

{
  "Routes": [
    {
      "UpstreamPathTemplate": "/externalForumService/GetAll",
      "DownstreamPathTemplate": "/api/externalforum/v1/forum/GetAll",
      "DownstreamScheme": "http",
      "ServiceName": "externalforum-api-svc",
      "UpstreamHttpMethod": [ "Get" ]
    },
    {
      "UpstreamPathTemplate": "/externalForumService",
      "DownstreamPathTemplate": "/api/externalforum/v1/forum",
      "DownstreamScheme": "http",
      "ServiceName": "externalforum-api-svc",
      "UpstreamHttpMethod": [ "Get" ]
    }
  ],
  "GlobalConfiguration": {
    "ServiceDiscoveryProvider": {
      "Namespace": "propnull",
      "Type": "kube"
    }
  }
}

地图服务

apiVersion: v1
kind: Service
metadata:
  name: externalforum-api-svc
  namespace: propnull
spec:
  type: ClusterIP
  selector:
    app: externalforum-api
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 80

我已经跑过kubectl create clusterrolebinding permissive-binding --clusterrole=cluster-admin --user=admin --user=kubelet --group=system:serviceaccounts

规格

  • 版本:17.0.0
  • 平台:网核5.0

【问题讨论】:

    标签: asp.net-core kubernetes microservices api-gateway ocelot


    【解决方案1】:

    尝试在 GlobalConfiguration 部分将“type : kube”更改为“type : KubernetesServiceDiscoveryProvider”。

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 2020-10-20
    • 2019-09-30
    • 2020-07-25
    • 2018-12-29
    • 2021-02-25
    • 1970-01-01
    • 2019-04-24
    • 2021-05-09
    • 2022-01-18
    相关资源
    最近更新 更多