Commit 613bbbb1 authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #26667 from mml/skip-local-data

Automatic merge from submit-queue Stop 'kubectl drain' deleting pods with local storage. Kubectl drain will not continue if there are pods with local storage unless forced with --delete-local-data. Fixes #23972
parents 54b352ae d09af4a1
......@@ -33,6 +33,10 @@ will make the node schedulable again.
.SH OPTIONS
.PP
\fB\-\-delete\-local\-data\fP=false
Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained).
.PP
\fB\-\-force\fP=false
Continue even if there are pods not managed by a ReplicationController, ReplicaSet, Job, or DaemonSet.
......
......@@ -73,6 +73,7 @@ $ kubectl drain foo --grace-period=900
### Options
```
--delete-local-data[=false]: Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained).
--force[=false]: Continue even if there are pods not managed by a ReplicationController, ReplicaSet, Job, or DaemonSet.
--grace-period=-1: Period of time in seconds given to each pod to terminate gracefully. If negative, the default value specified in the pod will be used.
--ignore-daemonsets[=false]: Ignore DaemonSet-managed pods.
......@@ -110,7 +111,7 @@ $ kubectl drain foo --grace-period=900
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
###### Auto generated by spf13/cobra on 15-Apr-2016
###### Auto generated by spf13/cobra on 6-Jun-2016
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_drain.md?pixel)]()
......
......@@ -16,6 +16,10 @@ description: |
When you are ready to put the node back into service, use kubectl uncordon, which
will make the node schedulable again.
options:
- name: delete-local-data
default_value: "false"
usage: |
Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained).
- name: force
default_value: "false"
usage: |
......
......@@ -89,6 +89,7 @@ default-container-mem-limit
delay-shutdown
delete-collection-workers
delete-instances
delete-local-data
delete-namespace
deleting-pods-burst
deleting-pods-qps
......
......@@ -325,6 +325,24 @@ func TestDrain(t *testing.T) {
},
}
emptydir_pod := api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "bar",
Namespace: "default",
CreationTimestamp: unversioned.Time{Time: time.Now()},
Labels: labels,
},
Spec: api.PodSpec{
NodeName: "node",
Volumes: []api.Volume{
{
Name: "scratch",
VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{Medium: ""}},
},
},
},
}
tests := []struct {
description string
node *api.Node
......@@ -407,6 +425,24 @@ func TestDrain(t *testing.T) {
expectDelete: true,
},
{
description: "pod with EmptyDir",
node: node,
expected: cordoned_node,
pods: []api.Pod{emptydir_pod},
args: []string{"node", "--force"},
expectFatal: true,
expectDelete: false,
},
{
description: "pod with EmptyDir and --delete-local-data",
node: node,
expected: cordoned_node,
pods: []api.Pod{emptydir_pod},
args: []string{"node", "--force", "--delete-local-data=true"},
expectFatal: false,
expectDelete: true,
},
{
description: "empty node",
node: node,
expected: cordoned_node,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment