mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +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",
|
"//pkg/registry/core/pod/rest:go_default_library",
|
||||||
"//staging/src/k8s.io/api/policy/v1beta1: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/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/apis/meta/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
@ -49,6 +50,7 @@ import (
|
|||||||
type PodStorage struct {
|
type PodStorage struct {
|
||||||
Pod *REST
|
Pod *REST
|
||||||
Binding *BindingREST
|
Binding *BindingREST
|
||||||
|
LegacyBinding *LegacyBindingREST
|
||||||
Eviction *EvictionREST
|
Eviction *EvictionREST
|
||||||
Status *StatusREST
|
Status *StatusREST
|
||||||
EphemeralContainers *EphemeralContainersREST
|
EphemeralContainers *EphemeralContainersREST
|
||||||
@ -95,9 +97,11 @@ func NewStorage(optsGetter generic.RESTOptionsGetter, k client.ConnectionInfoGet
|
|||||||
ephemeralContainersStore := *store
|
ephemeralContainersStore := *store
|
||||||
ephemeralContainersStore.UpdateStrategy = pod.EphemeralContainersStrategy
|
ephemeralContainersStore.UpdateStrategy = pod.EphemeralContainersStrategy
|
||||||
|
|
||||||
|
bindingREST := &BindingREST{store: store}
|
||||||
return PodStorage{
|
return PodStorage{
|
||||||
Pod: &REST{store, proxyTransport},
|
Pod: &REST{store, proxyTransport},
|
||||||
Binding: &BindingREST{store: store},
|
Binding: &BindingREST{store: store},
|
||||||
|
LegacyBinding: &LegacyBindingREST{bindingREST},
|
||||||
Eviction: newEvictionStorage(store, podDisruptionBudgetClient),
|
Eviction: newEvictionStorage(store, podDisruptionBudgetClient),
|
||||||
Status: &StatusREST{store: &statusStore},
|
Status: &StatusREST{store: &statusStore},
|
||||||
EphemeralContainers: &EphemeralContainersREST{store: &ephemeralContainersStore},
|
EphemeralContainers: &EphemeralContainersREST{store: &ephemeralContainersStore},
|
||||||
@ -225,6 +229,32 @@ func (r *BindingREST) assignPod(ctx context.Context, podID string, machine strin
|
|||||||
return
|
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.
|
// StatusREST implements the REST endpoint for changing the status of a pod.
|
||||||
type StatusREST struct {
|
type StatusREST struct {
|
||||||
store *genericregistry.Store
|
store *genericregistry.Store
|
||||||
|
@ -248,7 +248,7 @@ func (c LegacyRESTStorageProvider) NewLegacyRESTStorage(restOptionsGetter generi
|
|||||||
"pods/portforward": podStorage.PortForward,
|
"pods/portforward": podStorage.PortForward,
|
||||||
"pods/proxy": podStorage.Proxy,
|
"pods/proxy": podStorage.Proxy,
|
||||||
"pods/binding": podStorage.Binding,
|
"pods/binding": podStorage.Binding,
|
||||||
"bindings": podStorage.Binding,
|
"bindings": podStorage.LegacyBinding,
|
||||||
|
|
||||||
"podTemplates": podTemplateStorage,
|
"podTemplates": podTemplateStorage,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user