How to provide Host to Kubernetes service discovery provider? #2256
-
The ProblemWhile navigating the docs I saw this rather concerning note:
As my situation is I am routing traffic to pods on a EKS cluster from an Ocelot based gateway running on docker on an EC2 node external to the cluster, this capability was important to me. ExpectationHow to RealityI needed the following code in my var cfg = Configuration.GetSection("GlobalConfiguration:ServiceDiscoveryProvider");
var Host = cfg.GetValue<string>("Host");
var Port = cfg.GetValue<int>("Port", 443);
var Token = cfg.GetValue<string>("Token");
services.Configure<KubeClientOptions>(options => {
options.ApiEndPoint = new UriBuilder("https",Host,Port).Uri;
options.AuthStrategy = KubeAuthStrategy.BearerToken;
options.AccessToken = Token;
options.AllowInsecure = true;
});
services.AddOcelot(Configuration).AddKubernetes(false); |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
Hello, Chris! Our NuGet Ocelot.Provider.Kubernetes extension package is based on the KubeClient package. For a comprehensive understanding, it is essential refer to the KubeClient documentation.
So, the subject of discussion is this line in docs: Ocelot/docs/features/kubernetes.rst Line 83 in ab119f8 This phrase was added in the following 👇
By default, The sentence in the documentation can confuse developers. Would you like us to rewrite the documentation and provide more explanation? |
Beta Was this translation helpful? Give feedback.
-
Sorry? useServiceAccount = trueIt is already documented in the Install section. useServiceAccount = falseYou are correct; the documentation for this mode and its configuration can be improved. A code sample is necessary. Here is adding services: So, useServiceAccount is false .
|
Beta Was this translation helpful? Give feedback.
-
It should work, but you forgot to replace the configuration service in DI for the Ocelot/src/Ocelot.Provider.Kubernetes/OcelotBuilderExtensions.cs Lines 31 to 34 in ab119f8 If you bind the configuration section to the IOptions<KubeClientOptions> interface, then your solution will be correct.
|
Beta Was this translation helpful? Give feedback.
It should work, but you forgot to replace th…