-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot resolve scoped service KubeClient.IKubeApiClient
from root provider
#977
Comments
Have you managed to solve this? I'm having the same issue. |
Any news regarding this issue? I am also having this problem. |
This happen when the KubeClient is not able to load the KUBECONFIG from the cluster during his instantiation (Injection), for example when you are running on a local machine. |
That happens because |
@Marusyk did you found any solution for this, I am facing this same issue |
@neetra |
Hello, you cant register your own IServiceDiscoveryProvider that initiates a scope before resolving the IKubeApiClient. Not so elegant because a scope is created every time but It works :) Another option is to register manually the
|
I created a file named KubeKubernetesServiceDiscoveryProvider and pasted above code, but not able to compile, can you please help me with the which version you are using (I am using Version=2.3.11.0) _
_ |
@ussamoo how do you come to know, how it is loaded? |
Sorry, I have a custom "kube-api-envelop" and the code was copied from it and modified. But it is based in the original file. Instead injecting the "IKubeApiClient", inject the "IServiceProvider" and resolve in a new scope before using it. Something like this
|
The kube-client library is dotnet-kube-client and the file that register the IKubeClient in the injector is that extension Here you can check from where it reads the configuration and that is registered a scoped services. Maybe check there if the default scope should be scoped or if they want to include a method to change scope. |
We found that the scope error only occurres when environment variable ASPNETCORE_ENVIRONMENT = Development
|
Hi @mot256 If you set this setting to false you are going to have an exception at runtime ;) |
Nope. Works just fine. Its without setting it to false in runtime that we get an issue... |
Reopened due #2178 (comment) |
@kick2nick, welcome! |
Discussed in #1948 |
Duplicate of #1470 |
Hi @raman-m, I'll take that. Need one day if we stick to solution proposed in #2178 (comment) - register IKubeApiClient as singleton as far as it already used like singleton. |
Validating scopes is essential, and DI-scopes should also be verified within your solutions. |
Thank you for your intention to contribute!
However, this is not the core issue. The problem lies in the incorrect implementation within the WithKubernetes and WithKubernetesAndRoundRobin helpers. It should be restructured using
Yes, you do! Please enable scope validation.
There's no need to wait for the issue mentioned in #2178. Your focus should be on
Again, waiting for anything related to #2178 is unnecessary. |
I have some doubts about this approach:
|
KubeClient.IKubeApiClient
from root provider
…y providers (#2180) * Fixed Kube/PollKube service provider scope validation * fix pollkube tests * remove BDDfy * Fix tests * Bump KubeClient to 2.5.12 * Code review by @raman-m * no Chinese tests now! * Cover by unit tests * Validate DI scopes in acceptance tests --------- Co-authored-by: kick2nick <nkuksov@beeline.ru> Co-authored-by: Raman Maksimchuk <dotnet044@gmail.com>
Expected Behavior / New Feature
redirect to service in k8s cluster
Actual Behavior / Motivation for New Feature
Steps to Reproduce the Problem
Follow this docs https://ocelot.readthedocs.io/en/latest/features/kubernetes.html
services.AddOcelot(_configuration).AddKubernetes(false); // or true
My service in k8s: devices-api.dev:10010
Config:
Specifications
The text was updated successfully, but these errors were encountered: