Ocelot
Ocelot copied to clipboard
After updating to kube 15.0.6, no redirect working
Expected Behavior / New Feature
We had 14.0.11 installed for our gateway service running in Azure K8s, version 1.15.7. After updating to 15.0.6 no reroutes are working. There should be no regressions when doing this update.
Actual Behavior / Motivation for New Feature
Looking at the logs, it shows these errors: Unable to find service discovery provider for type: kube
Here is the Global config:
"GlobalConfiguration": { "ServiceDiscoveryProvider": { "Host": "unused", "Port": 443, "Token": "unused", "Namespace": "XXX", "Type": "kube" } }
Since we use rbac with least accessabiliy we have the following definition for the access rights.
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: XXX
name: api-serviceaccount
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: XXX
name: service-reader
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["services", "endpoints", "pods"]
verbs: ["get", "watch", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-services
namespace: XXX
subjects:
- kind: ServiceAccount
name: api-serviceaccount
namespace: XXX
apiGroup: ""
roleRef:
kind: Role #this must be Role or ClusterRole
name: service-reader
apiGroup: rbac.authorization.k8s.io
Any other information thats needed? Everything else we kept the same, its really only the nuget update and the user account changes.
Steps to Reproduce the Problem
- Build a system using 14.x.x for k8s and define a reroute.
- Update the kubernetes nuget to 15.06
- Verify that the reroute is still working
Specifications
- Version: 15.0.6
- Platform: net core 3.1
- Subsystem: kube
The way I see it, this commit https://github.com/ThreeMammals/Ocelot/commit/6e5471a714dddb0a3a40fbb97eac2810cee1c78d renamed service discovery providers and now they are rejected here https://github.com/ThreeMammals/Ocelot/blob/master/src/Ocelot/ServiceDiscovery/ServiceDiscoveryProviderFactory.cs#L57. This should be broken for all service discovery providers as they were renamed in multiple places.
The way I got it to work was to create proxy providers with proper names, like they used to have: https://gist.github.com/molesinski/c949264d2d287e13c8c7477eb0632221
Thanks for the solution! Looks like a pretty major bug to me.
Looking at it briefly, would setting the type in GlobalConfiguration to KubernetesServiceDiscoveryProvider work? Guess is should right?
No, it wouldn't, because here it still is looking for old type name, which is "pollkube": https://github.com/ThreeMammals/Ocelot/blob/master/src/Ocelot.Provider.Kubernetes/KubernetesProviderFactory.cs#L30
Ok, pollkube will remain broken but the default implementation should work or am i overlooking something?
I can confirm that molesinski's solution works. I will still keep this open though because this should be fixed at library level.
I'm also receiving this issue trying out the latest version of Ocelot. I agree this seems like a major bug that should be fixed asap.
I can indeed confirm that version 15.x doesn't work. When going back to 14.1.3 all works fine!
Same problem. Please, fix it!
I have tried the 15.x and indeed it does not work with provider type "kube" or "pollkube" via appsettings.json. So I rolled back to 14.1.3.
I know it is a major change version. Shouldn't it have a documentation for what has changed?
I just started a new project with 16.0.1 and am getting this error so still not fixed. Should I downgrade to 14.1.3? The documentation is also wrong, I just wasted a whole day because I assumed I must be doing something wrong because it's never worked for me.
If you dont use k8s you can downgrade to 14.x otherwise you should use 16.x and apply the fix that is described in this thread. Otherwise the traffic load balancing will not work correctly.
Thanks. I missed the fix on first read through. I'll give that a go.
I can confirm that molesinski's solution works. I will still keep this open though because this should be fixed at library level.
Um, I am trying to use @molesinski's fix for v16.0.1, but it doesn't work for me.
What I've done is - Added OcelotBuilderExtensions molesinski's from to my solution, then
services
.AddOcelot()
.AddKubernetesFixed(); // https://github.com/ThreeMammals/Ocelot/issues/1199
Am I missing something?
Found out the reason from https://github.com/ThreeMammals/Ocelot/commit/3439be89271bb37b170429d69ca74978c941432e It turns out that v16.0.1 has changed the ReRoutes to Routes.
@elvishsu66 so you used ReRoutes in the config instead of Routes? If so its not a related issue. It was a breaking change from older versions to v16.
@elvishsu66 so you used ReRoutes in the config instead of Routes? If so its not a related issue. It was a breaking change from older versions to v16.
Yes, @rakkum, that was my mistake. @molesinski's fix works for me as well.
Run into the same problem.Hope to repair as soon as possible.
I am also having this same issue in version 17.0
as well. Any timeline when this will be implemented in the library?
@molesinski - your solution worked for me in new version 17.0
of Ocelot package. Thanks so much.
The way I see it, this commit 6e5471a renamed service discovery providers and now they are rejected here https://github.com/ThreeMammals/Ocelot/blob/master/src/Ocelot/ServiceDiscovery/ServiceDiscoveryProviderFactory.cs#L57. This should be broken for all service discovery providers as they were renamed in multiple places.
The way I got it to work was to create proxy providers with proper names, like they used to have: https://gist.github.com/molesinski/c949264d2d287e13c8c7477eb0632221
How do you implement this code? How do you make ocelot use the OcelotBuilderExtensions.
@molesinski - your solution worked for me in new version
17.0
of Ocelot package. Thanks so much.
How did you implement it, can simply add it to your project. Or do you need to change a file. Or do you need to give it to ocelot in the Startup.cs.
Is there any chance this fix will be merged into develop
branch?
@molesinski commented on Apr 15, 2020
Thanks for your interest in Ocelot! Why not to create a PR?
@rakkum @molesinski @elvishsu66 @MrDaedra and other people I am very sorry, guys, you have experienced such problems with K8s provider all these 3-4 years. Yes, the problem was introduced in 15.0.0 release by Tom in the commit https://github.com/ThreeMammals/Ocelot/commit/6e5471a714dddb0a3a40fbb97eac2810cee1c78d 🤯 , see my comment
Fixed by #1954 on Feb 12 Fixed in version 23.0.0, released on Feb 13