'API Gateway Ocelot and Kubernetes

I am trying to access my microservice "externalforum-api-svc" inside my kubernetes cluster using ocelot gateway. I`ve followed the docs but it does not seem to be working.

Can someone please tell me whats wrong with it?

I want to deploy the ocelot api gateway as clusterIP and use Ingress to access it from outside of the cluster, but i am facing this issue when trying to reroute from ocelot -> service inside the cluster.

## Error warn: Ocelot.Responder.Middleware.ResponderMiddleware[0] requestId: 0HMCO5SFMMOIQ:00000002, previousRequestId: no previous request id, message: Error Code: UnableToFindServiceDiscoveryProviderError Message: Unable to find service discovery provider for type: consul errors found in ResponderMiddleware. Setting error response for request path:/externalForumService, request method: 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"
    }
  }
}

Service to map

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

I have already ran kubectl create clusterrolebinding permissive-binding --clusterrole=cluster-admin --user=admin --user=kubelet --group=system:serviceaccounts

Specifications

  • Version: 17.0.0
  • Platform: net core 5.0


Solution 1:[1]

Try to change "type : kube" to "type : KubernetesServiceDiscoveryProvider" in GlobalConfiguration section.

Solution 2:[2]

On Ocelot 18 (Kubernetes 1.20) just update your service provider type, the documentation is outdated:

"GlobalConfiguration": {
 "ServiceDiscoveryProvider": {
   "Namespace": "propnull",
   "Type": "KubernetesServiceDiscoveryProvider"
 }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2