@@ -23,6 +23,7 @@ import (
23
23
"net/url"
24
24
25
25
"k8s.io/apimachinery/pkg/api/errors"
26
+ "k8s.io/apimachinery/pkg/api/meta"
26
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27
28
"k8s.io/apimachinery/pkg/runtime"
28
29
"k8s.io/apiserver/pkg/registry/generic"
@@ -49,6 +50,7 @@ import (
49
50
type PodStorage struct {
50
51
Pod * REST
51
52
Binding * BindingREST
53
+ LegacyBinding * LegacyBindingREST
52
54
Eviction * EvictionREST
53
55
Status * StatusREST
54
56
EphemeralContainers * EphemeralContainersREST
@@ -95,9 +97,11 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGet
95
97
ephemeralContainersStore := * store
96
98
ephemeralContainersStore .UpdateStrategy = pod .EphemeralContainersStrategy
97
99
100
+ bindingREST := & BindingREST {store : store }
98
101
return PodStorage {
99
102
Pod : & REST {store , proxyTransport },
100
103
Binding : & BindingREST {store : store },
104
+ LegacyBinding : & LegacyBindingREST {bindingREST },
101
105
Eviction : newEvictionStorage (store , podDisruptionBudgetClient ),
102
106
Status : & StatusREST {store : & statusStore },
103
107
EphemeralContainers : & EphemeralContainersREST {store : & ephemeralContainersStore },
@@ -225,6 +229,32 @@ func (r *BindingREST) assignPod(ctx context.Context, podID string, machine strin
225
229
return
226
230
}
227
231
232
+ var _ = rest .Creater (& LegacyBindingREST {})
233
+
234
+ // LegacyBindingREST implements the REST endpoint for binding pods to nodes when etcd is in use.
235
+ type LegacyBindingREST struct {
236
+ bindingRest * BindingREST
237
+ }
238
+
239
+ // NamespaceScoped fulfill rest.Scoper
240
+ func (r * LegacyBindingREST ) NamespaceScoped () bool {
241
+ return r .bindingRest .NamespaceScoped ()
242
+ }
243
+
244
+ // New creates a new binding resource
245
+ func (r * LegacyBindingREST ) New () runtime.Object {
246
+ return r .bindingRest .New ()
247
+ }
248
+
249
+ // Create ensures a pod is bound to a specific host.
250
+ func (r * LegacyBindingREST ) Create (ctx context.Context , obj runtime.Object , createValidation rest.ValidateObjectFunc , options * metav1.CreateOptions ) (out runtime.Object , err error ) {
251
+ metadata , err := meta .Accessor (obj )
252
+ if err != nil {
253
+ return nil , errors .NewBadRequest (fmt .Sprintf ("not a Binding object: %T" , obj ))
254
+ }
255
+ return r .bindingRest .Create (ctx , metadata .GetName (), obj , createValidation , options )
256
+ }
257
+
228
258
// StatusREST implements the REST endpoint for changing the status of a pod.
229
259
type StatusREST struct {
230
260
store * genericregistry.Store
0 commit comments