mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2024-12-22 11:06:04 +00:00
Merge pull request #708 from zalando-incubator/fix-apiserver-setup
Fix custom apiserver setup
This commit is contained in:
commit
f55afc0905
@ -151,21 +151,8 @@ func (o AdapterServerOptions) RunCustomMetricsAdapterServer(stopCh <-chan struct
|
|||||||
klog.Fatal(http.ListenAndServe(o.MetricsAddress, nil))
|
klog.Fatal(http.ListenAndServe(o.MetricsAddress, nil))
|
||||||
}()
|
}()
|
||||||
|
|
||||||
serverConfig := genericapiserver.NewRecommendedConfig(apiserver.Codecs)
|
|
||||||
err := o.CustomMetricsAdapterServerOptions.ApplyTo(serverConfig)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
config := &apiserver.Config{
|
|
||||||
GenericConfig: &serverConfig.Config,
|
|
||||||
}
|
|
||||||
|
|
||||||
config.GenericConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(generatedopenapi.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(apiserver.Scheme))
|
|
||||||
config.GenericConfig.OpenAPIConfig.Info.Title = "kube-metrics-adapter"
|
|
||||||
config.GenericConfig.OpenAPIConfig.Info.Version = "1.0.0"
|
|
||||||
|
|
||||||
var clientConfig *rest.Config
|
var clientConfig *rest.Config
|
||||||
|
var err error
|
||||||
if len(o.RemoteKubeConfigFile) > 0 {
|
if len(o.RemoteKubeConfigFile) > 0 {
|
||||||
loadingRules := &clientcmd.ClientConfigLoadingRules{ExplicitPath: o.RemoteKubeConfigFile}
|
loadingRules := &clientcmd.ClientConfigLoadingRules{ExplicitPath: o.RemoteKubeConfigFile}
|
||||||
loader := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, &clientcmd.ConfigOverrides{})
|
loader := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, &clientcmd.ConfigOverrides{})
|
||||||
@ -178,6 +165,21 @@ func (o AdapterServerOptions) RunCustomMetricsAdapterServer(stopCh <-chan struct
|
|||||||
return fmt.Errorf("unable to construct lister client config to initialize provider: %v", err)
|
return fmt.Errorf("unable to construct lister client config to initialize provider: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
serverConfig := genericapiserver.NewRecommendedConfig(apiserver.Codecs)
|
||||||
|
serverConfig.ClientConfig = clientConfig
|
||||||
|
err = o.CustomMetricsAdapterServerOptions.ApplyTo(serverConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
config := &apiserver.Config{
|
||||||
|
GenericConfig: &serverConfig.Config,
|
||||||
|
}
|
||||||
|
|
||||||
|
config.GenericConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(generatedopenapi.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(apiserver.Scheme))
|
||||||
|
config.GenericConfig.OpenAPIConfig.Info.Title = "kube-metrics-adapter"
|
||||||
|
config.GenericConfig.OpenAPIConfig.Info.Version = "1.0.0"
|
||||||
|
|
||||||
// convert stop channel to a context
|
// convert stop channel to a context
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
go func() {
|
go func() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user