mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 21:50:05 +00:00
Change proxy config to reuse util/config
Splits endpoint and service configuration into their own objects. Also makes the endpoint and service configuration tests correct - there was a race condition previously that meant tests were passing but not checking correct code.
This commit is contained in:
@@ -41,27 +41,27 @@ func main() {
|
||||
|
||||
glog.Infof("Using configuration file %s and etcd_servers %s", *configFile, *etcdServers)
|
||||
|
||||
proxyConfig := config.NewServiceConfig()
|
||||
serviceConfig := config.NewServiceConfig()
|
||||
endpointsConfig := config.NewEndpointsConfig()
|
||||
|
||||
// Create a configuration source that handles configuration from etcd.
|
||||
etcdClient := etcd.NewClient([]string{*etcdServers})
|
||||
config.NewConfigSourceEtcd(etcdClient,
|
||||
proxyConfig.GetServiceConfigurationChannel("etcd"),
|
||||
proxyConfig.GetEndpointsConfigurationChannel("etcd"))
|
||||
serviceConfig.Channel("etcd"),
|
||||
endpointsConfig.Channel("etcd"))
|
||||
|
||||
// And create a configuration source that reads from a local file
|
||||
config.NewConfigSourceFile(*configFile,
|
||||
proxyConfig.GetServiceConfigurationChannel("file"),
|
||||
proxyConfig.GetEndpointsConfigurationChannel("file"))
|
||||
serviceConfig.Channel("file"),
|
||||
endpointsConfig.Channel("file"))
|
||||
|
||||
loadBalancer := proxy.NewLoadBalancerRR()
|
||||
proxier := proxy.NewProxier(loadBalancer)
|
||||
// Wire proxier to handle changes to services
|
||||
proxyConfig.RegisterServiceHandler(proxier)
|
||||
serviceConfig.RegisterHandler(proxier)
|
||||
// And wire loadBalancer to handle changes to endpoints to services
|
||||
proxyConfig.RegisterEndpointsHandler(loadBalancer)
|
||||
endpointsConfig.RegisterHandler(loadBalancer)
|
||||
|
||||
// Just loop forever for now...
|
||||
select {}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user