private static ServiceDiscovery.Providers.IServiceDiscoveryProvider GetkubeProvider(IServiceProvider provider, Configuration.ServiceProviderConfiguration config, DownstreamReRoute reRoute, IOcelotLoggerFactory factory) { var kubeClient = provider.GetService <IKubeApiClient>(); var k8sRegistryConfiguration = new KubeRegistryConfiguration() { KeyOfServiceInK8s = reRoute.ServiceName, KubeNamespace = string.IsNullOrEmpty(reRoute.ServiceNamespace) ? config.Namespace : reRoute.ServiceNamespace }; var k8sServiceDiscoveryProvider = new Kube(k8sRegistryConfiguration, factory, kubeClient); if (config.Type?.ToLower() == "pollkube") { return(new PollKube(config.PollingInterval, factory, k8sServiceDiscoveryProvider)); } return(k8sServiceDiscoveryProvider); }
private static ServiceDiscovery.Providers.IServiceDiscoveryProvider GetkubeProvider(IServiceProvider provider, Configuration.ServiceProviderConfiguration config, string name, IOcelotLoggerFactory factory) { var kubeClientFactory = provider.GetService <IKubeApiClientFactory>(); var k8sRegistryConfiguration = new KubeRegistryConfiguration() { ApiEndPoint = new Uri($"https://{config.Host}:{config.Port}"), KeyOfServiceInK8s = name, KubeNamespace = config.Namespace, AuthStrategy = KubeAuthStrategy.BearerToken, AccessToken = config.Token, AllowInsecure = true // Don't validate server certificate }; var k8sServiceDiscoveryProvider = new Kube(k8sRegistryConfiguration, factory, kubeClientFactory); if (config.Type?.ToLower() == "pollkube") { return(new PollKube(config.PollingInterval, factory, k8sServiceDiscoveryProvider)); } return(k8sServiceDiscoveryProvider); }