Skip to content

How to provide Host to KubernetesServiceDiscoveryProvider? #2255

@chrisbecke

Description

@chrisbecke

The Problem

While navigating the docs I saw this rather concerning note:

Note 1: Host, Port and Token are no longer in use.

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.

Expectation

How to usePodServiceAccount to configure and use an external Kubernetes cluster should be documented.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    KubernetesService discovery by KubernetesNET9.NET 9 releaseService DiscoveryOcelot feature: Service DiscoverydocumentationNeeds a documentation update

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions