2

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
Anil_M
  • 10,893
  • 6
  • 47
  • 74
Arthur Muller
  • 61
  • 2
  • 10

3 Answers3

1

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

tiomkin
  • 23
  • 1
  • 4
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 10 '22 at 20:51
1

In my case error was different and it could not map proper pod. So you can map manually

{
    "Routes": [
        {
            "DownstreamPathTemplate": "/api/{everything}",
            "DownstreamScheme": "http", 
            "DownstreamHostAndPorts": [
                {
                    "Host": "serviceName.Namespace.svc.cluster.local",
                    "Port": 80
                }
            ],
            "UpstreamPathTemplate": "/something/{everything}",
          
        },....
dawid debinski
  • 392
  • 4
  • 6
0

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

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