@@ -44,11 +44,11 @@ import (
44
44
"k8s.io/kubernetes/pkg/apis/apps"
45
45
"k8s.io/kubernetes/pkg/apis/autoscaling"
46
46
"k8s.io/kubernetes/pkg/apis/batch"
47
+ batchv2alpha1 "k8s.io/kubernetes/pkg/apis/batch/v2alpha1"
47
48
"k8s.io/kubernetes/pkg/apis/extensions"
48
49
kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
49
50
kinternalclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
50
51
"k8s.io/kubernetes/pkg/cloudprovider"
51
- "k8s.io/kubernetes/pkg/kubeapiserver"
52
52
"k8s.io/kubernetes/pkg/master"
53
53
"k8s.io/kubernetes/pkg/registry/cachesize"
54
54
"k8s.io/kubernetes/pkg/registry/core/endpoint"
@@ -160,40 +160,31 @@ func BuildKubeAPIserverOptions(masterConfig configapi.MasterConfig) (*kapiserver
160
160
func BuildStorageFactory (masterConfig configapi.MasterConfig , server * kapiserveroptions.ServerRunOptions , enforcedStorageVersions []schema.GroupVersionResource ) (* apiserverstorage.DefaultStorageFactory , error ) {
161
161
resourceEncodingConfig := apiserverstorage .NewDefaultResourceEncodingConfig (kapi .Registry )
162
162
163
- // TODO(rebase): the following were without effect at least since 3.5. Remove them?
164
- // resourceEncodingConfig.SetVersionEncoding(kapi.GroupName, schema.GroupVersion{Group: kapi.GroupName, Version: masterConfig.EtcdStorageConfig.KubernetesStorageVersion}, kapi.SchemeGroupVersion)
165
- // resourceEncodingConfig.SetVersionEncoding(extensions.GroupName, schema.GroupVersion{Group: extensions.GroupName, Version: "v1beta1"}, extensions.SchemeGroupVersion)
166
- // resourceEncodingConfig.SetVersionEncoding(batch.GroupName, schema.GroupVersion{Group: batch.GroupName, Version: "v1"}, batch.SchemeGroupVersion)
167
- // resourceEncodingConfig.SetVersionEncoding(autoscaling.GroupName, schema.GroupVersion{Group: autoscaling.GroupName, Version: "v1"}, autoscaling.SchemeGroupVersion)
168
-
169
163
storageGroupsToEncodingVersion , err := server .StorageSerialization .StorageGroupsToEncodingVersion ()
170
164
if err != nil {
171
165
return nil , err
172
166
}
167
+ for group , storageEncodingVersion := range storageGroupsToEncodingVersion {
168
+ resourceEncodingConfig .SetVersionEncoding (group , storageEncodingVersion , schema.GroupVersion {Group : group , Version : runtime .APIVersionInternal })
169
+ }
170
+ resourceEncodingConfig .SetVersionEncoding (batch .GroupName , batchv2alpha1 .SchemeGroupVersion , batch .SchemeGroupVersion )
171
+
172
+ // use legacy group name "" for all resources that existed when apigroups were introduced
173
+ for _ , gvr := range enforcedStorageVersions {
174
+ resourceEncodingConfig .SetResourceEncoding (gvr .GroupResource (), schema.GroupVersion {Version : gvr .Version }, schema.GroupVersion {Version : runtime .APIVersionInternal })
175
+ }
173
176
174
- storageFactory , err := kubeapiserver . NewStorageFactory (
177
+ storageFactory := apiserverstorage . NewDefaultStorageFactory (
175
178
server .Etcd .StorageConfig ,
176
179
server .Etcd .DefaultStorageMediaType ,
177
180
kapi .Codecs ,
178
181
resourceEncodingConfig ,
179
- storageGroupsToEncodingVersion ,
180
- // FIXME: this GroupVersionResource override should be configurable
181
- []schema.GroupVersionResource {batch .Resource ("cronjobs" ).WithVersion ("v2alpha1" )},
182
182
master .DefaultAPIResourceConfigSource (),
183
- server .APIEnablement .RuntimeConfig ,
184
183
)
185
184
if err != nil {
186
185
return nil , err
187
186
}
188
187
189
- // TODO: the following works, but better make single resource overrides possible in BuildDefaultStorageFactory
190
- // instead of being late to the party and patching here:
191
-
192
- // use legacy group name "" for all resources that existed when apigroups were introduced
193
- for _ , gvr := range enforcedStorageVersions {
194
- resourceEncodingConfig .SetResourceEncoding (gvr .GroupResource (), schema.GroupVersion {Version : gvr .Version }, schema.GroupVersion {Version : runtime .APIVersionInternal })
195
- }
196
-
197
188
// the order here is important, it defines which version will be used for storage
198
189
storageFactory .AddCohabitatingResources (batch .Resource ("jobs" ), extensions .Resource ("jobs" ))
199
190
storageFactory .AddCohabitatingResources (extensions .Resource ("horizontalpodautoscalers" ), autoscaling .Resource ("horizontalpodautoscalers" ))
0 commit comments