mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
add legacyBinding for non-Named Binding Creater
This commit is contained in:
parent
b28f62c8ad
commit
d4d696d0f2
@ -64,6 +64,7 @@ go_library(
|
||||
"//pkg/registry/core/pod/rest:go_default_library",
|
||||
"//staging/src/k8s.io/api/policy/v1beta1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
"net/url"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apiserver/pkg/registry/generic"
|
||||
@ -49,6 +50,7 @@ import (
|
||||
type PodStorage struct {
|
||||
Pod *REST
|
||||
Binding *BindingREST
|
||||
LegacyBinding *LegacyBindingREST
|
||||
Eviction *EvictionREST
|
||||
Status *StatusREST
|
||||
EphemeralContainers *EphemeralContainersREST
|
||||
@ -95,9 +97,11 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGet
|
||||
ephemeralContainersStore := *store
|
||||
ephemeralContainersStore.UpdateStrategy = pod.EphemeralContainersStrategy
|
||||
|
||||
bindingREST := &BindingREST{store: store}
|
||||
return PodStorage{
|
||||
Pod: &REST{store, proxyTransport},
|
||||
Binding: &BindingREST{store: store},
|
||||
LegacyBinding: &LegacyBindingREST{bindingREST},
|
||||
Eviction: newEvictionStorage(store, podDisruptionBudgetClient),
|
||||
Status: &StatusREST{store: &statusStore},
|
||||
EphemeralContainers: &EphemeralContainersREST{store: &ephemeralContainersStore},
|
||||
@ -225,6 +229,32 @@ func (r *BindingREST) assignPod(ctx context.Context, podID string, machine strin
|
||||
return
|
||||
}
|
||||
|
||||
var _ = rest.Creater(&LegacyBindingREST{})
|
||||
|
||||
// LegacyBindingREST implements the REST endpoint for binding pods to nodes when etcd is in use.
|
||||
type LegacyBindingREST struct {
|
||||
bindingRest *BindingREST
|
||||
}
|
||||
|
||||
// NamespaceScoped fulfill rest.Scoper
|
||||
func (r *LegacyBindingREST) NamespaceScoped() bool {
|
||||
return r.bindingRest.NamespaceScoped()
|
||||
}
|
||||
|
||||
// New creates a new binding resource
|
||||
func (r *LegacyBindingREST) New() runtime.Object {
|
||||
return r.bindingRest.New()
|
||||
}
|
||||
|
||||
// Create ensures a pod is bound to a specific host.
|
||||
func (r *LegacyBindingREST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (out runtime.Object, err error) {
|
||||
metadata, err := meta.Accessor(obj)
|
||||
if err != nil {
|
||||
return nil, errors.NewBadRequest(fmt.Sprintf("not a Binding object: %T", obj))
|
||||
}
|
||||
return r.bindingRest.Create(ctx, metadata.GetName(), obj, createValidation, options)
|
||||
}
|
||||
|
||||
// StatusREST implements the REST endpoint for changing the status of a pod.
|
||||
type StatusREST struct {
|
||||
store *genericregistry.Store
|
||||
|
@ -248,7 +248,7 @@ func (c LegacyRESTStorageProvider) NewLegacyRESTStorage(restOptionsGetter generi
|
||||
"pods/portforward": podStorage.PortForward,
|
||||
"pods/proxy": podStorage.Proxy,
|
||||
"pods/binding": podStorage.Binding,
|
||||
"bindings": podStorage.Binding,
|
||||
"bindings": podStorage.LegacyBinding,
|
||||
|
||||
"podTemplates": podTemplateStorage,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user