-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35483 from ymqytw/use_evict_for_drain
Automatic merge from submit-queue Fix kubectl drain for statefulset Support deleting pets for `kubectl drain`. Use evict to delete pods. Fixes: #33727 ```release-note Adds support for StatefulSets in kubectl drain. Switches to use the eviction sub-resource instead of deletion in kubectl drain, if server supports. ``` @foxish @caesarxuchao
- Loading branch information
Showing
18 changed files
with
550 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
pkg/client/clientset_generated/internalclientset/typed/policy/internalversion/eviction.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 internalversion | ||
|
||
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 *PolicyClient, namespace string) *evictions { | ||
return &evictions{ | ||
client: c.RESTClient(), | ||
ns: namespace, | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
.../clientset_generated/internalclientset/typed/policy/internalversion/eviction_expansion.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 internalversion | ||
|
||
import ( | ||
policy "k8s.io/kubernetes/pkg/apis/policy" | ||
) | ||
|
||
// 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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
.../clientset_generated/internalclientset/typed/policy/internalversion/fake/fake_eviction.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 *FakePolicy | ||
ns string | ||
} |
33 changes: 33 additions & 0 deletions
33
..._generated/internalclientset/typed/policy/internalversion/fake/fake_eviction_expansion.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
unversioned "k8s.io/kubernetes/pkg/api/unversioned" | ||
policy "k8s.io/kubernetes/pkg/apis/policy" | ||
core "k8s.io/kubernetes/pkg/client/testing/core" | ||
) | ||
|
||
func (c *FakeEvictions) Evict(eviction *policy.Eviction) error { | ||
action := core.GetActionImpl{} | ||
action.Verb = "post" | ||
action.Namespace = c.ns | ||
action.Resource = unversioned.GroupVersionResource{Group: "", Version: "", Resource: "pods"} | ||
action.Subresource = "eviction" | ||
_, err := c.Fake.Invokes(action, eviction) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
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/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 internalversion | ||
|
||
import ( | ||
"k8s.io/kubernetes/pkg/api/errors" | ||
policy "k8s.io/kubernetes/pkg/apis/policy" | ||
"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 []*policy.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 []*policy.Eviction, err error) { | ||
err = cache.ListAll(s.indexer, selector, func(m interface{}) { | ||
ret = append(ret, m.(*policy.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 []*policy.Eviction, err error) | ||
// Get retrieves the Eviction from the indexer for a given namespace and name. | ||
Get(name string) (*policy.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 []*policy.Eviction, err error) { | ||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { | ||
ret = append(ret, m.(*policy.Eviction)) | ||
}) | ||
return ret, err | ||
} | ||
|
||
// Get retrieves the Eviction from the indexer for a given namespace and name. | ||
func (s evictionNamespaceLister) Get(name string) (*policy.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.(*policy.Eviction), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.