Skip to content

How to provide Host to Kubernetes service discovery provider? #2256

Answered by raman-m
chrisbecke asked this question in Q&A
Discussion options

You must be logged in to vote

Reality

I needed the following code in my Startup.cs to connect to a cluster the way the documentation implies should be possible

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);

It should work, but you forgot to replace th…

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@chrisbecke
Comment options

@raman-m
Comment options

@chrisbecke
Comment options

@raman-m
Comment options

Comment options

You must be logged in to vote
6 replies
@raman-m
Comment options

@chrisbecke
Comment options

@raman-m
Comment options

@raman-m
Comment options

@raman-m
Comment options

Answer selected by raman-m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Service Discovery Ocelot feature: Service Discovery Kubernetes Service discovery by Kubernetes NET9 .NET 9 release
2 participants
Converted from issue

This discussion was converted from issue #2255 on January 24, 2025 08:14.