From feed19920a135975ce0990e5015a21178ac4516f Mon Sep 17 00:00:00 2001 From: Fiachra Corcoran Date: Thu, 18 Apr 2024 11:46:09 +0100 Subject: [PATCH] Fix running api server locally --- pkg/cmd/server/start.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/cmd/server/start.go b/pkg/cmd/server/start.go index 6117de9e..04b1bda2 100644 --- a/pkg/cmd/server/start.go +++ b/pkg/cmd/server/start.go @@ -34,7 +34,6 @@ import ( utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/endpoints/openapi" - //"k8s.io/apiserver/pkg/features" genericapiserver "k8s.io/apiserver/pkg/server" genericoptions "k8s.io/apiserver/pkg/server/options" utilfeature "k8s.io/apiserver/pkg/util/feature" @@ -42,7 +41,11 @@ import ( netutils "k8s.io/utils/net" ) -const defaultEtcdPathPrefix = "/registry/porch.kpt.dev" +const ( + defaultEtcdPathPrefix = "/registry/porch.kpt.dev" + OpenAPITitle = "Porch" + OpenAPIVersion = "0.1" +) // PorchServerOptions contains state for master/api server type PorchServerOptions struct { @@ -125,7 +128,6 @@ func (o *PorchServerOptions) Complete() error { klog.Fatalf("--standalone-debug-mode must not be used when running in k8s") } else { o.RecommendedOptions.Authorization = nil - o.RecommendedOptions.CoreAPI = nil o.RecommendedOptions.Admission = nil o.RecommendedOptions.Authentication.RemoteKubeConfigFileOptional = true } @@ -155,10 +157,6 @@ func (o *PorchServerOptions) Config() (*apiserver.Config, error) { return nil, fmt.Errorf("error creating self-signed certificates: %w", err) } - // if o.RecommendedOptions.Etcd != nil { - // o.RecommendedOptions.Etcd.StorageConfig.Paging = utilfeature.DefaultFeatureGate.Enabled(features.APIListChunking) - // } - o.RecommendedOptions.ExtraAdmissionInitializers = func(c *genericapiserver.RecommendedConfig) ([]admission.PluginInitializer, error) { client, err := clientset.NewForConfig(c.LoopbackClientConfig) if err != nil { @@ -170,12 +168,14 @@ func (o *PorchServerOptions) Config() (*apiserver.Config, error) { } serverConfig := genericapiserver.NewRecommendedConfig(apiserver.Codecs) - + serverConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(sampleopenapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(apiserver.Scheme)) - serverConfig.OpenAPIConfig.Info.Title = "Porch" - serverConfig.OpenAPIConfig.Info.Version = "0.1" + serverConfig.OpenAPIConfig.Info.Title = OpenAPITitle + serverConfig.OpenAPIConfig.Info.Version = OpenAPIVersion serverConfig.OpenAPIV3Config = genericapiserver.DefaultOpenAPIV3Config(sampleopenapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(apiserver.Scheme)) + serverConfig.OpenAPIConfig.Info.Title = OpenAPITitle + serverConfig.OpenAPIConfig.Info.Version = OpenAPIVersion if err := o.RecommendedOptions.ApplyTo(serverConfig); err != nil { return nil, err