Commit Graph

3159 Commits (284e8182a402cfd545fc000fedaea071fed873b0)

Author SHA1 Message Date
Maciej Szulik 5d721bff81
Remove pkg/client/unversioned 2018-02-21 13:08:11 +01:00
Kubernetes Submit Queue 370540f90d
Merge pull request #60057 from deads2k/cli-07-printer
Automatic merge from submit-queue (batch tested with PRs 59391, 58097, 60057, 60090). 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>.

cleanup printers some more

This cleans up some more dead printer flags and unnecessary arguments for various methods.  We're getting closer.  Still need to clean up some ugly around `PrintSuccess` and then its time to start trimming layers.

@kubernetes/sig-cli-maintainers 

```release-note
NONE
```
2018-02-20 13:51:35 -08:00
David Eads dd6405681f cleanup printers some more 2018-02-20 12:59:40 -05:00
Jeff Grafton ef56a8d6bb Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
Kubernetes Submit Queue 01ec7a9eb8
Merge pull request #59809 from phsiao/59733_port_forward_with_target_port
Automatic merge from submit-queue (batch tested with PRs 59809, 59955). 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>.

kubectl port-forward should resolve service port to target port

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

Continues on the work in #59705, this PR adds additional support for looking up targetPort for a service, as well as enable using svc/name to select a pod.

**Which issue(s) this PR fixes**:
Fixes #15180
Fixes #59733

**Special notes for your reviewer**:

I decided to create pkg/kubectl/util/service_port.go to contain two functions that might be re-usable.

**Release note**:
```release-note
`kubectl port-forward` now supports specifying a service to port forward to: `kubectl port-forward svc/myservice 8443:443`
```
2018-02-15 22:42:30 -08:00
Kubernetes Submit Queue bb500a73b6
Merge pull request #59353 from juanvallejo/jvallejo/update-name-printer-output
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 name printer output to kind.group/name

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

Followup to https://github.com/kubernetes/kubernetes/pull/59227

Updates output via `-o name` to be pipeable.

cc @deads2k
2018-02-15 10:37:19 -08:00
juanvallejo 765f9ec68b
update -o name format to kind.group/name 2018-02-15 10:33:06 -05:00
Shawn Hsiao 4a0bbf2363 kubectl port-forward support resolving service port to target port, and support Service as resource type 2018-02-14 12:02:57 -05:00
Shawn Hsiao 139c62c3e9 kubectl port-forward allows using resource name to select a matching pod 2018-02-13 12:10:02 -05:00
Kubernetes Submit Queue 198a098d9d
Merge pull request #59506 from juanvallejo/jvallejo/handle-watch-multiple-reqs
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>.

fix --watch on multiple requests

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

`kubectl get <resource> --watch` only supports watching a single resource kind at a time.
This check fails if more than one resource `Info` is returned.

When dealing with large quantities of a single resource kind, or an amount that exceeds the value of `--chunk-size`, more than one request is made to the server causing a resource `Info` to be created for each of the requests, ultimately causing the above check to fail even though we are dealing with the same type of resource.

This patch modifies that check to take into account the GVKs of all infos returned, and only fail if at least one differs.

cc @deads2k
2018-02-12 02:25:45 -08:00
Kubernetes Submit Queue 317853c90c
Merge pull request #59464 from dixudx/fix_all_typos
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>.

fix all the typos across the project

**What this PR does / why we need it**:
There are lots of typos across the project. We should avoid small PRs on fixing those annoying typos, which is time-consuming and low efficient.

This PR does fix all the typos across the project currently. And with #59463, typos could be avoided when a new PR gets merged.

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

**Special notes for your reviewer**:
/sig testing
/area test-infra
/sig release
/cc @ixdy 
/assign @fejta 

**Release note**:

```release-note
None
```
2018-02-10 22:12:45 -08:00
Di Xu 48388fec7e fix all the typos across the project 2018-02-11 11:04:14 +08:00
juanvallejo aea8deee03
fix --watch on multiple requests 2018-02-09 15:17:02 -05:00
zhengjiajin 6dfe3cb04f add more error logs in kubectl run 2018-02-08 19:37:47 +08:00
Kubernetes Submit Queue 1f6251444b
Merge pull request #51042 from soltysh/request_timeout
Automatic merge from submit-queue (batch tested with PRs 59276, 51042, 58973, 59377, 59472). 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 passing request-timeout from NewRequest all the way down

**What this PR does / why we need it**:
Currently if you pass `--request-timeout` it's not passed all the way down to the actual request object. There's a separate field on the `Request` object that allows setting that timeout, but it's not taken from that flag. 

@smarterclayton @deads2k ptal, this is coming from https://github.com/openshift/origin/pull/13701
2018-02-07 12:00:44 -08:00
Kubernetes Submit Queue 15dbd4e2ae
Merge pull request #59227 from juanvallejo/jvallejo/remove-mapper-dep-printer
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>.

remove mapper dependency for cmdutil.Factory#PrintSuccess

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

Part of a series of patches removing printing stack dependency on mappings the rest mapper

**Before**
```
$ kubectl label pod/my-pod label=label
pod "my-pod" labeled
```

**After**
```
$ kubectl label pod/my-pod label=label
pods "my-pod" labeled
```

cc @deads2k
2018-02-07 08:39:15 -08:00
juanvallejo beb5ea641a
remove mapper dependency - PrintSuccess 2018-02-07 10:10:45 -05:00
Maciej Szulik 7da1002091 Allow passing request-timeout from NewRequest all the way down to actual request 2018-02-07 16:02:26 +01:00
bin liu f679fc1827 Remove duplicated comment 2018-02-07 16:48:22 +08:00
Kubernetes Submit Queue 313f443015
Merge pull request #58991 from juanvallejo/jvallejo/fix-apply-force
Automatic merge from submit-queue (batch tested with PRs 51323, 59306, 58991, 59050). 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>.

fix apply --force w/ invalid resource

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

- First commit: Fixes cases where `--force` is provided with `kubectl apply`, with an object that is BOTH invalid and will cause a conflict error
- Second commit: Fixes cases where `--force` is provided with `kubectl apply`, with an invalid object 

Justification for the first commit here: https://bugzilla.redhat.com/show_bug.cgi?id=1539529#c3

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

cc @ironcladlou
2018-02-06 10:40:37 -08:00
Kubernetes Submit Queue 989e4f868b
Merge pull request #51323 from dixudx/conflict_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>.

kubectl should return an error if "-l" and "--all" are both specified

**What this PR does / why we need it**:
Per discussion in [#50497](https://github.com/kubernetes/kubernetes/pull/50497#discussion_r134881507)

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

**Special notes for your reviewer**:
/assign @caesarxuchao @mengqiy 

**Release note**:

```release-note
kubectl should return an error if "-l" and "--all" are both specified
```
2018-02-06 10:00:47 -08:00
juanvallejo ef0e40d39c
fix apply --force w/ invalid AND conflicting resource 2018-02-06 11:29:00 -05:00
Di Xu e45117856e kubectl: cannot set --all and --selector at the same time 2018-02-06 23:55:36 +08:00
Kubernetes Submit Queue 3021aa224c
Merge pull request #55516 from zjj2wry/config-unset
Automatic merge from submit-queue (batch tested with PRs 59158, 38320, 59059, 55516, 59357). 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 example for kubectl config unset, this will help user use

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

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2018-02-05 12:40:40 -08:00
Kubernetes Submit Queue 5320cdeedd
Merge pull request #58533 from juanvallejo/jvallejo/usability-add-kubectl-describe-suggestion
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>.

suggest using describe cmd to list pod containers

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

Usability: suggest using `kubectl describe` to obtain available pod containers when running `kubectl attach ...`

cc @soltysh
2018-02-05 07:27:43 -08:00
zhengjiajin 46f760e8d0 add example for kubectl config unset, this will help user use 2018-02-05 20:33:49 +08:00
juanvallejo 6a79239944
suggest using describe cmd to list pod containers 2018-02-01 15:33:51 -05:00
Juan Vallejo 4026356b1c
Revert "fail earlier on discovery failures" 2018-02-01 13:02:10 -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 235714e7f3
Merge pull request #58298 from p0lyn0mial/generic_scaler_scalerfor_continued
Automatic merge from submit-queue (batch tested with PRs 58955, 58968, 58971, 58963, 58298). 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>.

removes the remainder from ScalerFor method

**What this PR does / why we need it**:
this PR removes existing scalers from `ScalerFor` method

**Release note**:

```release-note
NONE
```
2018-01-29 13:48:51 -08:00
p0lyn0mial 71eb1ff3b1 removes the remainder from ScalerFor method
all remaining scalers were replaced by GenericScaler exept JobScaler.
It is not clear whether JobScaler could use generic scaler or not.
For more details see the pull request.
2018-01-29 20:02:27 +01:00
Kubernetes Submit Queue f2ac9671f0
Merge pull request #57229 from niuzhenguo/cleanup_validargs
Automatic merge from submit-queue (batch tested with PRs 57229, 58907). 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>.

Abstract cmd valid args get behind the factory

**What this PR does / why we need it**:
This abstract retrieving the list of handled resources for valid args as a function to follow more conventions.

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2018-01-27 00:31:30 -08:00
Kubernetes Submit Queue 3009ec94f7
Merge pull request #58861 from liggitt/prefer-resources-to-shortnames
Automatic merge from submit-queue (batch tested with PRs 58760, 58861). 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>.

Prefer exact resource name matches to shortname expansions

Prevents a shortname of "pod" or "pods" from taking precedence over an exact resource name match

```release-note
NONE
```
2018-01-26 14:46:29 -08:00
Kubernetes Submit Queue d352fc6f3f
Merge pull request #56829 from niuzhenguo/create-run
Automatic merge from submit-queue (batch tested with PRs 58518, 58771, 58101, 56829). 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>.

[Kubectl] Update RunCreate to follow more conventions

**What this PR does / why we need it**:
Make RunCreate with options like other commands, and abstract raw() into separated func.

**Release note**:

```release-note
NONE
```
2018-01-26 01:03:41 -08:00
Jordan Liggitt e1e1be74da
Prefer exact resource name matches to shortname expansions 2018-01-26 01:45:38 -05:00
Kubernetes Submit Queue 617c87ba06
Merge pull request #58741 from dixudx/fix_kubectl_alias_group
Automatic merge from submit-queue (batch tested with PRs 58302, 58782, 58555, 58741). 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 containing API group when resolving shortname from discovery

**What this PR does / why we need it**:
kubectl does not use containing API group when resolving shortname from discovery 

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

**Special notes for your reviewer**:
/assign @liggitt 
/cc @nikhita @zjj2wry 
**Release note**:

```release-note
use containing API group when resolving shortname from discovery
```
2018-01-25 11:43:57 -08:00
Maciej Szulik c7efab40b6 Fix kubectl explain for cronjobs 2018-01-25 16:10:31 +01:00
Di Xu 97ec47ba55 use containing API group when resolving shortname from discovery 2018-01-25 09:38:34 +08:00
Kubernetes Submit Queue 3cbb62b6bb
Merge pull request #56206 from brancz/top-metrics-s
Automatic merge from submit-queue (batch tested with PRs 56206, 58525). 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>.

kubectl: Use metrics-server for kubectl top commands

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

This PR implements support for the kubectl top commands to use the metrics-server as an aggregated API, instead of requesting the metrics from heapster directly. If the `metrics.k8s.io` API is not served by the apiserver, then this still falls back to the previous behavior.

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

Fixes #55489

**Special notes for your reviewer**:

As utilizing heapster as well as the v1alpha1 version of the metrics API is discouraged, I intentionally implemented the support very separated, so that once it is decided, that support is entirely removed, this will make it easy.

**Release note**:

```release-note
Support metrics API in `kubectl top` commands.
```

/cc @kubernetes/sig-instrumentation-pr-reviews @DirectXMan12 @fgrzadkowski @piosz
2018-01-23 13:17:31 -08:00
Kubernetes Submit Queue 2a04c09027
Merge pull request #58144 from tomerf/kubectl_cp_prefix
Automatic merge from submit-queue (batch tested with PRs 58144, 57149). 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>.

Fixed crash in kubectl cp when path has multiple leading slashes

**What this PR does / why we need it**: Fixed crash in kubectl cp when path has multiple leading slashes
For example:
```
$ kubectl cp pod://path/to/somewhere localfile
tar: Removing leading `//' from member names
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
k8s.io/kubernetes/pkg/kubectl/cmd.untarAll(0x363e840, 0xc420198120, 0x7fff5fbffc13, 0x1, 0x7fff5fbffbfa, 0x18, 0x0, 0x0)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go:329 +0x7b4
k8s.io/kubernetes/pkg/kubectl/cmd.copyFromPod(0x3671940, 0xc420261dd0, 0xc4202f9200, 0x3644480, 0xc42000c020, 0x0, 0x0, 0x7fff5fbffbed, 0xb, 0x7fff5fbffbf9, ...)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go:237 +0x375
k8s.io/kubernetes/pkg/kubectl/cmd.runCopy(0x3671940, 0xc420261dd0, 0xc4202f9200, 0x3644480, 0xc42000c018, 0x3644480, 0xc42000c020, 0xc4203490a0, 0x2, 0x2, ...)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go:134 +0x35b
k8s.io/kubernetes/pkg/kubectl/cmd.NewCmdCp.func1(0xc4202f9200, 0xc4203490a0, 0x2, 0x2)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go:72 +0x89
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute(0xc4202f9200, 0xc420348ee0, 0x2, 0x2, 0xc4202f9200, 0xc420348ee0)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:603 +0x234
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc42038d440, 0x8000104, 0x0, 0xffffffffffffffff)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:689 +0x2fe
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute(0xc42038d440, 0xc420261dd0, 0x3644440)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:648 +0x2b
k8s.io/kubernetes/cmd/kubectl/app.Run(0x0, 0x0)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubectl/app/kubectl.go:41 +0xd5
main.main()
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubectl/kubectl.go:27 +0x26
```

**Which issue(s) this PR fixes** None

**Special notes for your reviewer**: None

**Release note**:
```release-note
Fixed crash in kubectl cp when path has multiple leading slashes
```
2018-01-22 19:02:27 -08:00
Frederic Branczyk b1448adb59
kubectl: Use metrics-server for kubectl top commands 2018-01-22 21:45:06 +01:00
juanvallejo 13add66f1e
tolerate more than one gvklist item
Some third-party resources could be part of more than one api group.
Allow this to be the case when adding openapi models to openapi data.
2018-01-19 14:24:03 -05:00
Louis Taylor b0f8a541fa
kubectl: make error with resource list prettier
Previously, running commands like `kubectl get` with no further
arguments would print a list of valid resource types with an error
messages formatted like so:

    <snip>
      * serviceaccounts (aka 'sa')
      * services (aka 'svc')
      * statefulsets (aka 'sts')
      * storageclasses (aka 'sc')error: Required resource not specified.
    Use "kubectl explain <resource>" for a detailed description of that resource (e.g. kubectl explain pods).
    See 'kubectl get -h' for help and examples.

This commit adds extra spacing so it now looks pretty:

    <snip>
      * serviceaccounts (aka 'sa')
      * services (aka 'svc')
      * statefulsets (aka 'sts')
      * storageclasses (aka 'sc')

    error: Required resource not specified.
    Use "kubectl explain <resource>" for a detailed description of that resource (e.g. kubectl explain pods).
    See 'kubectl get -h' for help and examples.
2018-01-18 22:19:44 +00:00
Kubernetes Submit Queue 44d0ba29d3
Merge pull request #56960 from islinwb/remove_unused_code_ut_pkg
Automatic merge from submit-queue (batch tested with PRs 53631, 56960). 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>.

Remove unused code in UT files in pkg/

**What this PR does / why we need it**:
Remove unused code in UT files in pkg/ .

**Release note**:

```release-note
NONE
```
2018-01-18 02:41:29 -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
David Eads d7ddcca231 low hanging fruit for using cobra commands 2018-01-17 13:43:43 -05:00
David Eads 49f12fa70f fail earlier on discovery failures 2018-01-16 16:02:13 -05:00
Kubernetes Submit Queue b04c28e80e
Merge pull request #57381 from niuzhenguo/get-raw-cleanup
Automatic merge from submit-queue (batch tested with PRs 52912, 57381). 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 more validators when run kubectl get with --raw

**What this PR does / why we need it**:
1. Make --raw and --output mutually exclusive for kubectl get cmd
2. Add url/ParseRequestURI check for the specified raw URI

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2018-01-15 22:13:33 -08:00
Kubernetes Submit Queue 1a341f6b88
Merge pull request #52912 from zjj2wry/rollout-status
Automatic merge from submit-queue (batch tested with PRs 52912, 57381). 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>.

bug(cli):fix kubectl rollout status not recoginze resource namespace

**What this PR does / why we need it**:
Fixes #42364

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

**Special notes for your reviewer**:
cc @kubernetes/sig-cli-pr-reviews

**Release note**:

```release-note
NONE
```
2018-01-15 22:13:30 -08:00
Kubernetes Submit Queue f008f147f8
Merge pull request #52321 from Mashimiao/factory-tfix
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>.

small tfix in cmd factory comment

Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>

**What this PR does / why we need it**:
tfix in cmd factory comment

**Release note**:
```release-note
NONE
```
2018-01-15 11:34:48 -08:00
Nikhita Raghunath 5cdd4dcbd5 kubectl scale: support Unstructured objects 2018-01-15 17:01:45 +05:30
linweibin fa8afc1d39 Remove unused code in UT files in pkg/ 2018-01-15 16:02:35 +08:00
Kubernetes Submit Queue 52a2256b1a
Merge pull request #57843 from p0lyn0mial/wire_generic_scaler
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>.

wires the generic scaler to kubectl

**What this PR does / why we need it**:
the changes introduced in this commit plumbs in the generic scaler to kubectl.
note that we don't change the behaviour of kubectl.
For example it won't scale new resources. That's the end goal.
The first step is to retrofit existing code to use the generic scaler.

**Release note**:

```release-note
NONE
```
2018-01-13 01:26:24 -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
p0lyn0mial dd9de90b0a the changes introduced in this commit plumbs in the generic scaler into kubectl.
note that we don't change the behaviour of kubectl.
For example it won't scale new resources. That's the end goal.
The first step is to retrofit existing code to use the generic scaler.
2018-01-12 09:21:18 +01:00
Kubernetes Submit Queue 4a77bd53e8
Merge pull request #57259 from ericchiang/client-go-no-cache-import
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>.

client-go: remove import of github.com/gregjones/httpcache

Moves NewCacheRoundTripper from `k8s.io/client-go/transport` to its own package. This prevents Kubernetes clients from requiring its dependencies.

This change removes the following transitive imports from `k8s.io/client-go/kubernetes`

```
github.com/google/btree
github.com/gregjones/httpcache
github.com/gregjones/httpcache/diskcache
github.com/peterbourgon/diskv
```


```release-note
NONE
```
2018-01-11 01:25:50 -08:00
Tomer Froumin 52f02c42e6 Fixed crash when path has multiple leading slashes 2018-01-11 10:46:22 +02:00
Kubernetes Submit Queue ba57ff9875
Merge pull request #57112 from aramase/kubectl-fixes
Automatic merge from submit-queue (batch tested with PRs 58025, 57112, 57879, 57571, 58062). 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>.

fix typos in kubectl pkg

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

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2018-01-10 11:46:43 -08:00
Kubernetes Submit Queue 91884464d2
Merge pull request #56919 from dixudx/refactor_get_uninitialized
Automatic merge from submit-queue (batch tested with PRs 49874, 56919, 57246). 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>.

refactor getting uninitialized in kubectl get

**What this PR does / why we need it**:
remove leftover TODO to refactor getting uninitialized in kubectl get

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

**Special notes for your reviewer**:
/assign @smarterclayton 

**Release note**:

```release-note
None
```
2018-01-10 08:15:44 -08:00
Ahmet Alp Balkan ee0351320e
cmd/kubectl: fix broken error formatting for run
This patch adds missing value to a format string (%s) in --restart flag
validation for "kubectl run".

"kubectl run --restart=foo" was giving error:

    error: invalid restart policy: %!s(MISSING)

Now it says:

    error: invalid restart policy: foo

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
2018-01-09 17:00:35 -08:00
Kubernetes Submit Queue b2ffdb73ac
Merge pull request #57511 from niuzhenguo/show-kind
Automatic merge from submit-queue (batch tested with PRs 57511, 57978). 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>.

Small improvement of showKind get

**What this PR does / why we need it**:
Given the complexity of determining whether to show resource with kind, this PR will be a small improvement when with `--show-kind=true`. There's no need to waste time to run the complex logic if we already decided to show resource with kind.

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2018-01-09 15:19:30 -08:00
Zhenguo Niu 3d75e990c3 [Kubectl] Update RunCreate to follow more conventions 2018-01-09 15:45:26 +08:00
Zhenguo Niu c3d77eea54 Abstract cmd valid args get behind the factory 2018-01-09 09:58:07 +08:00
Eric Chiang ea085e0a32 client-go: remove import of github.com/gregjones/httpcache 2018-01-08 09:54:12 -08:00
juanvallejo d4e17cb7b4
Allow oadm drain to continue w ds-managed pods w local storage 2018-01-08 11:51:15 -05:00
Kubernetes Submit Queue a2bce0d74e
Merge pull request #56769 from dixudx/forbid_unnamed_context
Automatic merge from submit-queue (batch tested with PRs 57521, 56769). 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>.

forbid unnamed context

**What this PR does / why we need it**:
forbid unnamed contexts with validation

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

**Special notes for your reviewer**:
/assign @sttts @fabianofranz 

**Release note**:

```release-note
forbid unnamed context
```
2018-01-07 11:19:45 -08:00
Di Xu 792a229936 forbid unnamed context 2018-01-07 10:52:03 +08:00
Anish Ramasekar c322f1d065
fix typos in kubectl pkg 2018-01-05 21:04:44 -06:00
Zhenguo Niu 93b11ad12d Small improvement of showKind get 2018-01-05 18:36:14 +08:00
Kubernetes Submit Queue f875756902
Merge pull request #57021 from lcfang/delkuctl
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>.

delete the unused function in kubectl

**What this PR does / why we need it**:
delete some unused code in `kubctl`
2018-01-04 14:11:54 -08:00
Maciej Szulik 2f9532f047 Allow kubectl set image/env on a cronjob 2018-01-04 10:27:37 +01:00
lcfang 44e2e7a906 delete the unused function in kubectl 2018-01-04 12:00:38 +08:00
Kubernetes Submit Queue b3cf1bd102
Merge pull request #56779 from Lion-Wei/kubectl-2
Automatic merge from submit-queue (batch tested with PRs 57651, 56411, 56779, 57523, 57624). 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>.

Error out if kubectl create with extra argument

**What this PR does / why we need it**:
When using `kubectl create` command with extra args, kubectl will accept the first one and ignore the others. 
This pr give a warnning in this case

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes kubernetes/kubectl#148

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```
2018-01-02 14:09:45 -08:00
Christoph Blecker 80e344644e
Regenerate all generated code 2018-01-02 00:21:07 -08: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
Jeff Grafton efee0704c6 Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
Kubernetes Submit Queue 56acf19e6d
Merge pull request #57303 from niuzhenguo/url-check
Automatic merge from submit-queue (batch tested with PRs 57400, 57403, 57303). 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>.

Restrict url conditions when run kubectl create with --raw

**What this PR does / why we need it**:
Currently when run kubectl create with --raw, it will raise "--raw cannot read from a url " if the filename has prefix "http", which is not proper as we may have filenames like "httptest" or similar.

This PR restrict the URL check conditions.

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-12-19 11:27:37 -08:00
Zhenguo Niu 8a7f8bc046 Move output and url checks under raw flag condition 2017-12-19 17:51:30 +08:00
Zhenguo Niu a0a69a3583 Add more validate conditions when run kubectl get with --raw 2017-12-19 15:37:21 +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
Kubernetes Submit Queue 5c17bec909
Merge pull request #57140 from niuzhenguo/noheaders-linebreak
Automatic merge from submit-queue (batch tested with PRs 56947, 56349, 57140, 53686, 57314). 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>.

Kubectl: Move no-headers flag get out of for loop

**What this PR does / why we need it**:
This makes no-headers flag get before the for loop happen, there's no need to get the flag multiple times.

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-12-18 12:24:41 -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
Kubernetes Submit Queue 90acdba062
Merge pull request #57150 from deads2k/rebase-03-convert
Automatic merge from submit-queue (batch tested with PRs 57324, 56931, 57000, 57150, 56965). 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 convert to default on a per object basis

`kubetl convert` needs to distinguish between cases where a user specifies a version (use this at all cost) and cases where it doesn't (for each object, find the best version to convert to).  This allows that to happen.
2017-12-18 08:46:49 -08: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
Zhenguo Niu 9b549bd5f4 Restrict url check conditions when creating with --raw 2017-12-18 13:42:58 +08:00
Kubernetes Submit Queue 5f92042610
Merge pull request #56483 from dixudx/fix_cli_attach_format
Automatic merge from submit-queue (batch tested with PRs 57127, 57011, 56754, 56601, 56483). 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>.

fix bad output format for attaching pods

**What this PR does / why we need it**:
If the user wants to attach stdin, wants a TTY, and `o.In` is a terminal, `t.Raw` is set to true, which is causing bad format like #56450.

We should avoid print extra logs in `SafeFunc`. Move it outer.

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

**Special notes for your reviewer**:
/assign @thockin @kubernetes/sig-cli-bugs  

**Release note**:

```release-note
None
```
2017-12-17 06:26:01 -08:00
Kubernetes Submit Queue 6236cddab7
Merge pull request #54881 from juanvallejo/jvallejo/use-printer-for-cmd-through-factory
Automatic merge from submit-queue (batch tested with PRs 56676, 57050, 54881, 56822, 57113). 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>.

ensure PrinterForCommand is consumed through cmdutil.Factory

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

This patch is one in a series of patches that aims to move all
printing functions to the `cmdutil.Factory` in order to make
the factory the one-stop shop for accessing printers in the client.

This PR is related to https://github.com/kubernetes/kubernetes/pull/50113 and aims to break the set of changes
introduced in this commit in order to make them easier to review.

@fabianofranz @mengqiy @shiywang
2017-12-16 19:19:44 -08:00
Kubernetes Submit Queue b9eee8fd6b
Merge pull request #54902 from YuxiJin-tobeyjin/addunitforlogs
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>.

Supplement unit test for kubectl logs

**What this PR does / why we need it**:
Supplement unit test for kubectl logs

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE

```
2017-12-16 09:15:26 -08:00
Kubernetes Submit Queue 6541b1ae06
Merge pull request #56673 from niuzhenguo/fix-diff-cmd-typo
Automatic merge from submit-queue (batch tested with PRs 56639, 56746, 56715, 56673, 56726). 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>.

Fix a typo in kubectl/diff cmd long description.

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

Correct a typo in kubelet alpha diff cmd long description.

**Release note**:
```release-note
NONE
```
2017-12-16 06:39:47 -08:00
Kubernetes Submit Queue 12402f3a94
Merge pull request #56512 from tpepper/docs
Automatic merge from submit-queue (batch tested with PRs 56579, 55236, 56512, 56549, 56538). 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>.

kubectl: point info url to user guide overview

The kubectl command output suggests a user find more information at the
github source repo, eg:

	$ kubectl --help
	kubectl controls the Kubernetes cluster manager.

	Find more information at https://github.com/kubernetes/kubernetes.

But there is curated user documentation available at, eg:

	https://kubernetes.io/docs/reference/kubectl/overview/

which upon referencing yields a much better experience for a user than the
top of the source repo.

Fixes #56511

Signed-off-by: Tim Pepper <tpepper@vmware.com>

```release-note
NONE
```
2017-12-15 21:19:40 -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 761fdeacaa
Merge pull request #55689 from luksa/kubectl_explain_kind_version
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>.

Make kubectl explain print the Kind and APIVersion of the resource

**What this PR does / why we need it**:
Kubectl explain currently doesn't print out the Kind and APIversion of the resource being explained. When running `kubectl explain hpa.spec`, for example, there is no way of knowing whether you're looking at the `autoscaling/v1` or the `autoscaling/v2beta1` version. 
Also, `kubectl explain` is often used as a reference when writing YAML/JSON object manifests. It allows you to look up everything except the API version. Currently, you either need to know the API Version of a resource by heart or look it up in the online API docs. 
This PR fixes both problems by having `kubectl explain` print out the full Kind and APIVersion of the resource it is explaining.

Here are a few examples of the new output:
```
$ kubectl explain deploy
KIND:     Deployment
VERSION:  extensions/v1beta1

DESCRIPTION:
...


$ kubectl explain hpa.spec
KIND:     HorizontalPodAutoscaler
VERSION:  autoscaling/v1

RESOURCE: spec <Object>

DESCRIPTION:
...


$ kubectl explain hpa.spec.maxReplicas
KIND:     HorizontalPodAutoscaler
VERSION:  autoscaling/v1

FIELD:    maxReplicas <integer>

DESCRIPTION:
...


$ kubectl explain hpa.spec --recursive
KIND:     HorizontalPodAutoscaler
VERSION:  autoscaling/v1

RESOURCE: spec <Object>

DESCRIPTION:
     behaviour of autoscaler. More info:
     https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.

     specification of a horizontal pod autoscaler.

FIELDS:
   maxReplicas	<integer>
   minReplicas	<integer>
   scaleTargetRef	<Object>
      apiVersion	<string>
      kind	<string>
      name	<string>
   targetCPUUtilizationPercentage	<integer>
```

**Release note**:

```release-note
Kubectl explain now prints out the Kind and API version of the resource being explained
```
2017-12-15 08:12:28 -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 126aafb287
Merge pull request #55604 from zjj2wry/kubectl_api_dep
Automatic merge from submit-queue (batch tested with PRs 55557, 55504, 56269, 55604, 56202). 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>.

remove internal version api from kubectl

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

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

**Special notes for your reviewer**:
/cc @liggitt  
**Release note**:

```release-note
NONE
```
2017-12-14 13:54:46 -08:00
Kubernetes Submit Queue 8e161212f6
Merge pull request #55913 from wackxu/refauto
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 structured generator for kubectl autoscale

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

Use structured generator for kubectl autoscale

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
part of  # https://github.com/kubernetes/kubectl/issues/138

**Special notes for your reviewer**:
/assign @mengqiy 

**Release note**:

```release-note
Use structured generator for kubectl autoscale 
```
2017-12-14 00:45:18 -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
Kubernetes Submit Queue 876259435a
Merge pull request #55991 from supereagle/core-client-with-version
Automatic merge from submit-queue (batch tested with PRs 54604, 55781, 55806, 55935, 55991). 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 core client with explicit version

**What this PR does / why we need it**:
Core 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**:
/cc @kubernetes/sig-api-machinery-pr-reviews
/cc @caesarxuchao @k82cn @sttts @kevin-wangzefeng 

**Release note**:
```release-note
NONE
```
2017-12-13 22:26:01 -08:00
Tim Pepper bd4e89cf5d kubectl: point info url to user guide overview
The kubectl command output suggests a user find more information at the
github source repo, eg:

	$ kubectl --help
	kubectl controls the Kubernetes cluster manager.

	Find more information at https://github.com/kubernetes/kubernetes.

But there is curated user documentation available at, eg:

	https://kubernetes.io/docs/reference/kubectl/overview/

which upon referencing yields a much better experience for a user than the
top of the source repo.

Fixes #56511

Signed-off-by: Tim Pepper <tpepper@vmware.com>
2017-12-13 17:01:50 -08:00
David Eads 2f7793df7d allow convert to default on a per object basis 2017-12-13 08:48:14 -05:00
Zhenguo Niu 7cccb94edb Kubectl: Move no-headers flag get out of for loop 2017-12-13 17:43:16 +08:00
Di Xu d66d8f053d refactor getting uninitialized in kubectl get 2017-12-07 13:30:20 +08:00
juanvallejo 8c9c2ee2d8
update type-check to use printers.PritnHandler 2017-12-05 13:39:55 -05:00
juanvallejo c53120e6b9
ensure PrinterForCommand is consumed through cmdutil.Factory 2017-12-05 13:39:29 -05:00
Lion-Wei d51fbd35ce warn if kubectl create with extra argument 2017-12-05 09:42:16 +08:00
ymqytw ed0dcb7498 build patch from openapi only for registered types 2017-12-01 13:44:11 -08:00
Zhenguo Niu 2522b3601b Fix a typo in kubectl/diff cmd long description. 2017-12-01 14:31:12 +08:00
Di Xu 6dddafe73b fix bad output format for attaching pods 2017-11-28 18:15:51 +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
Kubernetes Submit Queue e412ad5393
Merge pull request #51321 from mengqiy/kubectl_apply_openapi
Automatic merge from submit-queue (batch tested with PRs 51321, 55969, 55039, 56183, 55976). 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>.

Kubectl apply and strategic merge patch using openapi

- [x] support openapi in strategic merge patch
- [x] test openapi in strategic merge patch
- [x] kubectl apply use openapi to calculate diff be default. It will fall back to use baked-in types when openapi is not available.
- [x] test openapi in kubectl apply

Fixes: kubernetes/kubectl#55

```release-note
kubectl apply use openapi to calculate diff be default. It will fall back to use baked-in types when openapi is not available.
```

/assign @apelisse
2017-11-22 11:59:49 -08:00
supereagle 9c02d7e38c use extensions client with explicit version 2017-11-22 21:18:14 +08:00
Kubernetes Submit Queue 9a0bbd0aa9
Merge pull request #53765 from tanshanshan/fix-bug1
Automatic merge from submit-queue (batch tested with PRs 54529, 53765). 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>.

fix  #53735, check whether  interface conversion is ok

**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 #

fix #53735

avoid interface conversion error 

**Special notes for your reviewer**:

**Release note**:

```release-note
```
2017-11-21 21:38:59 -08:00
ymqytw 0b0004e0c0 support openapi in apply 2017-11-21 10:22:43 -08:00
juanvallejo f5ab356043
pass printOpts by pointer 2017-11-20 14:49:23 -05:00
juanvallejo d3773b4b06
consolidate printer OutputOpts w PrintOpts
This patch removes the use of printers.OutputOptions in favor of only
having a single struct for setting / passing printer options set by user
flags.
2017-11-20 14:49:23 -05:00
wackxu 87054639a2 refactor kubectl autoscale to use the new generator 2017-11-20 14:12:20 +08:00
Clayton Coleman 09b64d36d2
rollingupdate should use explicit casting
It needs both internal and versioned - use the new helpers to detect
that
2017-11-19 20:41:02 -05: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
Clayton Coleman 04ab96d2bd
Unify Object and UnstructuredObject
The unified RESTMapper and Typer follow the new rules, but on error will
fallback to the legacy path (while still supporting Unstructured
objects). This allows callers to handle the appropriate distinction
themselves if necessary.

Add a LocalParam() method to the resource.Builder that DRYs up a large
chunk of complicated code in set commands.
2017-11-19 19:16:50 -05:00
Clayton Coleman 7563a0c4d8
Remove unstructured error checking from affected code
Also remove error messages that depended on ObjectKinds() - future
changes will potentially remove this interface and the replacements here
are equivalent.
2017-11-19 19:16:50 -05:00
Clayton Coleman e298aa39c3
Add a lazy discovery interface for Unstructured
Delays the error until the first call and then preserves it for others.
More closely matches the intent of the Object() calls. Loaders are now
lazy and don't need to return errors directly.

Sets the stage for collapsing unstructured and structured builders
together.
2017-11-19 19:16:50 -05:00
Clayton Coleman 287a3ed1e1
Apply set last applied should not need to fetch latest
Latest always refreshes from the server, and the server will return the
updated object. In this case, we want to only access the local file.
2017-11-19 19:16:49 -05:00
Clayton Coleman 5038eb2a3f
Remove use of VersionedObject and simplify builder in generic methods
Reduce all uses of Unstructured to the simpler form, and avoid asking
for mapper or typer unless it is required. Use Typed() for places that
previously used VersionedObject, and remove paths for versioned objects
from code that is now using unstructured.
2017-11-19 19:16:49 -05:00
Clayton Coleman 64f56764d5
Builder should allow moving between unstructured / versioned easily
Demonstrate its use with get.go by removing the need to call decode with
a hardcoded scheme. Add tests to get_test.go to restore proving that
unstructured conversion is possible.
2017-11-19 19:16:49 -05:00
Clayton Coleman 0229fd4bd1
Unify unstructured and versioned object in resource.Builder
resource.Builder should be aware of both paths, and the caller is
responsible for determining the different path via use.
2017-11-19 19:02:25 -05:00
Clayton Coleman 98e0c69907 Revert "refactor builder in kubectl factory"
This reverts commit 06c5be9802.
2017-11-19 19:02:21 -05:00
Kubernetes Submit Queue fa3047880d
Merge pull request #54867 from juanvallejo/jvallejo/move-print-success-cmdutil-factory
Automatic merge from submit-queue (batch tested with PRs 55233, 55927, 55903, 54867, 55940). 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>.

move cmd/util/printing.go#PrintSuccess to factory_builder.go

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

This patch is one in a series of patches that aims to move all
printing functions to the `cmdutil.Factory` in order to make
the factory the one-stop shop for accessing printers in the client.

This PR is related to https://github.com/kubernetes/kubernetes/pull/50113 and aims to break that set of changes
by introducing a portion of them in this commit in order to make 
them easier to review.

@fabianofranz @mengqiy @shiywang @seans3
2017-11-18 12:26:15 -08:00
Kubernetes Submit Queue 153b5f50f2
Merge pull request #53483 from apelisse/openapi-columns
Automatic merge from submit-queue (batch tested with PRs 50457, 55558, 53483, 55731, 52842). 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>.

Show openapi custom columns in `kubectl get`

Change the name of the flag to something slightly more user-friendly,
while making it default true. The flag is kept so that someone can
revert it temporarly if things go wrong.

**What this PR does / why we need it**: OpenAPI can specify for some columns to be used in `kubectl get`. That's very useful for non-core/hard-coded type in order to print more valuable data in get.

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

**Special notes for your reviewer**:

Closes kubernetes/kubectl#143

**Release note**:
```release-note
`kubectl get` will now use OpenAPI schema extensions by default to select columns for custom types.
```
2017-11-18 11:36:19 -08:00
Kubernetes Submit Queue a67abac765
Merge pull request #55650 from smarterclayton/make_unstructured_conversion
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>.

Move unstructured conversion into pkg/runtime

Scheme conversion should support unstructured conversion natively to
allow going from unstructured to typed and back. It is not a higher
level responsibility to do that conversion because the scheme is the
only one who knows what types it supports.

@liggitt @kubernetes/sig-cli-api-reviews I am going to make Scheme support unstructured in ConvertToVersion and Convert, which means resource.Builder and the CLI can get simpler for all existing use cases where versioned and unstructured need to coexist.
2017-11-18 08:47:10 -08:00
Kubernetes Submit Queue 56e62b684e
Merge pull request #54053 from WanLinghao/cmd_test_unused_function
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>.

remove unused function in cmd_test.go

PR removed unused defaultClientConfigForVersion() functions from cmd_test.go.



**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 #

**Special notes for your reviewer**:

**Release note**:

```
NONE
```
2017-11-17 08:28:26 -08:00
Clayton Coleman f8cc69cafe
kubectl apply edit-last-applied should fail when version is missing
If a user edits last-applied-configuration and it doesn't have an
apiVersion or kind, the command should error out. Now that we check for
kind and version on the unstructured object typer, the previously
passing test now correctly fails. Add a new explicit failure test and
make the existing test pass.
2017-11-16 18:02:41 -05:00
Clayton Coleman 5519a7c5e9
Make edit test use subtests to identify flake 2017-11-16 15:45:59 -05:00
Sergey Lanzman 3474747465 Move regexp.MustCompile to global variable 2017-11-16 22:03:12 +02:00
Kubernetes Submit Queue 2f2d49442f
Merge pull request #55371 from charrywanganthony/showlabel
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>.

Using --show-labels with incompatible ‘kubectl get’ arguments should …

…error out

**What this PR does / why we need it**:
According to @ahmetb 's [issue](https://github.com/kubernetes/kubernetes/issues/55290)  
Under specific circumstances, current behavior is that the `--show-labels` simply doesn’t make a difference since it’s not applicable.  

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

**Release note**:

```release-note
NONE
```
2017-11-16 08:03:18 -08:00
Kubernetes Submit Queue cc62445844
Merge pull request #55647 from smarterclayton/move_category
Automatic merge from submit-queue (batch tested with PRs 55697, 55631, 51905, 55647, 55826). 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>.

Move category expander out of kubectl/resource

Removes coupling with unstructured.  Part of refactoring get.go and simplifying the builder.
2017-11-16 03:57:35 -08:00
Kubernetes Submit Queue c7f8c208c9
Merge pull request #55131 from stewart-yu/addnamespaces
Automatic merge from submit-queue (batch tested with PRs 55682, 55444, 55456, 55717, 55131). 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>.

hint command missing namespace parameters

**What this PR does / why we need it**:
hint command miss namespace parameters.
before change,  the hint is:
```shell
Use 'kubectl describe pod/<podname>' to see all of the containers in this pod.
```
after change, the hint is:
```shell
Use 'kubectl describe pod/<podname> -n <podnamespace>' to see all of the containers in this pod.
```

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-11-15 23:06:22 -08:00
Antoine Pelisse 1d99b763df Show openapi custom columns in `kubectl get`
Change the name of the flag to something slightly more user-friendly,
while making it default true. The flag is kept so that someone can
revert it temporarly if things go wrong.
2017-11-15 14:02:27 -08:00
Antoine Pelisse 9778b1a9ba openapi: Add EmptyResource/CreateOpenAPISchemaFunc test utils
Add a new EmptyResource class that implements openapi.Resources, but
just doesn't have any resources. That is useful for tests that expect
the OpenAPISchema to be working, but don't expect any actual result.

Also implement CreateOpenAPISchemaFunc to simply plug in the TestFactory
code when you want to use an actual APISchema.
2017-11-15 14:02:13 -08:00
Kubernetes Submit Queue 884f256027
Merge pull request #55274 from venezia/enhance_label_taint_docs
Automatic merge from submit-queue (batch tested with PRs 55648, 55274, 54982, 51955, 55639). 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>.

Enhance label and taint documentation in kubectl

**What this PR does / why we need it**:
This adds some language around how taint and label keys can have a domain + '/' in front of them.  From the current documentation, it would seem like these are not allowed even though [well known labels](https://kubernetes.io/docs/reference/labels-annotations-taints/) have them.

Also, it seemed unclear (to me) that both the label's key and value can be 63 characters long.  I wanted to clarify this.

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

**Special notes for your reviewer**:
Phrasing of "_DNS subdomain prefix and '/'_" was copied from [a validator's message](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L57) ... I'm unsure if its the best wording, but wanted to be consistent with the validator.

**Release note**:
```release-note
NONE
```
2017-11-15 12:03:33 -08:00
juanvallejo 701d6536a2
move cmd/util/printing.go#PrintSuccess to factory_builder.go 2017-11-15 10:46:39 -05:00
Clayton Coleman b366afa00a
Move category expander out of kubectl/resource 2017-11-14 17:38:16 -05:00
Kubernetes Submit Queue e725361722
Merge pull request #54877 from juanvallejo/jvallejo/move-PrintResourceInfoRorCommand-cmdutil-factory
Automatic merge from submit-queue (batch tested with PRs 54602, 54877, 55243, 55509, 55128). 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>.

move cmd/util/printing.go#PrintResourceInfoForCommand -> factory…

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

This patch is one in a series of patches that aims to move all
printing functions to the `cmdutil.Factory` in order to make
the factory the one-stop shop for accessing printers in the client.

This PR is related to https://github.com/kubernetes/kubernetes/pull/50113 and aims to break the set of changes
introduced in this commit in order to make them easier to review.

@fabianofranz @mengqiy @shiywang @seans3
2017-11-14 03:03:23 -08:00
Marko Luksa c77d5d0f90 Kubectl explain now also prints the Kind and APIVersion of the resource 2017-11-14 11:05:19 +01:00
zhengjiajin 0fab7c1bec bug(cli):fix kubectl rollout status not recoginze resource namespace 2017-11-14 11:45:14 +08:00
zhengjiajin 3fe0d59607 remove internal version api from kubectl label command 2017-11-13 17:30:09 +08:00
zhengjiajin aabee865cd remove internal version api from kubectl annotate command 2017-11-13 17:29:40 +08:00
zhengjiajin 1fa1e8dac1 use versionedObject replace internal in kubectl set selector 2017-11-13 14:27:59 +08:00
Chao Wang 6a34285e84 Using --show-labels with incompatible ‘kubectl get’ arguments should error out 2017-11-13 09:33:58 +08:00
Kubernetes Submit Queue 7650665059
Merge pull request #54554 from zjj2wry/set-dep
Automatic merge from submit-queue (batch tested with PRs 53337, 55465, 55512, 55522, 54554). 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>.

switch UpdatePodSpecForObject to work on v1.PodSpec, use info.VersionedObject, and avoid conversion completely

**What this PR does / why we need it**:
ref #54212
ref #https://github.com/kubernetes/kubectl/issues/83

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

**Special notes for your reviewer**:
cc @liggitt @pwittrock 
**Release note**:

```release-note
NONE
```
2017-11-11 12:44:30 -08:00
Kubernetes Submit Queue 0ca74ef2e3
Merge pull request #54858 from wackxu/createpri
Automatic merge from submit-queue (batch tested with PRs 54460, 55258, 54858, 55506, 55510). 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 create subcommand for priorityclass

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

add `create priorityclass` sub command


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

**Special notes for your reviewer**:

**Release note**:

```release-note
add create priorityclass sub command
```
2017-11-11 10:45:23 -08:00
Kubernetes Submit Queue fc61d9bc1e
Merge pull request #54987 from tengqm/scale-help
Automatic merge from submit-queue (batch tested with PRs 54987, 55221, 54099, 55144, 54215). 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>.

Scale help

**What this PR does / why we need it**:
The `kubectl autoscale --help` says this:

```
# Auto scale a deployment "foo", with the number of pods between 2 and 10, target CPU utilization specified so a default autoscaling policy will be used:
  kubectl autoscale deployment foo --min=2 --max=10
```

This is incorrect. A default autoscaling policy will be used because *no* target CPU utilization has been specified.

**Which issue(s) this PR fixes**:

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```
2017-11-10 14:51:23 -08:00
zhengjiajin dc312142ab remove todo: switch UpdatePodSpecForObject to work on v1.PodSpec, use info.VersionedObject, and avoid conversion completely 2017-11-11 02:36:12 +08:00
Dr. Stefan Schimanski 1e79dfb959 Update generated code 2017-11-10 18:26:46 +01:00
Kubernetes Submit Queue 3e1f81d97b
Merge pull request #55440 from apelisse/add-owners
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>.

Add apelisse to some OWNERS

I wrote most of this code anyway.

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

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-11-10 05:38:16 -08:00
Kubernetes Submit Queue 81631eceb8
Merge pull request #48340 from superbrothers/completions-config-rename-context
Automatic merge from submit-queue (batch tested with PRs 55268, 55282, 55419, 48340, 54829). 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>.

Support completions for kubectl config rename-context

**What this PR does / why we need it**:
With this PR, kubectl config rename-context supports completion for current context.
```
$ kubectl config rename-context <tab>
cluster01  minikube
```

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

**Special notes for your reviewer**:

**Release note**:

```release-note
Support completion for kubectl config rename-context
```
2017-11-09 21:39:28 -08:00
Antoine Pelisse 5c3c0f6e5b Add apelisse to OWNERS
I wrote most of this code anyway.
2017-11-09 15:39:31 -08:00
juanvallejo 4418591226
move cmd/util/printing.go#PrintResourceInfoForCommand -> factory_builder.go 2017-11-09 15:13:18 -05:00
Kubernetes Submit Queue a78d6b85ce
Merge pull request #46946 from kellycampbell/sort-contexts
Automatic merge from submit-queue (batch tested with PRs 46946, 45792). 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>.

kubectl config get-contexts: sort output

This sorts the output of kubectl config get-contexts because the ordering is otherwise non-stable and makes it harder to find the context you're looking for when you have more than a few.

```release-note
The output of kubectl config get-contexts is now sorted alphabetically by the context name.
```
2017-11-09 11:27:37 -08:00
Kubernetes Submit Queue f4d470c75c
Merge pull request #55162 from deads2k/cli-06-tolerate-error
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>.

tolerate discovery errors in the restmapper

Found this while investigating a related problem.  The restmapper can use the information it has found.  It doesn't have to discard all of it.
2017-11-09 08:36:44 -08:00
Dr. Stefan Schimanski bec617f3cc Update generated files 2017-11-09 12:14:08 +01:00
Dr. Stefan Schimanski 012b085ac8 pkg/apis/core: mechanical import fixes in dependencies 2017-11-09 12:14:08 +01:00
Dr. Stefan Schimanski d13b936a2a pkg/apis/core: fixup conversion func names in dependencies 2017-11-09 12:14:07 +01:00
Kubernetes Submit Queue 79d858660c
Merge pull request #55044 from ahmetb/wording
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>.

kubectl/config/rename: fix wording

Using `Context %q renamed to %q.` in rename-context to be consistent with other
commands like delete-context, set-context, use-context.

/sig cli
/release-note none
2017-11-09 01:52:26 -08:00
Kubernetes Submit Queue 73d53678c6
Merge pull request #55095 from smarterclayton/fix_mac
Automatic merge from submit-queue (batch tested with PRs 55092, 55348, 55095, 55277, 55352). 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>.

Fix unit tests on darwin / non-linux platforms
2017-11-08 21:18:23 -08:00
Kubernetes Submit Queue 2ee10cc73e
Merge pull request #55092 from mengqiy/refactor_factory
Automatic merge from submit-queue (batch tested with PRs 55092, 55348, 55095, 55277, 55352). 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>.

refactor build in kubectl factory

Refactor kubectl factory and resource builder.

This will be helpful for `kinflate`.

```release-note
NONE
```

/assign @monopole
2017-11-08 21:18:16 -08:00
Kubernetes Submit Queue a3e00dbd72
Merge pull request #55120 from enj/enj/r/rbac_reconcile_visitor
Automatic merge from submit-queue (batch tested with PRs 54177, 55203, 55120, 55275, 55260). 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>.

Make ReconcileOptions reusable

This change makes ReconcileOptions fully reusable by:

1. Replacing ResourceBuilder with a Visitor that can be generically plugged in.  This decouples the use of file input from the options.
2. Replacing core client with namespace client since that smaller interface is what is needed by RunReconcile.
3. All fields are now checked by Validate as a way to document that they should be set before calling RunReconcile.

Signed-off-by: Monis Khan <mkhan@redhat.com>

```release-note
NONE
```

/assign @deads2k @fabianofranz @juanvallejo
2017-11-08 18:31:08 -08:00
WanLinghao 3be3cf6b64 removed unused defaultClientConfigForVersion()
functions from cmd_test.go.

 modified:   pkg/kubectl/cmd/cmd_test.go
2017-11-09 10:23:56 +08:00
Kubernetes Submit Queue e5acc48295
Merge pull request #54493 from yland/kubectl_extensions_update
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>.

Replace some occurances of kubernetes internal api types in kubectl 

**What this PR does / why we need it**:
Removes dependency on k8s.io/kubernetes/pkg/apis/extensions from kubectl

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
part of https://github.com/kubernetes/kubectl/issues/83
fixes: https://github.com/kubernetes/kubectl/issues/92

**Special notes for your reviewer**:

**Release note**:
```NONE
```
2017-11-08 14:19:18 -08:00
yland 456df2c74e Replace some occurances of kubernetes internal api types in kubectl 2017-11-08 18:27:45 +01:00
ymqytw 06c5be9802 refactor builder in kubectl factory 2017-11-07 20:16:27 -08:00
Michael Venezia 53b3b5b6c5
Adding documentation on using domains and / in taint/label keys; Also clarified both key and value to labels can be 63 characters long 2017-11-07 20:09:52 -05:00
Kubernetes Submit Queue 45bdf707f0
Merge pull request #50140 from dixudx/kubectl_add_fieldSelector
Automatic merge from submit-queue (batch tested with PRs 53273, 55058, 55237, 50140). 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 field selector for kubectl get

**What this PR does / why we need it**:
When working in #50075, I found current kubectl did not support using `field-selector`.

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

**Special notes for your reviewer**:
/cc @janetkuo @kargakis 
/assign @derekwaynecarr @smarterclayton @bgrant0607 

**Release note**:

```release-note
add field selector for kubectl get
```
2017-11-07 09:39:49 -08:00
Monis Khan 136cb482aa
Make ReconcileOptions reusable
This change makes ReconcileOptions fully reusable by:

1. Replacing ResourceBuilder with a Visitor that can be generically
plugged in.  This decouples the use of file input from the options.
2. Replacing core client with namespace client since that smaller
interface is what is needed by RunReconcile.
3. All fields are now checked by Validate as a way to document that
they should be set before calling RunReconcile.

Signed-off-by: Monis Khan <mkhan@redhat.com>
2017-11-07 09:57:14 -05:00
wackxu 741c58be7f add create subcommand for priorityclass 2017-11-07 15:03:01 +08:00
Kubernetes Submit Queue 658024c2d7
Merge pull request #54846 from zjj2wry/remove-kubectl-dep
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>.

Remove kubectl dependency internal version

**What this PR does / why we need it**:
ref kubernetes/kubectl#83

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

**Special notes for your reviewer**:
use `k8s.io/api/core/v1` replace `k8s.io/kubernetes/pkg/api`

use `k8s.io/client-go/kubernetes/typed/core/v1` replace `k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion`

**Release note**:

```release-note
NONE
```
2017-11-06 06:34:40 -08:00
David Eads 8203b0b135 tolerate discovery errors in the restmapper 2017-11-06 08:22:44 -05:00
Di Xu fa143c6ddf add tests 2017-11-06 17:24:59 +08:00
Di Xu 4a3131ddaa add fieldSelector for kubectl get 2017-11-06 14:30:56 +08:00
Di Xu 057b7bf767 rename selector to labelSelector 2017-11-06 14:30:20 +08:00
stewart-yu 21e56e67b7 add namespace parameters on command 2017-11-06 10:19:08 +08:00
Clayton Coleman d3790db03a
The cp command must call Close() on files, and does not pass on Mac
Path operations needed to be with filepath, not path (for cross
platform compat), and TMPDIR is not guaranteed to have a trailing slash.
2017-11-03 22:21:29 -04:00
Kubernetes Submit Queue 2ecb368026
Merge pull request #53679 from kow3ns/workloadsv1
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>.

Workloads V1

**What this PR does / why we need it**: This PR promotes the Deployment, ReplicaSet, and DaemonSet StatefulSet, ControllerRevision kinds to the apps/v1 group version.

https://github.com/kubernetes/features/issues/353

**Special notes for your reviewer**:
There will be at least two followups to this PR. The first to add a scale sub-resource when the correct location is resolved, and the second to deal with Conditions in the workloads API.

While it would have been preferable to move the kinds individually providing a lesser burden on reviewers, this proved impracticable due to the intricacies of version resolution in kubectl for objects of the different kinds in the same group.  

```release-note
DaemonSet, Deployment, ReplicaSet, and StatefulSet have been promoted to GA and are available in the apps/v1 group version.
```
2017-11-03 15:17:16 -07:00
Kubernetes Submit Queue 7e853132b7
Merge pull request #54056 from yuexiao-wang/modify-comment
Automatic merge from submit-queue (batch tested with PRs 51401, 54056, 54977, 55017, 55052). 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>.

Fix example and comments for kubectl convert

Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>

**What this PR does / why we need it**:
There are some erros in example and comments in convert

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

**Release note**:
```release-note
NONE
```
2017-11-03 12:07:56 -07:00
Kubernetes Submit Queue 97143e51f9
Merge pull request #51401 from CaoShuFeng/rename_context
Automatic merge from submit-queue (batch tested with PRs 51401, 54056, 54977, 55017, 55052). 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>.

[cli] exit when Validate() returns an error

cmdutil.UsageErrorf() does nothing but returna a string. When Validate()
returns an error, we should call exit() function.

fix: https://github.com/kubernetes/kubectl/issues/119

**Release note**:
```
NONE
```
2017-11-03 12:07:53 -07:00
Kenneth Owens 5590c1fb94 gets the correct version of kubernetes client for DaemonSet and StatefulSet History and Rollback and updates test-cmd for new versions 2017-11-03 10:16:50 -07:00
Ahmet Alp Balkan d7b0890217
kubectl/config/rename: fix wording
Using "Context %q renamed to %q." in rename-context to be consistent with other
commands like delete-context, set-context, use-context.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
2017-11-02 21:10:11 -07:00
ymqytw 5557f2e444 discovery client not depend on pkg/api/legacyscheme 2017-11-02 14:59:21 -07:00
Kubernetes Submit Queue 5f73021e25
Merge pull request #54989 from wackxu/reterr
Automatic merge from submit-queue (batch tested with PRs 52367, 53363, 54989, 54872, 54643). 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>.

should check and return err when visit failure

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

should check and return err when visit failure

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-11-02 12:59:18 -07:00
Kubernetes Submit Queue 55e216f56e
Merge pull request #54957 from apelisse/update-kube-openapi
Automatic merge from submit-queue (batch tested with PRs 55004, 54957). 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 kube-openapi to use validation

**What this PR does / why we need it**: Moves openapi validation code to kube-openapi, so that we can move the rest of the code to apimachinery repository, so that later we can use it from both the client and the server.

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

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```
2017-11-02 11:17:33 -07:00
Antoine Pelisse 8f7262e819 Update kube-openapi to use validation 2017-11-02 09:25:03 -07:00
wackxu 7a05ecd046 should check and return err when visit failure 2017-11-02 20:15:34 +08:00
tengqm 6eacd341d1 Fix kubectl autoscale help message 2017-11-02 17:05:45 +08:00
Cao Shufeng 26032ad6f8 [cli] exit when Validate() return an error
cmdutil.UsageErrorf() does nothing but return a string. When Validate()
returns an error, we should call exit() function.
2017-11-02 14:51:28 +08:00
Kubernetes Submit Queue d595003e0d
Merge pull request #54449 from smarterclayton/get_with_options
Automatic merge from submit-queue (batch tested with PRs 54895, 54449). 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 the get command to follow more conventions of commands

Pure code movement, builds on top of #54446 and only the last commit is new. Will make refactoring get easier.
2017-11-01 21:25:12 -07:00
Mengqi Yu b518a80cef add test for convert 2017-11-01 01:14:24 -07:00
Mengqi Yu 44aa7116e4 switch convert to use pkg/api/legacyscheme 2017-11-01 00:20:50 -07:00
Kubernetes Submit Queue 7f9f847ce9
Merge pull request #54406 from superbrothers/kubectl-override-short-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>.

Improve 'kubectl completion` to override short flags

**What this PR does / why we need it**: This PR improves `kubectl completion` to override short flags in
addition to long flags. I tested this PR in both bash and zsh.

```
# Complete pods name in the `default` namespace
$ kubectl get po nginx-4217019353-<tab>
nginx-4217019353-mw1pk  nginx-4217019353-rzw2c

# Complete pods name in the `kube-system` namepace due to overriding the namespace
$ kubectl -n kube-system get po kube<tab>
kube-addon-manager-minikube  kube-dns-910330662-l9pwt     kubernetes-dashboard-9fbhm
```

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-10-31 22:32:54 -07:00
Kubernetes Submit Queue ed00d9c062
Merge pull request #54445 from crimsonfaith91/rem
Automatic merge from submit-queue (batch tested with PRs 53190, 54790, 54445, 52607, 54801). 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>.

remove created-by annotation

**What this PR does / why we need it**:
This PR removes `CreatedByAnnotation`.

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

**Release note**:

```release-note
The `kubernetes.io/created-by` annotation is no longer added to controller-created objects. Use the  `metadata.ownerReferences` item that has `controller` set to `true` to determine which controller, if any, owns an object.
```
2017-10-31 20:10:21 -07:00
YuxiJin-tobeyjin 655d734138 Add complementary unittest for kubectl logs 2017-11-01 10:35:50 +08:00
Clayton Coleman 1d066f3c35
Update the get command to follow more conventions
Simplify some complicated steps in the command by splitting out code
into smaller chunks.
2017-10-31 22:20:14 -04:00
Kubernetes Submit Queue 037b8ab8b3
Merge pull request #54446 from smarterclayton/cleanup_get
Automatic merge from submit-queue (batch tested with PRs 54446, 54202). 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>.

Create a new package for generic commands like get

This is in preparation for cleaning up the structure of `kubectl get` to ease implementing serverside get and streaming API responses. Moves a hardcoded constant into a method in preparation for a future serverside implementation. Also improves some existing description text.
2017-10-31 15:51:23 -07:00
Kubernetes Submit Queue 7efc6c83f0
Merge pull request #54046 from hzxuzhonghu/kubectl-apply
Automatic merge from submit-queue (batch tested with PRs 54326, 54046). 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>.

kubectl apply does not send empty patch request

**What this PR does / why we need it**:
`kubectl apply -f filename` always send patch request to apiserver, whether the file changed or not.

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-10-31 14:13:20 -07:00
Kubernetes Submit Queue a7a0a63f16
Merge pull request #54820 from sjevs/test/issue-54645-kubectl-apply-view-last-applied
Automatic merge from submit-queue (batch tested with PRs 54774, 54820, 52192, 54827). 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>.

Added a test for proper `%s` handling when display last applied confi…

**What this PR does / why we need it**:
Added missing tests which checks proper handling of `%s` in arguments for command `kubectl apply view-last-applied`

**Which issue this PR fixes**
#54645

**Special notes for your reviewer**:
Added a test case to cover specific issue described. 
It fails on version `v1.7.3`..`v1.7.9` and passes since `v1.8.0`. 

P.S. Not sure if there is already a lower level test which covers this case in the k8s test suite. I would recommend to add this test, so the issue would not reoccur.

**Release note**:
```release-note
NONE
```
2017-10-31 13:22:18 -07:00
zhengjiajin fe0f461cea remove dependency from top command 2017-10-31 16:15:32 +08:00
Kubernetes Submit Queue f46f0efd31
Merge pull request #54572 from ellenkorbes/ellenmakesamess
Automatic merge from submit-queue (batch tested with PRs 54572, 54686). 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>.

kubectl partial env docs & examples

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

It adds documentation and examples to kubectl env.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: This PR partially addresses [#98](https://github.com/kubernetes/kubectl/issues/98).

**Special notes for your reviewer**:

This is a partial PR. I'm mostly looking for feedback as to whether I'm on the right track with this issue. Any feedback is appreciated. Thanks.

(This is my contribution to Outreachy's Kubernetes internship application.)

**Release note**:


```release-note
NONE
```
2017-10-30 21:45:14 -07:00
Clayton Coleman 93fed120fb
Move printing the valid resource types to a function
Should be calculated from discovery in the future. Also improve
descriptions on the affected commands.
2017-10-30 23:45:45 -04:00
Kubernetes Submit Queue 127dc0653f
Merge pull request #54818 from apelisse/propagate-error-diff
Automatic merge from submit-queue (batch tested with PRs 54728, 54818). 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>.

diff: Propragate errors when diffing

Because of that, errors while diffing would potentially not do anything,
leaving the user clueless of what was going on.

**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 #

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```
2017-10-30 20:29:18 -07:00
Clayton Coleman 55fdceca93
Move get into its own package 2017-10-30 21:55:39 -04:00
Kubernetes Submit Queue 812f1a3edb
Merge pull request #54533 from mengqiy/kubectl_scheme
Automatic merge from submit-queue (batch tested with PRs 54533, 54777, 54763, 54806, 54703). 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>.

Create kubectl's own instance of Scheme and Registry

Create kubectl's own instance of Registry and Scheme.
Switch most command that doesn't depend on internal types to use kubectl's own scheme and register.

There are some hack of registering the internal types in some of unit test now, they should be gone after switch to the external type.

Switch kubectl's factory code to use kubectl's scheme will create a lot of ripples.
I don't want make this PR a super giant PR, so I will do it in a followup PR.

Partially addressed #48564.

Copy the summary from https://github.com/kubernetes/kubernetes/pull/54533#issuecomment-340522302:
- creates pkg/kubectl/scheme (install.go and scheme.go) with
deps on properly vendored k8s.io packages.
- deletes about 80% percent of dependence on pkg/api/legacyscheme
- replaces direct dependence from pkg/kubectl on
pkg/apis/rbac
to a vendor style dependence on
k8s.io/api/rbac
and removes dependencies on rbac paths containing internalversion
- replaces almost 50% of direct dependence on pkg/api with (properly vendored)
k8s.io/api/core/v1
- deletes all of dependence on pkg/apis/policy and k8s.io/api/policy/v1beta1

```release-note
NONE
```

/assign @monopole @apelisse
cc: @pwittrock
2017-10-30 17:38:14 -07:00
Sergej Jevsejev c5bdd1da15 Added a test for proper `%s` handling when display last applied configuration 2017-10-30 23:03:10 +01:00
Antoine Pelisse b916739d4f diff: Propragate errors when diffing
Because of that, errors while diffing would potentially not do anything,
leaving the user clueless of what was going on.
2017-10-30 14:16:36 -07:00
Kubernetes Submit Queue 81b1fa4588
Merge pull request #53796 from lichuqiang/kubectl_fix_1
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>.

Fix print format of rootScoped resourced in kubectl

**What this PR does / why we need it**:
remove _NAMESPACE_ filed when querying rootScoped resource with kubectl

**Which issue this PR fixes**

fixes #53767

**Special notes for your reviewer**:
/cc @smarterclayton 


**Release note**:
```release-note
NONE
```
2017-10-30 13:47:56 -07:00
Jun Xiang Tee efbfead4ef remove created-by annotation 2017-10-30 12:49:44 -07:00
Kubernetes Submit Queue 12e5db561e
Merge pull request #53768 from smarterclayton/chunking_cli
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>.

Support api chunking in kubectl get

This enables chunking in the resource builder to make it easy to
retrieve resources in pages and visit partial result sets. This adds
`--chunk-size` to `kubectl get` only so that users can get comfortable
with the use of chunking in beta. Future changes will enable chunking
for all CLI commands so that bulk actions can be performed more
efficiently.

```
$ kubectl get pods --all-namespaces
... print batch of 500 pods ...
... print second batch of 500 pods ...
...
```

@kubernetes/sig-cli-pr-reviews @kubernetes/sig-api-machinery-pr-reviews

```release-note
`kubectl get` will by default fetch large lists of resources in chunks of up to 500 items rather than requesting all resources up front from the server. This reduces the perceived latency of managing large clusters since the server returns the first set of results to the client much more quickly.  A new flag `--chunk-size=SIZE` may be used to alter the number of items or disable this feature when `0` is passed.  This is a beta feature.
```
2017-10-29 15:59:54 -07:00
Ellen Körbes 413eaecf32 Added comments & examples/tests to kubectl env package 2017-10-29 20:23:20 -02:00
ymqytw 4487cc5e15 switch some commands to use its own scheme 2017-10-27 18:31:42 -07:00
hzxuzhonghu c5c56dcf35 kubectl apply does not send empty patch request 2017-10-28 09:12:57 +08:00
Clayton Coleman 4780ad0297
Support api chunking in kubectl get
This enables chunking in the resource builder to make it easy to
retrieve resources in pages and visit partial result sets. This adds
`--chunk-size` to `kubectl get` only so that users can get comfortable
with the use of chunking in beta. Future changes will enable chunking
for all CLI commands so that bulk actions can be performed more
efficiently.
2017-10-27 17:23:36 -04:00
Kubernetes Submit Queue 51652d1c23 Merge pull request #53816 from marun/remove-federation
Automatic merge from submit-queue (batch tested with PRs 54112, 54150, 53816, 54321, 54338). 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>.

Remove federation

This PR removes the federation codebase and associated tooling from the tree.

The first commit just removes the `federation` path and should be uncontroversial.  The second commit removes references and associated tooling and suggests careful review.

Requirements for merge:

- [x] Bazel jobs no longer hard-code federation as a target ([test infra #4983](https://github.com/kubernetes/test-infra/pull/4983))
- [x] `federation-e2e` jobs are not run by default for k/k

**Release note**:

```release-note
Development of Kubernetes Federation has moved to github.com/kubernetes/federation.  This move out of tree also means that Federation will begin releasing separately from Kubernetes.  The impact of this is Federation-specific behavior will no longer be included in kubectl, kubefed will no longer be released as part of Kubernetes, and the Federation servers will no longer be included in the hyperkube binary and image.
```

cc: @kubernetes/sig-multicluster-pr-reviews @kubernetes/sig-testing-pr-reviews
2017-10-26 17:07:28 -07:00
Maru Newby adc338d330 Remove all traces of federation 2017-10-26 13:37:37 -07:00
zhengjiajin dd9ab89e31 fix issue(#52994)kubectl set resource can not update multi resource in local 2017-10-26 15:33:22 +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
Kubernetes Submit Queue 6ba5f77d5d Merge pull request #53920 from apelisse/diff
Automatic merge from submit-queue (batch tested with PRs 53051, 52489, 53920). 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>.

Implement `kubectl alpha diff` to diff resources

`kubectl alpha diff` lets you diff your resources against live
resources, or last applied, or even preview what changes are going to be
applied on the cluster.

This is still quite premature, and mostly untested.

**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 #

**Special notes for your reviewer**:

**Release note**:
Clearly not ready for Release note.
```release-note
NONE
```

kubernetes/community#287
2017-10-24 21:38:23 -07:00
Kubernetes Submit Queue 8f79857b42 Merge pull request #54094 from juanvallejo/jvallejo/exit-plugin-cmd-w-correct-exit-code
Automatic merge from submit-queue (batch tested with PRs 54107, 54184, 54377, 54094, 54111). 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>.

exit with correct exit code on plugin failure

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

Correctly exits after a plugin command execution failure with the correct exit code.
Related downstream bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1501756

**Before**
```
$ kubectl plugin will-fail-plugin
ls: cannot access 'does-not-exist': No such file or directory
error: exit status 2

$ echo $?
1
```

**After**
```
$ kubectl plugin will-fail-plugin
ls: cannot access 'does-not-exist': No such file or directory
error: exit status 2

$ echo $?
2
```

cc @fabianofranz
2017-10-24 15:59:13 -07:00
Kubernetes Submit Queue 2ad7d6f711 Merge pull request #54083 from juanvallejo/jvallejo/update-resource-builder-cmd-drain
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 resource selector - kubectl drain

Followup to https://github.com/kubernetes/kubernetes/pull/52917

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

Updates resource builder in cmd/drain.go to parse resource args similar to other commands.

cc @liggitt
2017-10-24 14:16:39 -07:00
Kubernetes Submit Queue 39218a1b44 Merge pull request #54270 from WanLinghao/set_command_fix
Automatic merge from submit-queue (batch tested with PRs 54270, 54479). 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>.

fix kubectl set command

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

1. fix some errors in 'kubectl set' series command

2.remove unused function in kubectl set env command

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

**Special notes for your reviewer**:

**Release note**:

```
NONE
```
2017-10-24 11:52:04 -07:00
Kubernetes Submit Queue f7dbe30f2b Merge pull request #54373 from dims/better-error-check-for-cluster-info
Automatic merge from submit-queue (batch tested with PRs 53479, 54373, 54441, 54443). 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>.

Better error check for kubectl cluster-info

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

In RunClusterInfo, We try to connect to the api service and get some
information, but we just ignore the errors from Do().Visit(). We should
return the error returned by Do().Visit() so the "kubectl cluster-info"
would fail correctly with an error code.
In RunClusterInfo, We try to connect to the api service and get some
information, but we just ignore the errors from Do().Visit(). We should
return the error returned by Do().Visit() so the "kubectl cluster-info"
would fail correctly with an error code.

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-10-23 18:39:05 -07:00
Kubernetes Submit Queue 6949b518d6 Merge pull request #54245 from deads2k/cli-03-postraw
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>.

add kubectl create --raw -f

Adds `--raw` to `kubectl create` to match `kubectl get --raw`.  It re-uses the transport, reads the input stream (stdin or a single file for now) and posts directly to the endpoint specified.  This let's you direct data directly at a subresource (as a for instance).  I'd like to see this extended to `kubectl replace` too, so that we have full access to subresources via scripting without having to reproduce the transports.

@kubernetes/sig-cli-pr-reviews 

```release-note
add `--raw` to `kubectl create` to POST using the normal transport
```
2017-10-23 17:16:01 -07:00
Kubernetes Submit Queue ca8d97d673 Merge pull request #53743 from DirectXMan12/feature/polymorphic-scale-client
Automatic merge from submit-queue (batch tested with PRs 53743, 53564). 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>.

Polymorphic Scale Client

This PR introduces a polymorphic scale client based on discovery information that's able to scale scalable resources in arbitrary group-versions, as long as they present the scale subresource in their discovery information.

Currently, it supports `extensions/v1beta1.Scale` and `autoscaling/v1.Scale`, but supporting other versions of scale if/when we produce them should be fairly trivial.

It also updates the HPA to use this client, meaning the HPA will now work on any scalable resource, not just things in the `extensions/v1beta1` API group.

**Release note**:
```release-note
Introduces a polymorphic scale client, allowing HorizontalPodAutoscalers to properly function on scalable resources in any API group.
```

Unblocks #29698
Unblocks #38756
Unblocks #49504 
Fixes #38810
2017-10-23 13:39:07 -07:00
Antoine Pelisse 011a45cde7 Implement `kubectl alpha diff` to diff resources
`kubectl alpha diff` lets you diff your resources against live
resources, or last applied, or even preview what changes are going to be
applied on the cluster.

This is still quite premature, and mostly untested.
2017-10-23 10:49:02 -07:00
David Eads 58f39a15de add kubectl create --raw -f 2017-10-23 12:50:46 -04:00
Davanum Srinivas 998f33272d Better error check for kubectl cluster-info
In RunClusterInfo, We try to connect to the api service and get some
information, but we just ignore the errors from Do().Visit(). We should
return the error returned by Do().Visit() so the "kubectl cluster-info"
would fail correctly with an error code.
2017-10-22 19:46:13 -04:00
Kazuki Suda d2816bc1ba Improve 'kubectl completion` to override short flags
This commit improves `kubectl completion` to override short flags in
addition to long flags.
2017-10-22 13:18:44 +09:00
Kubernetes Submit Queue 9403fcc9c7 Merge pull request #54024 from pwittrock/resource-validation-deps
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>.

kubectl resource builder to use versioned list

Switch to using a versioned listed when return an object from the resource builder.

This is necessary to allow cli's built outside the kubernetes/kubernetes repo to vendor the resource builder logic without vendoring all of Kubernetes.

The following commands call the modified function.  (identified by changing the function name and recompiling)

- [x] `attach`
  - pkg/kubectl/cmd/attach.go:155: builder.Do().Object
  - passes to `AttachablePodForObject` which does not support Lists of any kind
- [x] `get`
  - pkg/kubectl/cmd/get.go:251: r.Object
  - [x] check if isList with `IsListType` -> `GetItemsPtr` -> check for presence of `Items` field
  - [x] pass to `ResourceVersion` -> `CommonAccessor` -> checks for `metav1.ListInterface` (which this PR introduces a compile time check to ensure v1.List implements this)
  - [x] pass to `ExtractList` -> checks if items implement `runtime.RawExtension`
- [x] `rolling_update`
  - pkg/kubectl/cmd/rollingupdate.go:207: request.Object
  - only accepts lists of length 1.  updated in PR to support both api.List and v1.List
- [x] `rollout_status`
  - pkg/kubectl/cmd/rollout/rollout_status.go:107: r.Object
  - passes to `ResourceVersion` -> `CommonAccessor` -> checks for `metav1.ListInterface`

```release-note
NONE
```

Closes kubernetes/kubectl#81
2017-10-20 21:31:10 -07:00
Kubernetes Submit Queue 507790c9c6 Merge pull request #54181 from apelisse/update-kube-openapi
Automatic merge from submit-queue (batch tested with PRs 54199, 54181, 54196). 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 openapi to use kube-openapi code

**What this PR does / why we need it**: OpenAPI code has moved to `github.com/kubernetes/kube-openapi`. Let's use that code as a dependency, since now it's duplicated.

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

**Special notes for your reviewer**:

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

No user visible changes. Just code moving around.
2017-10-20 18:57:03 -07:00
Kubernetes Submit Queue 67e9fb6288 Merge pull request #53916 from juanvallejo/jvallejo/update-dockercfg-data
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 .dockercfg content to config.json

update the data format of .dockercfg to match the new docker config.json
format, which encapsulates all registry auth objects in an overall
"auths" object when an option `--config-format` is specified with the value
`--config-format=config.json`:

```
{
    "auths": {
        "reg.url": {
            "auth": "...=="
        }
    }
}
```

**Release note**:
```release-note
secret data containing Docker registry auth objects is now generated using the config.json format
```

cc @bparees @fabianofranz
2017-10-20 10:37:26 -07:00
Kubernetes Submit Queue d7eebdfdbe Merge pull request #54113 from spzala/groupkindvalidationtest
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>.

Create new unit tests for version and kind validation

This is a follow up PR per discussion in the
https://github.com/kubernetes/kubernetes/pull/53587
Creating new unit tests here for basic and aggregated validation of version
and kind group.



**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 #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-10-20 09:29:24 -07:00
Antoine Pelisse 3ed58475c4 Update openapi to use kube-openapi code 2017-10-20 09:21:06 -07:00
WanLinghao c79aba664b fix some small errors in 'kubectl set' series command
modified:   pkg/kubectl/cmd/set/set_env.go
modified:   pkg/kubectl/cmd/set/set_serviceaccount.go
modified:   pkg/kubectl/cmd/set/set_subject.go
2017-10-20 12:48:34 +08:00
Solly Ross eac2049fc9 [client-go] avoid Registry in fake REST client
Previously, the fake RESTClient in client-go required a Registry.  It
used the Registry to fetch the GroupVersion for the fake client.
However, the way it did so was dubious in some cases (it hard-coded the
default API group in places), and not strictly necssary.

This updates the fake client to just recieve the GroupVersion and
internal group name directly, instead of requiring a Registry, so that
it can be consumed in unit tests where a Registry isn't necessarily
readily available (e.g. elsewhere in client-go).
2017-10-19 11:01:44 -04:00
juanvallejo ee2f9c95e7
update resource selector - kubectl drain 2017-10-19 10:10:06 -04:00
Kubernetes Submit Queue eb041b00ea Merge pull request #53609 from juanvallejo/jvallejo/set-user-specified-ns-dry-run-create
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>.

add user-specified  ns to --dry-run created obj

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

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

Includes a namespace in a created resource's metadata when `--dry-run` is used if:
- a namespace was explicitly set by the user (via `--namespace`)
- No errors occur accessing the object's metadata

cc @fabianofranz @deads2k
2017-10-19 00:24:42 -07:00
Kubernetes Submit Queue 29d2f15c9e Merge pull request #47636 from xiangpengzhao/some-cleanup
Automatic merge from submit-queue (batch tested with PRs 51310, 51458, 47636). 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>.

Clean up some service related description

**What this PR does / why we need it**:
As per the review comment https://github.com/kubernetes/kubernetes/pull/47250#discussion_r121162426, send this cleanup PR.

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

**Special notes for your reviewer**:
since this is minor cleanup, there is no related issue. see https://github.com/kubernetes/kubernetes/pull/47250#discussion_r121162426

**Release note**:

```release-note
NONE
```
2017-10-18 20:47:10 -07:00
juanvallejo 96d3f4552f
exit with correct exit code on plugin failure 2017-10-18 19:01:29 -04:00
juanvallejo 027c8b9ef2
update .dockercfg content to config.json
update the data format of .dockercfg to match the new docker config.json
format, which encapsulates all registry auth objects in an overall
"auths" object:

{
    "auths": {
        "reg.url": {
            "auth": "...=="
        }
    }
}
2017-10-18 14:33:14 -04:00
Kubernetes Submit Queue 2d914ee703 Merge pull request #53984 from sttts/sttts-legacyscheme
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>.

pkg/api: extract Scheme/Registry/Codecs into pkg/api/legacyscheme

This serves as

- a preparation for the pkg/api->pkg/apis/core move
- and makes the dependency to the scheme explicit when vizualizing
  left depenncies.

The later helps with our our efforts to split up the monolithic repo
into self-contained sub-repos, e.g. for kubectl, controller-manager
and kube-apiserver in the future.
2017-10-18 10:49:10 -07:00
Phillip Wittrock fd169a6218 Switch to v1.List instead of allowing the conversion fn to be provided. 2017-10-18 09:30:46 -07:00
Dr. Stefan Schimanski cad0364e73 Update bazel 2017-10-18 17:24:04 +02:00