Skip to content

Commit

Permalink
Fix running api server locally
Browse files Browse the repository at this point in the history
  • Loading branch information
efiacor committed Apr 18, 2024
1 parent 5f52bc0 commit feed199
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/cmd/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ 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"
"k8s.io/klog/v2"
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 {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit feed199

Please sign in to comment.