mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
copy eviction from internal clientset to release_1_5 clientset
This commit is contained in:
parent
aa08702d23
commit
83a0373926
@ -89,6 +89,9 @@ type PodDisruptionBudgetList struct {
|
||||
Items []PodDisruptionBudget `json:"items" protobuf:"bytes,2,rep,name=items"`
|
||||
}
|
||||
|
||||
// +genclient=true
|
||||
// +noMethods=true
|
||||
|
||||
// Eviction evicts a pod from its node subject to certain policies and safety constraints.
|
||||
// This is a subresource of Pod. A request to cause such an eviction is
|
||||
// created by POSTing to .../pods/<pod name>/evictions.
|
||||
|
@ -14,6 +14,8 @@ go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"eviction.go",
|
||||
"eviction_expansion.go",
|
||||
"generated_expansion.go",
|
||||
"poddisruptionbudget.go",
|
||||
"policy_client.go",
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
restclient "k8s.io/kubernetes/pkg/client/restclient"
|
||||
)
|
||||
|
||||
// EvictionsGetter has a method to return a EvictionInterface.
|
||||
// A group's client should implement this interface.
|
||||
type EvictionsGetter interface {
|
||||
Evictions(namespace string) EvictionInterface
|
||||
}
|
||||
|
||||
// EvictionInterface has methods to work with Eviction resources.
|
||||
type EvictionInterface interface {
|
||||
EvictionExpansion
|
||||
}
|
||||
|
||||
// evictions implements EvictionInterface
|
||||
type evictions struct {
|
||||
client restclient.Interface
|
||||
ns string
|
||||
}
|
||||
|
||||
// newEvictions returns a Evictions
|
||||
func newEvictions(c *PolicyV1beta1Client, namespace string) *evictions {
|
||||
return &evictions{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
policy "k8s.io/kubernetes/pkg/apis/policy/v1beta1"
|
||||
)
|
||||
|
||||
// The EvictionExpansion interface allows manually adding extra methods to the ScaleInterface.
|
||||
type EvictionExpansion interface {
|
||||
Evict(eviction *policy.Eviction) error
|
||||
}
|
||||
|
||||
func (c *evictions) Evict(eviction *policy.Eviction) error {
|
||||
return c.client.Post().
|
||||
AbsPath("/api/v1").
|
||||
Namespace(eviction.Namespace).
|
||||
Resource("pods").
|
||||
Name(eviction.Name).
|
||||
SubResource("eviction").
|
||||
Body(eviction).
|
||||
Do().
|
||||
Error()
|
||||
}
|
@ -14,6 +14,8 @@ go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"fake_eviction.go",
|
||||
"fake_eviction_expansion.go",
|
||||
"fake_poddisruptionbudget.go",
|
||||
"fake_policy_client.go",
|
||||
],
|
||||
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
// FakeEvictions implements EvictionInterface
|
||||
type FakeEvictions struct {
|
||||
Fake *FakePolicyV1beta1
|
||||
ns string
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
policy "k8s.io/kubernetes/pkg/apis/policy/v1beta1"
|
||||
core "k8s.io/kubernetes/pkg/client/testing/core"
|
||||
"k8s.io/kubernetes/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
func (c *FakeEvictions) Evict(eviction *policy.Eviction) error {
|
||||
action := core.GetActionImpl{}
|
||||
action.Verb = "post"
|
||||
action.Namespace = c.ns
|
||||
action.Resource = schema.GroupVersionResource{Group: "", Version: "", Resource: "pods"}
|
||||
action.Subresource = "eviction"
|
||||
_, err := c.Fake.Invokes(action, eviction)
|
||||
return err
|
||||
}
|
@ -26,6 +26,10 @@ type FakePolicyV1beta1 struct {
|
||||
*core.Fake
|
||||
}
|
||||
|
||||
func (c *FakePolicyV1beta1) Evictions(namespace string) v1beta1.EvictionInterface {
|
||||
return &FakeEvictions{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakePolicyV1beta1) PodDisruptionBudgets(namespace string) v1beta1.PodDisruptionBudgetInterface {
|
||||
return &FakePodDisruptionBudgets{c, namespace}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
|
||||
type PolicyV1beta1Interface interface {
|
||||
RESTClient() restclient.Interface
|
||||
EvictionsGetter
|
||||
PodDisruptionBudgetsGetter
|
||||
}
|
||||
|
||||
@ -35,6 +36,10 @@ type PolicyV1beta1Client struct {
|
||||
restClient restclient.Interface
|
||||
}
|
||||
|
||||
func (c *PolicyV1beta1Client) Evictions(namespace string) EvictionInterface {
|
||||
return newEvictions(c, namespace)
|
||||
}
|
||||
|
||||
func (c *PolicyV1beta1Client) PodDisruptionBudgets(namespace string) PodDisruptionBudgetInterface {
|
||||
return newPodDisruptionBudgets(c, namespace)
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ load(
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"eviction.go",
|
||||
"expansion_generated.go",
|
||||
"poddisruptionbudget.go",
|
||||
],
|
||||
|
95
pkg/client/listers/policy/v1beta1/eviction.go
Normal file
95
pkg/client/listers/policy/v1beta1/eviction.go
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// This file was automatically generated by lister-gen with arguments: --input-dirs=[k8s.io/kubernetes/pkg/api,k8s.io/kubernetes/pkg/api/v1,k8s.io/kubernetes/pkg/apis/abac,k8s.io/kubernetes/pkg/apis/abac/v0,k8s.io/kubernetes/pkg/apis/abac/v1beta1,k8s.io/kubernetes/pkg/apis/apps,k8s.io/kubernetes/pkg/apis/apps/v1beta1,k8s.io/kubernetes/pkg/apis/authentication,k8s.io/kubernetes/pkg/apis/authentication/v1beta1,k8s.io/kubernetes/pkg/apis/authorization,k8s.io/kubernetes/pkg/apis/authorization/v1beta1,k8s.io/kubernetes/pkg/apis/autoscaling,k8s.io/kubernetes/pkg/apis/autoscaling/v1,k8s.io/kubernetes/pkg/apis/batch,k8s.io/kubernetes/pkg/apis/batch/v1,k8s.io/kubernetes/pkg/apis/batch/v2alpha1,k8s.io/kubernetes/pkg/apis/certificates,k8s.io/kubernetes/pkg/apis/certificates/v1alpha1,k8s.io/kubernetes/pkg/apis/componentconfig,k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1,k8s.io/kubernetes/pkg/apis/extensions,k8s.io/kubernetes/pkg/apis/extensions/v1beta1,k8s.io/kubernetes/pkg/apis/imagepolicy,k8s.io/kubernetes/pkg/apis/imagepolicy/v1alpha1,k8s.io/kubernetes/pkg/apis/meta/v1,k8s.io/kubernetes/pkg/apis/policy,k8s.io/kubernetes/pkg/apis/policy/v1alpha1,k8s.io/kubernetes/pkg/apis/policy/v1beta1,k8s.io/kubernetes/pkg/apis/rbac,k8s.io/kubernetes/pkg/apis/rbac/v1alpha1,k8s.io/kubernetes/pkg/apis/storage,k8s.io/kubernetes/pkg/apis/storage/v1beta1]
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api/errors"
|
||||
policy "k8s.io/kubernetes/pkg/apis/policy"
|
||||
v1beta1 "k8s.io/kubernetes/pkg/apis/policy/v1beta1"
|
||||
"k8s.io/kubernetes/pkg/client/cache"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
)
|
||||
|
||||
// EvictionLister helps list Evictions.
|
||||
type EvictionLister interface {
|
||||
// List lists all Evictions in the indexer.
|
||||
List(selector labels.Selector) (ret []*v1beta1.Eviction, err error)
|
||||
// Evictions returns an object that can list and get Evictions.
|
||||
Evictions(namespace string) EvictionNamespaceLister
|
||||
EvictionListerExpansion
|
||||
}
|
||||
|
||||
// evictionLister implements the EvictionLister interface.
|
||||
type evictionLister struct {
|
||||
indexer cache.Indexer
|
||||
}
|
||||
|
||||
// NewEvictionLister returns a new EvictionLister.
|
||||
func NewEvictionLister(indexer cache.Indexer) EvictionLister {
|
||||
return &evictionLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all Evictions in the indexer.
|
||||
func (s *evictionLister) List(selector labels.Selector) (ret []*v1beta1.Eviction, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1beta1.Eviction))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Evictions returns an object that can list and get Evictions.
|
||||
func (s *evictionLister) Evictions(namespace string) EvictionNamespaceLister {
|
||||
return evictionNamespaceLister{indexer: s.indexer, namespace: namespace}
|
||||
}
|
||||
|
||||
// EvictionNamespaceLister helps list and get Evictions.
|
||||
type EvictionNamespaceLister interface {
|
||||
// List lists all Evictions in the indexer for a given namespace.
|
||||
List(selector labels.Selector) (ret []*v1beta1.Eviction, err error)
|
||||
// Get retrieves the Eviction from the indexer for a given namespace and name.
|
||||
Get(name string) (*v1beta1.Eviction, error)
|
||||
EvictionNamespaceListerExpansion
|
||||
}
|
||||
|
||||
// evictionNamespaceLister implements the EvictionNamespaceLister
|
||||
// interface.
|
||||
type evictionNamespaceLister struct {
|
||||
indexer cache.Indexer
|
||||
namespace string
|
||||
}
|
||||
|
||||
// List lists all Evictions in the indexer for a given namespace.
|
||||
func (s evictionNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Eviction, err error) {
|
||||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1beta1.Eviction))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the Eviction from the indexer for a given namespace and name.
|
||||
func (s evictionNamespaceLister) Get(name string) (*v1beta1.Eviction, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(policy.Resource("eviction"), name)
|
||||
}
|
||||
return obj.(*v1beta1.Eviction), nil
|
||||
}
|
@ -18,6 +18,14 @@ limitations under the License.
|
||||
|
||||
package v1beta1
|
||||
|
||||
// EvictionListerExpansion allows custom methods to be added to
|
||||
// EvictionLister.
|
||||
type EvictionListerExpansion interface{}
|
||||
|
||||
// EvictionNamespaceListerExpansion allows custom methods to be added to
|
||||
// EvictionNamespaeLister.
|
||||
type EvictionNamespaceListerExpansion interface{}
|
||||
|
||||
// PodDisruptionBudgetListerExpansion allows custom methods to be added to
|
||||
// PodDisruptionBudgetLister.
|
||||
type PodDisruptionBudgetListerExpansion interface{}
|
||||
|
Loading…
Reference in New Issue
Block a user