Commit Graph

94 Commits (799a0bf41023b02e84a5551a5030b34ffe410919)

Author SHA1 Message Date
juanvallejo beb5ea641a
remove mapper dependency - PrintSuccess 2018-02-07 10:10:45 -05:00
Kubernetes Submit Queue 8e666feac2
Merge pull request #57322 from niuzhenguo/dry-run-flag-cleanup
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Use GetDryRunFlag to keep consistent

**What this PR does / why we need it**:
There's a cmd util GetDryRunFlag, but we still get 'dry-run' directly somewhere. This PR makes them consistent.

**Release note**:

```release-note
NONE
```
2018-01-29 20:04:54 -08:00
Kubernetes Submit Queue 048757b8a5
Merge pull request #53631 from dixudx/enforce_cobra_required_flags
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

update vendor spf13/cobra to enforce required flags

**What this PR does / why we need it**:

spf13/cobra#502 has enforced checking flags that marked as required, an error will be raised if unset.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*:fixes #54855
xref #48400
fixes kubernetes/kubectl#121 

**Special notes for your reviewer**:
/assign @liggitt @eparis 

**Release note**:

```release-note
kubectl now enforces required flags at a more fundamental level
```
2018-01-18 02:00:27 -08:00
Kubernetes Submit Queue 4bc93609ea
Merge pull request #56713 from juanvallejo/jvallejo/handle-ds-pod-drain-local-storage
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Allow kubectl drain to continue w ds-managed pods with local storage

**Release note**:
```release-note
NONE
```

Prevents oadm drain from failing if it encounters DaemonSet-managed pods
that have local storage, when the option to ignore DaemonSet-managed
pods has been specified.

Will add a test

cc @kubernetes/sig-cli-misc @deads2k @fabianofranz @dustymabe
2018-01-12 23:05:46 -08:00
juanvallejo d4e17cb7b4
Allow oadm drain to continue w ds-managed pods w local storage 2018-01-08 11:51:15 -05:00
Di Xu 1c715d51c4 some code change
fix wrong required flags

disable the addition of [flags] to the usage, use customized useline

fix function rename
2017-12-25 16:23:38 +08:00
Kubernetes Submit Queue 3ef674188d
Merge pull request #56864 from juanvallejo/jvallejo/add-selector-kubectl-drain
Automatic merge from submit-queue (batch tested with PRs 55751, 57337, 56406, 56864, 57347). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Add pod-selector kubectl drain

**Release note**:
```release-note
Added the ability to select pods in a chosen node to be drained, based on given pod label-selector
```

This patch adds the ability to select pods in a chosen node to be drained, based on given pod label-selector. Related downstream issue: https://github.com/openshift/origin/issues/17554

Further, it removes explicit, specific, pod-controller check. The `drain` command currently fails if a pod has a controller of a `kind` [not explicitly handled in the command itself](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/drain.go#L331). This causes `drain` to be unusable if a node contains pods managed by third-party, or "unknown" controllers.

Based on [this comment](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/drain.go#L353), the expectation was to fail if a pod's controller was not found for whatever reason. I believe that the `drain` command should not care about the existence of a pod controller. It should only care whether a pod has one, and act according to that controller kind. This solves a downstream bug: https://github.com/openshift/origin/issues/17563

cc @fabianofranz @deads2k @kubernetes/sig-cli-misc
2017-12-18 18:50:45 -08:00
juanvallejo 2f1108451f
Remove hard-coded pod-controller check
This allows pods with third-party, or unknown controllers to be drained
successfully.
2017-12-18 13:09:13 -05:00
juanvallejo 151398e961
add --pod-selector opt kubectl drain 2017-12-18 10:15:06 -05:00
Zhenguo Niu 86cc625a55 Use GetDryRunFlag to keep consistent 2017-12-18 19:28:55 +08:00
Kubernetes Submit Queue 6b66131034
Merge pull request #56413 from supereagle/policy-client-with-version
Automatic merge from submit-queue (batch tested with PRs 56413, 56322, 56490, 56460, 56487). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Use policy client with explicit version

**What this PR does / why we need it**:

**Which issue(s) this PR fixes** :
Fixes partially #55993

**Special notes for your reviewer**:
/cc @caesarxuchao @sttts

**Release note**:
```release-note
NONE
```
2017-12-15 16:43:47 -08:00
Kubernetes Submit Queue 778c60a6c0
Merge pull request #56263 from supereagle/batch-client-with-version
Automatic merge from submit-queue (batch tested with PRs 56217, 56268, 56263, 56328, 56200). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Use batch client with explicit version

**What this PR does / why we need it**:

**Which issue(s) this PR fixes** :
Fixes partially #55993

**Special notes for your reviewer**:
/cc @caesarxuchao @sttts

**Release note**:
```release-note
NONE
```
2017-12-14 23:37:46 -08:00
Kubernetes Submit Queue baf93c060e
Merge pull request #55995 from supereagle/extensions-client-with-version
Automatic merge from submit-queue (batch tested with PRs 55900, 55995, 55913, 55467, 55376). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Use extensions client with explicit version

**What this PR does / why we need it**:
Extensions client without explicit version has been deprecated, change them to the one with explicit version.

**Which issue(s) this PR fixes**:
Fixes partially #55993

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-12-14 00:45:15 -08:00
supereagle 79352bafaa use policy client with explicit version 2017-11-27 22:42:00 +08:00
supereagle 032416c75d use core client with explicit version
fix more usage of deprecated core client
2017-11-25 08:14:10 +08:00
supereagle 1fe05ac29a Use batch client with explicit version 2017-11-23 09:32:13 +08:00
supereagle 9c02d7e38c use extensions client with explicit version 2017-11-22 21:18:14 +08:00
Clayton Coleman 8f4b6c8771
All commands must declare Unstructured or Internal
Callers must take a dependency on one or the other set of conversions
and default client behavior. Future changes may add a Versioned() type,
but this is an accurate reflection of current code state.
2017-11-19 20:41:02 -05:00
juanvallejo 701d6536a2
move cmd/util/printing.go#PrintSuccess to factory_builder.go 2017-11-15 10:46:39 -05:00
Di Xu 057b7bf767 rename selector to labelSelector 2017-11-06 14:30:20 +08:00
Ferran Rodenas c1802dc472 Update kubectl drain command to use policy V1Beta1 instead of unversioned API
Signed-off-by: Ferran Rodenas <frodenas@gmail.com>
2017-10-25 16:44:57 +02:00
juanvallejo ee2f9c95e7
update resource selector - kubectl drain 2017-10-19 10:10:06 -04:00
juanvallejo e11a11140f
add --dry-run option to kubectl drain 2017-10-06 11:55:36 -04:00
juanvallejo 3775a50cb8
add --selector flag support 2017-10-02 16:18:30 -04:00
juanvallejo 90d76adb4b
add Local and Unstructured builder attributes
Moves DisabledClientMapperForMapping wrapper to new Local attribute.
Removes Factory#NewUnstructuredBuilder in favor of new Unstructured
builder attribute.
2017-09-05 11:57:00 -04:00
ymqytw b776df8a20 move i18n to kubectl/util 2017-08-16 12:27:36 -07:00
Kubernetes Submit Queue 3e8a25e818 Merge pull request #50008 from atlassian/meta-controller-ref
Automatic merge from submit-queue

Migrate to controller references helpers in meta/v1

**What this PR does / why we need it**:
This is a follow up for #48319 that migrates all method usages to new methods in meta/v1.

**Special notes for your reviewer**:
Looking at each commit individually might be easier.

**Release note**:
```release-note
NONE
```
/sig api-machinery
/kind cleanup
2017-08-10 17:07:30 -07:00
Xing Zhou 65c28eb64f Add error return for the Marshal object invocation.
Add error return for the Marshal object invocation.
2017-08-08 13:38:31 +08:00
Mikhail Mazurskiy b28a83a4cf
Migrate to GetControllerOf from meta/v1 package 2017-08-06 22:41:58 +10:00
Kubernetes Submit Queue 0e94e9439f Merge pull request #49438 from zhangxiaoyu-zidif/delete-err-def-for-drain
Automatic merge from submit-queue (batch tested with PRs 48911, 49475, 49438, 49362, 49274)

Delete redundant err definition

**What this PR does / why we need it**:
Delete redundant err definition
line 642 has its definition and initialization, so line 641 is redundant.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
NONE

**Special notes for your reviewer**:
NONE

**Release note**:

```release-note
NONE
```
2017-07-24 20:39:18 -07:00
Eric Paris 7c531ecc13 Do not spin forever if kubectl drain races with other removal
In https://github.com/kubernetes/kubernetes/pull/47450 we stopped
returning an error if a pod disappeared before we could remove it.
Instead we just continue to spin forever. Return "success" if a pod
disappeared before we actually removed it.

https://bugzilla.redhat.com/1473777
bug 1473777
2017-07-22 13:39:01 -04:00
zhangxiaoyu-zidif 1b785d09d4 Delete redundant err definition 2017-07-22 16:19:32 +08:00
Kubernetes Submit Queue d58d29d99d Merge pull request #48082 from ravisantoshgudimetla/kubectl_drain_node_conversion
Automatic merge from submit-queue (batch tested with PRs 48082, 48815, 48901, 48824)

Changes for typecasting node in drain

**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #48059 

**Special notes for your reviewer**:
Precursor to #44944

**Release note**:

```release-note
kubectl drain now uses PATCH instead of PUT to update the node. The node object is now of type v1 instead of using internal api.
```
2017-07-13 22:43:54 -07:00
ravisantoshgudimetla db120eb8ca Changes for converting node to v1 in drain 2017-07-12 21:36:29 -04:00
ymqytw b336691ca3 eliminate kubectl dependency on kubelet 2017-07-05 20:23:30 -07:00
Alexander Campbell 6fd36c10ad kubectl/cmd: many small refactors
* Rename variables and functions to match Go convention.
   For example, UsageError --> UsageErrorf.
 * Remove redundant or unreachable code.
 * Simplify some utility functions (no functionality changes).
 * Fix hanging 'if { return } else { return }' constructs.
 * Fix several incorrect printf verbs.
2017-06-27 16:25:20 -07:00
Kubernetes Submit Queue 60126b0ceb Merge pull request #47471 from crimsonfaith91/drain
Automatic merge from submit-queue (batch tested with PRs 46151, 47602, 47507, 46203, 47471)

deprecate created-by annotation for pod drain

**What this PR does / why we need it**: This PR deprecates created-by annotation for pod drain. This is required as we now have ControllerRef.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: xref #44407

**Special notes for your reviewer**: This is the second PR for deprecating created-by annotation. Other PRs can be found here: https://github.com/kubernetes/kubernetes/pull/47469 , #47475 

**Release note**:

```release-note
```
2017-06-23 05:08:30 -07:00
Jun Xiang Tee d76b08d154 deprecate created-by annotation for pod drain 2017-06-16 13:33:26 -07:00
Kubernetes Submit Queue c31893978b Merge pull request #45918 from juanvallejo/jvallejo/fix-kubectl-set-resources-local
Automatic merge from submit-queue

fix --local flag for kubectl commands

Fixes https://github.com/kubernetes/kubernetes/issues/47079

**Release note**:
```release-note
NONE
```

Fixes the `--local` flag for `kubectl set ...` sub-commands.
**As of the 1.7 release**, `PrinterForCommand` was updated to [use a mapper and typer for unstructured objects](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/util/factory_builder.go#L52), which further prevented the use of `--local` when there was no connection to an api server.


**before** (with no connection to a server)
```
$ kubectl set resources -f pod.json --limits=cpu=200m,memory=512Mi --local
error: unable to connect to a server to handle "pods": Get https://10.13.137.149:8443/api: dial tcp 10.13.137.149:8443: getsockopt: connection refused
```

**after** (with no connection to a server)
```
$ kubectl set resources -f pod.json --limits=cpu=200m,memory=512Mi --local
NAME              READY     STATUS    RESTARTS   AGE
mypod   0/1                 0          <unknown>
```

cc @smarterclayton @fabianofranz
2017-06-16 08:19:13 -07:00
Michail Kargakis 26d3eadb46
Ignore 404s on evict 2017-06-13 20:21:26 +02:00
juanvallejo d036686185
fix --local flag for `kubectl set` commands 2017-06-13 12:57:05 -04:00
Derek Carr 1dc4d77942 kubectl drain errors if pod is already deleted 2017-06-09 17:05:43 -04:00
Brendan Burns 79f51923d3 Extract a bunch more strings from kubectl 2017-04-06 20:12:50 -07:00
Kubernetes Submit Queue eaf3c47489 Merge pull request #42115 from justinsb/kubectl_expose_drainoptions
Automatic merge from submit-queue (batch tested with PRs 42162, 41973, 42015, 42115, 41923)

kubectl drain: make code reusable

DrainOptions requires a few fields to be set, and the expectation is
that these are set as part of construction of the object.  If they are
set, then the drain code can be reused in other kubernetes projects.

This does not create a contract that DrainOptions should fulfill going
forwards, any more than any of the other types that happen to be exposed
are part of the contract.  Instead, this merely makes use outside the
package possible.

```release-note
NONE
```
2017-02-28 22:06:03 -08:00
Maciej Szulik 27259358cb Switch ClientAccessFactory to use clientset.Interface rather than actual type 2017-02-27 13:13:06 +01:00
Justin Santa Barbara 72afd143c4 kubectl drain: make code reusable
DrainOptions requires a few fields to be set, and the expectation is
that these are set as part of construction of the object.  If they are
set, then the drain code can be reused in other kubernetes projects.

This does not create a contract that DrainOptions should fulfill going
forwards, any more than any of the other types that happen to be exposed
are part of the contract.  Instead, this merely makes use outside the
package possible.
2017-02-26 00:48:48 -05:00
Maru Newby 92d739bebc kubectl: Allow 'drain --force' to remove orphaned pods 2017-02-22 06:59:33 -08:00
Kubernetes Submit Queue 5c4cec21c3 Merge pull request #38771 from derekwaynecarr/fix_drain_typo
Automatic merge from submit-queue (batch tested with PRs 41145, 38771, 41003, 41089, 40365)

Fix typo in drain command
2017-02-09 13:34:47 -08:00
Brendan Burns d9c4a289a6 Extract strings for translation. 2017-02-06 22:32:01 -08:00
Clayton Coleman be6d2933df
refactor: Move *Options references to metav1 2017-01-24 13:41:51 -05:00