move storage serialization type to etcd options

pull/6/head
deads2k 2017-02-07 13:34:02 -05:00
parent cc75d51897
commit b410b387ee
6 changed files with 14 additions and 13 deletions

View File

@ -94,7 +94,7 @@ func NewServerRunOptions() *ServerRunOptions {
ServiceNodePortRange: DefaultServiceNodePortRange,
}
// Overwrite the default for storage data format.
s.GenericServerRunOptions.DefaultStorageMediaType = "application/vnd.kubernetes.protobuf"
s.Etcd.DefaultStorageMediaType = "application/vnd.kubernetes.protobuf"
return &s
}

View File

@ -205,7 +205,7 @@ func Run(s *options.ServerRunOptions) error {
return fmt.Errorf("error generating storage version map: %s", err)
}
storageFactory, err := kubeapiserver.BuildDefaultStorageFactory(
s.Etcd.StorageConfig, s.GenericServerRunOptions.DefaultStorageMediaType, api.Codecs,
s.Etcd.StorageConfig, s.Etcd.DefaultStorageMediaType, api.Codecs,
genericapiserver.NewDefaultResourceEncodingConfig(api.Registry), storageGroupsToEncodingVersion,
// FIXME: this GroupVersionResource override should be configurable
[]schema.GroupVersionResource{batch.Resource("cronjobs").WithVersion("v2alpha1")},

View File

@ -63,7 +63,7 @@ func NewServerRunOptions() *ServerRunOptions {
EventTTL: 1 * time.Hour,
}
// Overwrite the default for storage data format.
s.GenericServerRunOptions.DefaultStorageMediaType = "application/vnd.kubernetes.protobuf"
s.Etcd.DefaultStorageMediaType = "application/vnd.kubernetes.protobuf"
return &s
}

View File

@ -122,7 +122,7 @@ func Run(s *options.ServerRunOptions) error {
return fmt.Errorf("error generating storage version map: %s", err)
}
storageFactory, err := kubeapiserver.BuildDefaultStorageFactory(
s.Etcd.StorageConfig, s.GenericServerRunOptions.DefaultStorageMediaType, api.Codecs,
s.Etcd.StorageConfig, s.Etcd.DefaultStorageMediaType, api.Codecs,
genericapiserver.NewDefaultResourceEncodingConfig(api.Registry), storageGroupsToEncodingVersion,
[]schema.GroupVersionResource{}, resourceConfig, s.GenericServerRunOptions.RuntimeConfig)
if err != nil {

View File

@ -33,6 +33,10 @@ type EtcdOptions struct {
StorageConfig storagebackend.Config
EtcdServersOverrides []string
// To enable protobuf as storage format, it is enough
// to set it to "application/vnd.kubernetes.protobuf".
DefaultStorageMediaType string
}
func NewEtcdOptions(scheme *runtime.Scheme) *EtcdOptions {
@ -44,6 +48,7 @@ func NewEtcdOptions(scheme *runtime.Scheme) *EtcdOptions {
DeserializationCacheSize: 0,
Copier: scheme,
},
DefaultStorageMediaType: "application/json",
}
}
@ -62,6 +67,10 @@ func (s *EtcdOptions) AddFlags(fs *pflag.FlagSet) {
"Per-resource etcd servers overrides, comma separated. The individual override "+
"format: group/resource#servers, where servers are http://ip:port, semicolon separated.")
fs.StringVar(&s.DefaultStorageMediaType, "storage-media-type", s.DefaultStorageMediaType, ""+
"The media type to use to store objects in storage. Defaults to application/json. "+
"Some resources may only support a specific media type and will ignore this setting.")
fs.StringVar(&s.StorageConfig.Type, "storage-backend", s.StorageConfig.Type,
"The storage backend for persistence. Options: 'etcd3' (default), 'etcd2'.")

View File

@ -39,10 +39,7 @@ type ServerRunOptions struct {
AdmissionControlConfigFile string
AdvertiseAddress net.IP
CorsAllowedOriginList []string
// To enable protobuf as storage format, it is enough
// to set it to "application/vnd.kubernetes.protobuf".
DefaultStorageMediaType string
CorsAllowedOriginList []string
DeleteCollectionWorkers int
EnableWatchCache bool
ExternalHost string
@ -59,7 +56,6 @@ func NewServerRunOptions() *ServerRunOptions {
return &ServerRunOptions{
AdmissionControl: "AlwaysAdmit",
DefaultStorageMediaType: "application/json",
DeleteCollectionWorkers: 1,
EnableWatchCache: true,
MaxRequestsInFlight: defaults.MaxRequestsInFlight,
@ -131,10 +127,6 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) {
"List of allowed origins for CORS, comma separated. An allowed origin can be a regular "+
"expression to support subdomain matching. If this list is empty CORS will not be enabled.")
fs.StringVar(&s.DefaultStorageMediaType, "storage-media-type", s.DefaultStorageMediaType, ""+
"The media type to use to store objects in storage. Defaults to application/json. "+
"Some resources may only support a specific media type and will ignore this setting.")
fs.IntVar(&s.DeleteCollectionWorkers, "delete-collection-workers", s.DeleteCollectionWorkers,
"Number of workers spawned for DeleteCollection call. These are used to speed up namespace cleanup.")