Commit Graph

3455 Commits (f98bc7d45435d0a48a48178ebe439296c554fb4c)

Author SHA1 Message Date
Mike Danese a05c3c0efd autogenerated 2017-04-14 10:40:57 -07:00
Cao Shufeng a6db26d5b7 Reorganize the output of "kubectl get -o json"
"resourceVersion" and "selfLink" are members of "metadata" rather than
the list. This change reorganize the struct to provide consistency with
other places.

Before this change:
    "kind": "List",
    "metadata": {},
    "resourceVersion": "",
    "selfLink": ""
After this change:
    "kind": "List",
    "metadata": {
        "resourceVersion": "",
        "selfLink": ""
    }

Reference:
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/types.go#L57
2017-04-14 11:08:34 +08:00
Kubernetes Submit Queue ab22baf94d Merge pull request #44299 from caesarxuchao/move-ref.go
Automatic merge from submit-queue (batch tested with PRs 44406, 41543, 44071, 44374, 44299)

Move pkg/api/ref.go to a subpackage

First commit is #44296. (unfortunately, removing that commit results in conflicts)

This PR moves the pkg/api/ref.go to its own subpackage. It's mostly a mechanic move.

I'll send a few more PRs to make the k8s.io/kubernetes/pkg/api package only contains the code we want in the k8s.io/api repo, then we can run a [script](a0015fd1be (diff-7a2fbb4371972350ee414c6b88aee1c8)) to cut the new repo.
2017-04-13 19:52:11 -07:00
Kubernetes Submit Queue 4653a9b280 Merge pull request #41543 from dshulyak/decouple_remotecommand
Automatic merge from submit-queue (batch tested with PRs 44406, 41543, 44071, 44374, 44299)

Decouple remotecommand

Refactored unversioned/remotecommand to decouple it from undesirable dependencies:

- term package now is not required, and functionality required to resize terminal size can be plugged in directly in kubectl
- in order to remove dependency on kubelet package - constants from kubelet/server/remotecommand were moved to separate util package (pkg/util/remotecommand)
- remotecommand_test.go moved to pkg/client/tests module
2017-04-13 19:52:05 -07:00
Kubernetes Submit Queue 9f92832fad Merge pull request #43942 from wanghaoran1988/fix_43323
Automatic merge from submit-queue (batch tested with PRs 44447, 44456, 43277, 41779, 43942)

Clean up pre-ControllerRef compatibility logic

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

**Special notes for your reviewer**:
No
**Release note**:

```
NONE
```
2017-04-13 15:02:03 -07:00
Kubernetes Submit Queue d2733394ca Merge pull request #42144 from xilabao/add-resource-validate
Automatic merge from submit-queue

add validate to resource in can-i

```
#kubectl auth can-i get xxx
the server doesn't have a resource type "xxx"
```
2017-04-13 11:43:05 -07:00
Chao Xu d9920c53a5 move ref.go to its own subpackage 2017-04-13 10:02:43 -07:00
Kubernetes Submit Queue c3463d737e Merge pull request #44251 from superbrothers/completion-cluster-user-flags
Automatic merge from submit-queue

Support completion for --cluster and --user

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

kubectl is supported completion for `--cluster` and `--user`.

```
$ kubectl --user=<tab>
--user=minikube  --user=user01

$ kubectl --cluster=<tab>
--cluster=cluster01  --cluster=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
Add completion support for --namespace and --cluster to kubectl
```
2017-04-13 08:42:04 -07:00
Dmitry Shulyak f50480c714 Decouple remotecommand client from term/kubelet dependencies
In order to move client/unversioned/remotecommand to client-go as a followup
for this change we have to decouple it from tons of dependencies
2017-04-13 15:56:40 +03:00
Kubernetes Submit Queue 45dc1539f3 Merge pull request #44416 from ivan4th/fix-kubectl-crash
Automatic merge from submit-queue

Fix crash in kubectl run

I observed the problem in k8s 1.5.1, but the code is still there, so fixing it.
Here's the old backtrace - happened due to network disconnection during `kubectl run`:

```
ivan4th@i4mac:~$ kubectl run --rm -it alpine1 --image=alpine:3.5 --restart=Never /bin/sh
Waiting for pod default/alpine1 to be running, status is Pending, pod ready: false
If you don't see a command prompt, try pressing enter.
/ # panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xe8706]

goroutine 1 [running]:
panic(0x11e0d80, 0xc420016090)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
k8s.io/kubernetes/pkg/kubectl/cmd.waitForPod.func2(0xc400000008, 0x14783a0)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/run.go:432 +0x126
k8s.io/kubernetes/pkg/util/interrupt.(*Handler).Run(0xc420379230, 0xc4206c11f0, 0x0, 0x0)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/util/interrupt/interrupt.go:103 +0x109
k8s.io/kubernetes/pkg/kubectl/cmd.waitForPod(0x208c8c0, 0xc4204832c0, 0xc4204395d0, 0x7, 0xc4204395a0, 0x7, 0x1477e10, 0xc4206e6040, 0x0, 0x0, ...)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/run.go:434 +0x49e
k8s.io/kubernetes/pkg/kubectl/cmd.waitForPodTerminated(0x208c8c0, 0xc4204832c0, 0xc4204395d0, 0x7, 0xc4204395a0, 0x7, 0x1c48020, 0xc42002c010, 0xc420124300, 0x0, ...)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/run.go:458 +0xea
k8s.io/kubernetes/pkg/kubectl/cmd.Run(0x1c61040, 0xc4203106e0, 0x1c47fe0, 0xc42002c008, 0x1c48020, 0xc42002c010, 0x1c48020, 0xc42002c018, 0xc42047e6c0, 0xc42006d200, ...)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/run.go:304 +0xe37
k8s.io/kubernetes/pkg/kubectl/cmd.NewCmdRun.func1(0xc42047e6c0, 0xc42006d200, 0x2, 0x6)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/run.go:98 +0x144
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute(0xc42047e6c0, 0xc42006d140, 0x6, 0x6, 0xc42047e6c0, 0xc42006d140)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:603 +0x439
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc4204dbb00, 0xc420438e50, 0x1, 0x1)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:689 +0x367
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute(0xc4204dbb00, 0xc4203106e0, 0x1c47fe0)
        /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:38 +0xd5
main.main()
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubectl/kubectl.go:26 +0x22
```
2017-04-13 05:56:14 -07:00
Kubernetes Submit Queue 19d722671b Merge pull request #43297 from mvdan/kubectl-params
Automatic merge from submit-queue

kubectl/cmd: remove a bunch of unused parameters

Found with github.com/mvdan/unparam.

**Release note**: NONE
2017-04-13 04:07:21 -07:00
Ivan Shvedunov b62af04f7f Fix crash in kubectl run 2017-04-13 01:00:50 +03:00
Chao Xu 08aa712a6c move helpers.go to helper 2017-04-11 15:49:11 -07:00
Kubernetes Submit Queue 785299eea5 Merge pull request #43490 from xingzhou/add-testcases
Automatic merge from submit-queue (batch tested with PRs 43304, 41427, 43490, 44352)

Supplement unit tests to `kubectl create rolebinding` command.

Supplement unit tests to `kubectl create rolebinding` command,
including:
1. Unit tests for pkg/kubectl/role.go
2. Unit tests for pkg/kubectl/cmd/create_role.go
2017-04-11 13:46:16 -07:00
Kubernetes Submit Queue 867159416f Merge pull request #44293 from deads2k/api-08-unstructureditems
Automatic merge from submit-queue (batch tested with PRs 43545, 44293, 44221, 43888)

make unstructured items correspond to other items for storage

"normal" `Items` elements include the struct itself, not a pointer to the struct.  Some of the deeper bits of storage rely on this behavior in reflective paths.

This updates the `UnstructuredList` to be "normal".

@kubernetes/sig-api-machinery-pr-reviews
2017-04-11 12:18:20 -07:00
Kubernetes Submit Queue da1fe12133 Merge pull request #43900 from CaoShuFeng/cani-quiet
Automatic merge from submit-queue (batch tested with PRs 43900, 44152, 44324)

fix return value of "kubectl auth cani --quiet"

Before this change:
$ kubectl auth can-i get pod
no
$ kubectl auth can-i get pod --quiet
$ echo $?
0

After this change:
$ kubectl auth can-i get pod
no
$ kubectl auth can-i get pod --quiet
$ echo $?
1

@deads2k 

**Release note**:

```NONE
```
2017-04-11 07:57:13 -07:00
deads2k 706823aaa8 make unstructured items correspond to other items for storage 2017-04-11 08:44:16 -04:00
Xing Zhou a08ad42848 Fixed `kubectl cluster-info dump` to support multi-container pod.
Fixed `kubectl cluster-info dump` to support multi-container pod.
2017-04-11 10:53:30 +08:00
Derek Carr 9c956c2170 Allow the usage of kubectl logs with label selector and container name 2017-04-10 13:14:47 -04:00
zhengjiajin 420da81a4b add kubectl config view test code 2017-04-10 19:36:42 +08:00
Cao Shufeng 877bf54465 add "bind" and "impersonate" to legal verbs
"bind" and "impersonate" are also legal verbs according this:
https://github.com/kubernetes/kubernetes.github.io/pull/2771/files
2017-04-10 03:46:04 -04:00
Kazuki Suda 2b1078e61e Support completion for --cluster and --user
With this commit, kubectl is supported completion for `--cluster` and `--user`.

```
$ kubectl --user=<tab>
--user=minikube  --user=user01

$ kubectl --cluster=<tab>
--cluster=cluster01  --cluster=minikube
```
2017-04-09 15:11:21 +09:00
Kubernetes Submit Queue 0a7fa6926a Merge pull request #42336 from superbrothers/context-completion-for-config-use-context
Automatic merge from submit-queue (batch tested with PRs 44119, 42538, 43802, 42336, 43396)

Support context completion for kubectl config use-context

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

With this PRt, kubectl is supported context completion for config use-context.

```
$ ./kubectl config use-context
cluster01  minikube
```

/ref  #42103 

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

#29386

**Special notes for your reviewer**:

**Release note**:

```release-note
```
2017-04-07 14:09:40 -07:00
Kubernetes Submit Queue bf766f48a6 Merge pull request #42538 from adohe/context_warning
Automatic merge from submit-queue (batch tested with PRs 44119, 42538, 43802, 42336, 43396)

print warning when delete current context

mirror update to kubectl. fix #42012 @smarterclayton ptal.

**Release Note**:
```
print warning when delete current context
```
2017-04-07 14:09:36 -07:00
Haoran Wang 866c599198 Clean up pre-ControllerRef compatibility logic 2017-04-07 14:09:23 +08:00
Brendan Burns 79f51923d3 Extract a bunch more strings from kubectl 2017-04-06 20:12:50 -07:00
Kubernetes Submit Queue 3160d7287d Merge pull request #43903 from xilabao/use-StringArray-for-user
Automatic merge from submit-queue (batch tested with PRs 44104, 43903, 44109)

use StringArray in create rolebindings

@liggitt I think maybe you like this.

```release-note
`kubectl create rolebinding` and `kubectl create clusterrolebinding` no longer allow specifying multiple subjects as comma-separated arguments. Use repeated `--user`, `--group`, or `--serviceaccount` arguments to specify multiple subjects. 
```
2017-04-05 17:43:26 -07:00
xilabao 33e55972f4 use StringArray in create rolebindings 2017-04-05 18:44:45 +08:00
Kubernetes Submit Queue 89875ccb40 Merge pull request #43514 from zjj2wry/006
Automatic merge from submit-queue (batch tested with PRs 44047, 43514, 44037, 43467)

unit test for kubectl config use-context

**What this PR does / why we need it**:
unit test for kubectl config use-context

**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**:
think you

**Release note**:

```release-note
```
2017-04-04 14:33:22 -07:00
Daniel Martí 810dbc5e98 kubectl/cmd: remove a bunch of unused parameters
Found with github.com/mvdan/unparam.
2017-04-04 10:36:30 +01:00
Kubernetes Submit Queue e9a91b8cca Merge pull request #44020 from tpot/kubectl-cmdline-spelling-fix
Automatic merge from submit-queue (batch tested with PRs 42674, 43937, 44020)

Fix spelling of 'arguments' for kubectl create authinfo

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

Fixes a silly spelling mistake in help output.

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

**Special notes for your reviewer**:

I've signed the CLA but don't fully understand the PR process yet.  I guess the "cla:yes" label gets added by someone else or automatically by a bot?

**Release note**:

```release-note
NONE
```
2017-04-04 00:53:16 -07:00
zhangxiaoyu-zidif 932ece5cfd e3d534b2c4 2017-04-04 14:16:34 +08:00
Tim Potter 1e4c93a0f8 Fix spelling of 'arguments' for kubectl create authinfo 2017-04-04 15:17:55 +10:00
Kubernetes Submit Queue 1df2363093 Merge pull request #42999 from shiywang/fix-return0
Automatic merge from submit-queue (batch tested with PRs 43450, 42999, 43968)

fix kubectl config return 0 on error

Fixes https://github.com/kubernetes/kubernetes/issues/42852
cc @kubernetes/sig-cli-bugs
@ymqytw ptal
2017-04-03 09:48:23 -07:00
Kubernetes Submit Queue 2d646e0c29 Merge pull request #43450 from zjj2wry/003
Automatic merge from submit-queue (batch tested with PRs 43450, 42999, 43968)

unit test for kubectl config set-context

**What this PR does / why we need it**:
unit test for create context

**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**:
think you 

**Release note**:

```release-note
NONE
```
2017-04-03 09:48:21 -07:00
xilabao 53f2c2753f add a warning to the resource check 2017-04-03 09:43:31 +08:00
Cao Shufeng 70a2643fdf fix return value of "kubectl auth cani --quiet"
Before this change:
$ kubectl auth can-i get pod
no
$ kubectl auth can-i get pod --quiet
$ echo $?
0

After this change:
$ kubectl auth can-i get pod
no
$ kubectl auth can-i get pod --quiet
$ echo $?
1
2017-03-31 07:40:48 -04:00
zhengjiajin 56c1baae01 unit test for kubectl config use-context 2017-03-31 13:29:52 +08:00
ymqytw 8d14b19cd7 check error 2017-03-30 17:47:18 -07:00
Kubernetes Submit Queue 9ba2a401bb Merge pull request #43207 from xilabao/add-can-i-example
Automatic merge from submit-queue

add can-i example

use * can check if the admin user or not.
2017-03-30 08:42:17 -07:00
xilabao 1833602bf8 add can-i example 2017-03-30 09:39:03 +08:00
Kubernetes Submit Queue 8fc0c708d1 Merge pull request #43509 from xilabao/remove-duplicate-in-create-rolebinding
Automatic merge from submit-queue (batch tested with PRs 42617, 43247, 43509, 43644, 43820)

ignore duplicate resource in create rolebinding
2017-03-29 16:05:23 -07:00
Xing Zhou 65b5b51c82 Supplement unit tests to `kubectl create rolebinding` command.
Supplement unit tests to `kubectl create rolebinding` command,
including:
1. Unit tests for pkg/kubectl/role.go
2. Unit tests for pkg/kubectl/cmd/create_role.go
2017-03-29 16:36:22 +08:00
Kubernetes Submit Queue c0497fc278 Merge pull request #43518 from zjj2wry/008
Automatic merge from submit-queue

unit test for kubectl config unset

**What this PR does / why we need it**:
unit test for kubectl config unset

**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**:
think you 

**Release note**:

```release-note
```
2017-03-28 13:51:54 -07:00
Alejandro Escobar a5e6dcb434 addressing issue #39427 adding a flag --output to allow for either json or yaml.
updating with PR changes requested.

latest changes to having short for human readable only, and error cases moved a bit to the end.

rebase fixes

latest pr. changes.

small change moving return nil out of switch.

updated the nil check for the error in the humanreadable case.

more optimization in humanreadable code.

pushed up current test changes, this is purely temporary

finished writing tests

updated test and function names.

changed output extensions from .sh to output.

updated version, version struct now just called Version and not VersionObj.

made a few changes to testing.

fixed testing issues, created better test and cleanup

go format change.
2017-03-28 10:07:53 -07:00
Kubernetes Submit Queue f14618a56b Merge pull request #43622 from deads2k/cli-10-category
Automatic merge from submit-queue (batch tested with PRs 42087, 43383, 43622)

move category expansion out of restmapper

RESTMapping isn't related to CategoryExpansion (the bit that expands "all" into items to be RESTMapped).  This provides that separation and simplifies the RESTMapper interface.

@kubernetes/sig-cli-pr-reviews
2017-03-27 16:08:20 -07:00
deads2k 8895f314b4 move category expansion out of restmapper 2017-03-27 13:54:05 -04:00
Kubernetes Submit Queue 9c62733b1f Merge pull request #43044 from ncdc/NewPrefixWriter
Automatic merge from submit-queue (batch tested with PRs 42900, 43044, 42896, 43308, 43621)

Convert PrefixWriter to an interface

Convert PrefixWriter to an interface to allow other packages to create instances. This is needed for downstream projects such as OpenShift.

cc @sttts @smarterclayton @oulinbao @deads2k @liggitt @kargakis @soltysh @kubernetes/sig-cli-pr-reviews
2017-03-27 08:32:25 -07:00
Kubernetes Submit Queue b9e3742779 Merge pull request #43303 from shiywang/fix1
Automatic merge from submit-queue

add cronjob resource name for get -h

Fixes https://github.com/kubernetes/kubernetes/issues/43293
@gyliu513 @ymqytw ptal
2017-03-26 14:20:48 -07:00
Kubernetes Submit Queue 6a529f700a Merge pull request #42948 from CaoShuFeng/fromLiteralStrings
Automatic merge from submit-queue (batch tested with PRs 42998, 42902, 42959, 43020, 42948)

[cli] fix Generator's error messages

Invalid variables are used when format error messages. This change
fixes them.

**Release note**:

```NONE
```
2017-03-25 17:17:28 -07:00
Kubernetes Submit Queue 31b6a18264 Merge pull request #42818 from liggitt/proxy-msg
Automatic merge from submit-queue (batch tested with PRs 42672, 42770, 42818, 42820, 40849)

Switch clusterinfo to print recommended proxy endpoints
2017-03-25 14:27:25 -07:00
zhengjiajin ee23bb1b3c unit test for kubectl config set-context 2017-03-25 17:46:22 +08:00
zhengjiajin 611c90c65d unit test for kubectl config unset 2017-03-25 17:44:57 +08:00
shiywang 4a3dad1da6 add cronjob resource name for get -h 2017-03-25 17:42:02 +08:00
Kubernetes Submit Queue 20b01be016 Merge pull request #41813 from shiywang/timeout_options
Automatic merge from submit-queue (batch tested with PRs 43642, 43170, 41813, 42170, 41581)

Be able to specify the timeout to wait for pod for kubectl logs/attach

Fixes https://github.com/kubernetes/kubernetes/issues/41786
current flag is `get-pod-timeout`, we can have a discussion if you have better one, default unit is seconds, above 0

@soltysh @kargakis ptal, thanks
@kubernetes/sig-cli-feature-requests
2017-03-24 19:04:26 -07:00
Kubernetes Submit Queue 0e17e5bd9c Merge pull request #38882 from fraenkel/configmap_env_file
Automatic merge from submit-queue (batch tested with PRs 41139, 41186, 38882, 37698, 42034)

create configmap from-env-file

Allow ConfigMaps to be created from Docker based env files.

See proposal https://github.com/kubernetes/community/issues/165

**Release-note:**
```release-note
1. create configmap has a new option --from-env-file that populates a configmap from file which follows a key=val format for each line.
2. create secret has a new option --from-env-file that populates a configmap from file which follows a key=val format for each line.
```
2017-03-24 12:33:25 -07:00
Kubernetes Submit Queue 0d53679efc Merge pull request #41139 from juanvallejo/jvallejo/set-cluster-api-value
Automatic merge from submit-queue

config set cluster api value

Related bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1420280

**Release note**:
```release-note
release-note-none
```

This patch sets a specified api version if one is given while setting cluster values in kubeconfig

cc @AdoHe  @pweil-
2017-03-24 12:10:55 -07:00
xilabao 757d12a211 fix kubectl run output 2017-03-24 17:08:49 +08:00
xilabao d2069ab46b ignore duplicate resource in create rolebinding 2017-03-22 17:35:04 +08:00
Xing Zhou a76f55403b Use TabWriter to keep output of "kubectl get xx -w" aligned.
Use TabWriter to keep output of "kubectl get xx -w" aligned.
2017-03-22 13:26:18 +08:00
Jordan Liggitt 939ca532aa
generated files 2017-03-20 23:57:38 -04:00
Jordan Liggitt 0e2f1b535d
Ensure empty serialized slices are zero-length, not null 2017-03-20 23:56:39 -04:00
Anthony Yeh fa23729a6d kubectl: Use v1.5-compatible ownership logic when listing dependents.
In particular, we should not assume ControllerRefs are necessarily set.
However, we can still use ControllerRefs that do exist to avoid
interfering with controllers that do use it.
2017-03-16 12:28:38 -07:00
Anthony Yeh 725ec0cc5e kubectl: Check for Deployment overlap annotation in reaper.
This effectively reverts the client-side changes in
cec3899b96.
We have to maintain the old behavior on the client side to support
version skew when talking to old servers that set the annotation.

However, the new server-side behavior is still to NOT set the
annotation.
2017-03-16 12:28:28 -07:00
shiywang 917a0b6f1b fix kubectl config return 0 on error 2017-03-16 08:34:51 +08:00
shiywang 52e4be2578 Be able to specify the timeout to wait for pod for kubectl logs/attach 2017-03-14 23:00:31 +08:00
Andy Goldstein 433fc606c6 Convert PrefixWriter to an interface
Convert PrefixWriter to an interface to allow other packages to create
instances. This is needed for downstream projects such as OpenShift.
2017-03-14 10:31:13 -04:00
Guangya Liu ab94015ee8 `kubectl taint` update for `NoExecute`. 2017-03-14 18:24:40 +08:00
AdoHe 8ebc6e91f8 print warning when delete current context 2017-03-12 22:29:11 +08:00
Cao Shufeng b2f530d756 [cli] fix Generator's error messages
Invalid variables are used when format error messages. This change
fixes them.
2017-03-11 02:09:52 -05:00
Kubernetes Submit Queue 9590f694c8 Merge pull request #41830 from irfanurrehman/fed-rbac-1
Automatic merge from submit-queue

[Federation] Kubefed Init should use the right RBAC API version clientset

**What this PR does / why we need it**:
Implements the need as described in https://github.com/kubernetes/kubernetes/issues/41263
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
https://github.com/kubernetes/kubernetes/issues/41263

**Special notes for your reviewer**:
@madhusudancs @shashidharatd @marun 
cc @kubernetes/sig-federation-bugs

**Release note**:

```
NONE
```
2017-03-10 15:56:47 -08:00
Maciej Szulik 597a359c38 Error out when cronjob generator not specified, but cronjobs are not available 2017-03-10 12:08:01 +01:00
Maciej Szulik aa4390750c Introduce new generator for apps/v1beta1 deployments 2017-03-10 12:08:01 +01:00
Maciej Szulik 1049dad0a4 Switch generators to use versioned objects 2017-03-10 12:08:01 +01:00
Łukasz Oleś b32afe1720 kubectl: respect DaemonSet strategy parameters for rollout status
It handles "after-merge" comments from #41116
2017-03-09 20:02:52 +01:00
Jordan Liggitt 9262c57ba8
Switch clusterinfo to print recommended proxy endpoints 2017-03-09 13:07:02 -05:00
Michael Fraenkel f2815156b0 create secret from-env-file 2017-03-08 07:58:01 -08:00
Michael Fraenkel 7eb49628c6 create configmap from-env-file 2017-03-08 07:58:01 -08:00
Kubernetes Submit Queue d306acca86 Merge pull request #42175 from enisoc/controller-ref-dep
Automatic merge from submit-queue

Deployment: Fully Respect ControllerRef

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

This is part of the completion of the [ControllerRef](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/controller-ref.md) proposal. It brings Deployment into full compliance with ControllerRef. See the individual commit messages for details.

**Which issue this PR fixes**:

This ensures that Deployment does not fight with other controllers over control of Pods and ReplicaSets.

Ref: https://github.com/kubernetes/kubernetes/issues/24433

**Special notes for your reviewer**:

**Release note**:

```release-note
Deployment now fully respects ControllerRef to avoid fighting over Pods and ReplicaSets. At the time of upgrade, **you must not have Deployments with selectors that overlap**, or else [ownership of ReplicaSets may change](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/controller-ref.md#upgrading).
```
cc @erictune @kubernetes/sig-apps-pr-reviews
2017-03-07 20:44:36 -08:00
xilabao a01cf0e66b add "use" to validResourceVerbs 2017-03-07 00:42:24 -06:00
Anthony Yeh 8c4bcb38fb Deployment: Filter by ControllerRef in Reaper.
We don't want to delete ReplicaSets we don't own.
2017-03-06 15:12:08 -08:00
Anthony Yeh cec3899b96 Deployment: Remove Overlap and SelectorUpdate annotations.
These are not used anymore since ControllerRef now protects against
fighting between controllers with overlapping selectors.
2017-03-06 15:12:08 -08:00
Kubernetes Submit Queue 90a4eda96b Merge pull request #41809 from kargakis/rollout-status-fix
Automatic merge from submit-queue

kubectl: respect deployment strategy parameters for rollout status

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

`rollout status` now respects the strategy parameters for a RollingUpdate Deployment. This means that it will exit as soon as minimum availability is reached for a rollout (note that if you allow maximum availability, `rollout status` will succeed as soon as the new pods are created)

@janetkuo @AdoHe ptal
2017-03-04 19:35:21 -08:00
Kubernetes Submit Queue db4fbf5958 Merge pull request #42369 from smarterclayton/get_warning
Automatic merge from submit-queue

Output of `kubectl get` is inconsistent for pods

Builds on top of fixes from #42283, only the last two commits are new. Reverts behavior of #39042 which was inconsistent and confusing.

Fixes #15853
2017-03-03 23:12:38 -08:00
Kubernetes Submit Queue b33d0fb394 Merge pull request #42391 from liggitt/patch-output
Automatic merge from submit-queue (batch tested with PRs 42443, 38924, 42367, 42391, 42310)

Fix 'not patched' kubectl error

fixes #42384
2017-03-03 18:08:44 -08:00
Kubernetes Submit Queue f7c07a121d Merge pull request #42285 from liggitt/get-watch
Automatic merge from submit-queue (batch tested with PRs 41919, 41149, 42350, 42351, 42285)

Fix error printing objects from kubectl get -w

Fixes #42276
2017-03-03 16:44:45 -08:00
Irfan Ur Rehman 2ad49a642b [Federation][Kubefed] Add some faked methods on kubectl fake test API factory for kubefeds consumption 2017-03-03 19:39:26 +05:30
Michail Kargakis d20ac8766e kubectl: respect deployment strategy parameters for rollout status 2017-03-03 14:12:08 +01:00
Clayton Coleman 34e4337e57
Don't print the "filtered" message on generic output
Unify the various output displays and make them simpler. Don't write to
glog, but only output the info when `-v 2` to stderr.
2017-03-02 15:58:25 -05:00
Clayton Coleman 4e7c10a520
Don't bypass filter on generic output
It is inconsistent and confusing (filtering is orthogonal from output)
and we don't want to regress behavior from 1.5.
2017-03-02 15:58:22 -05:00
juanvallejo b9d0c76dfd config set cluster api value 2017-03-02 14:01:25 -05:00
Kubernetes Submit Queue a9ac50051c Merge pull request #41924 from ymqytw/change_saveConfig
Automatic merge from submit-queue (batch tested with PRs 41984, 41682, 41924, 41928)

make edit respect --save-config

New behavior:

edit:
1) the flag is set to true: it will create or update the last-applied-config annotation
2) the flag is set to false or is unspecified: NOP

replace:
1) If saveConfig is true, create or update the annotation.
2) If saveConfig is false and the local config file doesn't have the annotation, we save the annotation from the live object if there is one (Try to not surprise the users).
3) If saveConfig is false and the local config file has the annotation, we use the annotation in the config file.
4) Same behavior for force replacing

fixes #40626

```release-note
stop kubectl edit from updating the last-applied-configuration annotation when --save-config is unspecified or false.
```

@pwittrock @liggitt 

This is a bug fix that prevented `edit` from being respected by `apply`
2017-03-02 10:51:16 -08:00
Jordan Liggitt 2802e5af27
Fix 'not patched' kubectl error 2017-03-02 01:00:48 -05:00
Kubernetes Submit Queue c7b53794d0 Merge pull request #39683 from soltysh/move_deployments
Automatic merge from submit-queue

Add apps/v1beta1 deployments with new defaults

This pull introduces deployments under `apps/v1beta1` and fixes #23597 and #23304.

TODO:

* [x] - create new type `apps/v1beta1.Deployment`
* [x] - update kubectl (stop, scale)
* [ ] - ~~new `kubectl run` generator~~ - this will only duplicate half of generator code, I suggest replacing current to use new endpoint
* [ ] - ~~create extended tests~~ - I've added integration and cmd tests verifying new endpoints
* [ ] - ~~create `hack/test-update-storage-objects.sh`~~ - see above

This is currently blocked by https://github.com/kubernetes/kubernetes/pull/38071, due to conflicting name `v1beta1.Deployment`. 

```release-note
Introduce apps/v1beta1.Deployments resource with modified defaults compared to extensions/v1beta1.Deployments.
```

@kargakis @mfojtik @kubernetes/sig-apps-misc
2017-03-01 08:29:26 -08:00
Kubernetes Submit Queue 50943d1783 Merge pull request #42191 from smarterclayton/dockercfg_secret
Automatic merge from submit-queue (batch tested with PRs 42316, 41618, 42201, 42113, 42191)

Make 'docker-email' optional on dockercfg secrets

It is not required for most username/password registries.

Fixes #41727
2017-03-01 07:48:33 -08:00
Kazuki Suda a46b04dc78 Support context completion for kubectl config use-context
With this commit, kubectl is supported context completion for config
use-context.

```
$ ./kubectl config use-context
cluster01  minikube
```

/refs #42103, #29386
2017-03-02 00:48:08 +09:00
Maciej Szulik c272630b1b Deployments under apps/v1beta1 with new defaults 2017-03-01 15:14:41 +01:00
Kubernetes Submit Queue e99ab5ada4 Merge pull request #42267 from liggitt/discovery-caching
Automatic merge from submit-queue

Prevent caching empty discovery docs

If kubectl makes requests before a server fully initialized, it could cache bad discovery responses (results of a partially forbidden discovery call, etc)

This changes to only cache responses that included at least one group or resource so that total failure doesn't get cached for 5 minutes
2017-03-01 06:11:01 -08:00
Kubernetes Submit Queue ba7c533fb0 Merge pull request #42103 from superbrothers/kubectl-context-completion
Automatic merge from submit-queue (batch tested with PRs 38676, 41765, 42103, 41833, 41702)

Support --context flag completion for kubectl

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

With this PR, `--context` flag completion is supported for kubectl.

**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
```
2017-03-01 01:44:07 -08:00
Kubernetes Submit Queue 83846e3a6a Merge pull request #41705 from liggitt/patch-output-result
Automatic merge from submit-queue (batch tested with PRs 41597, 42185, 42075, 42178, 41705)

Honor output formats in kubectl patch

Currently, output formats other than `-o name` are only honored when in `--local` mode.

This PR also prints the result from the server when in regular mode
2017-03-01 00:36:12 -08:00
xiangpengzhao 5daa6980e1 Add short name "netpol" for networkpolicies 2017-03-01 14:40:56 +08:00
Kubernetes Submit Queue eaf3c47489 Merge pull request #42115 from justinsb/kubectl_expose_drainoptions
Automatic merge from submit-queue (batch tested with PRs 42162, 41973, 42015, 42115, 41923)

kubectl drain: make code reusable

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

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

```release-note
NONE
```
2017-02-28 22:06:03 -08:00
Jordan Liggitt 091aac7e1e
Prevent caching empty discovery docs 2017-02-28 23:43:32 -05:00
Jordan Liggitt 31b3e01f1e
Fix error printing objects from kubectl get -w 2017-02-28 22:36:26 -05:00
Clayton Coleman bace937438
Don't filter items when resources requested by name
Add tracking on resource.Builder if a "named" item is requested (from
file, stream, url, or resource args) and use that in `get` to accurately
determine whether to filter resources. Add tests.
2017-02-28 19:19:33 -05:00
Kubernetes Submit Queue 34b31c8f32 Merge pull request #41699 from liggitt/apply-output-result
Automatic merge from submit-queue (batch tested with PRs 40746, 41699, 42108, 42174, 42093)

Output result of apply operation

Fixes #41690 

Plumbs the resulting object from patch operations back to the top level so it can be output when printing
2017-02-28 07:51:22 -08:00
Kubernetes Submit Queue bdb141a60f Merge pull request #40746 from matthyx/master
Automatic merge from submit-queue

numeric ordering of kubectl outputs

**What this PR does / why we need it**:
Instead of having kubectl listing the pods in a alphabetical way:
foobar-1-build
foobar-10-build
foobar-2-build
foobar-3-build
With the parameter --sort-by '{.metadata.name}' it now gives:
foobar-1-build
foobar-2-build
foobar-3-build
foobar-10-build

**Which issue this PR fixes**
https://github.com/openshift/origin/issues/7229

**Special notes for your reviewer**:
I have followed the dependencies requirements from https://github.com/kubernetes/community/blob/master/contributors/devel/godep.md

**Release note**:

```release-note
Import a natural sorting library and use it in the sorting printer.
```
2017-02-28 07:45:37 -08:00
Kubernetes Submit Queue 8ceb0c4025 Merge pull request #41151 from ahakanbaba/tpr-unit-tests
Automatic merge from submit-queue (batch tested with PRs 41937, 41151, 42092, 40269, 42135)

Add a unit test for idempotent applys to the TPR entries.

The test in apply_test follows the general pattern of other tests.
We load from a file in test/fixtures and mock the API server in the
function closure in the HttpClient call.
The apply operation expects a last-modified-configuration annotation.
That is written verbatim in the test/fixture file.

References #40841



**What this PR does / why we need it**:
Adds one unit test for TPR's using applies. 

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
References: 
https://github.com/kubernetes/features/issues/95
https://github.com/kubernetes/kubernetes/issues/40841#issue-204769102


**Special notes for your reviewer**:

I am not super proud of the tpr-entry name. 
But I feel like we need to call the two objects differently. 
The one which has Kind:ThirdPartyResource 
and the one has Kind:Foo. 

Is the name "ThirdPartyResource" used interchangeably for both ? I used tpr-entry for the Kind:Foo object.

Also I !assume! this is testing an idempotent apply because the last-applied-configuration annotation is the same as the object itself. 

This is the state I see in the logs of kubectl if I do a proper idempotent apply of a third party resource entry. 

I guess I will know more once I start playing around with apply command that change TPR objects. 

**Release note**:

```release-note
```
2017-02-28 01:24:06 -08:00
Matthias Bertschy 336a78aeaf Use natural sorting for strings in sorting_printer
Import new dependency vbom.ml/util/sortorder
Run ./hack/update-bazel.sh
2017-02-28 07:50:44 +01:00
Clayton Coleman ec753da074
Make 'docker-email' optional on dockercfg secrets
It is not required for most username/password registries.
2017-02-27 17:13:08 -05:00
ymqytw 1cebb2c1bb make edit respect --save-config 2017-02-27 13:34:07 -08:00
Kubernetes Submit Queue 6d9e2afeda Merge pull request #40927 from soltysh/deployment_logs
Automatic merge from submit-queue (batch tested with PRs 42053, 41282, 42056, 41663, 40927)

Allow getting logs directly from deployment, job and statefulset

**Special notes for your reviewer**:
@smarterclayton you asked for it in OpenShift


```release-note
kubectl logs allows getting logs directly from deployment, job and statefulset
```
2017-02-27 12:45:36 -08:00
Hakan Baba 1cc30bdfb2 Add a unit test for applies and idempotent applys to the TPR entries.
The tests in apply_test follows the general pattern of other tests.
We load from a file in test/fixtures and mock the API server in the
function closure in the HttpClient call.
In PATCH request rount-tripper we check that the kubectl apply
implementation worked as expected.

References #40841
2017-02-27 10:22:12 -08:00
Jordan Liggitt 4592c47ad4
Output result of apply operation 2017-02-27 09:28:28 -05:00
Jordan Liggitt 56d141851f
Honor output formats in kubectl patch 2017-02-27 09:20:49 -05:00
Maciej Szulik 5472a5e0a5 Allow getting logs directly from deployment, job and statefulset 2017-02-27 13:13:09 +01:00
Maciej Szulik 27259358cb Switch ClientAccessFactory to use clientset.Interface rather than actual type 2017-02-27 13:13:06 +01:00
Łukasz Oleś b2d9f99f0c Moved tests and fixed typs 2017-02-27 09:15:56 +01:00
Łukasz Oleś b59ecde587 Implement kubectl rollout status for daemon sets 2017-02-27 09:15:56 +01:00
Kubernetes Submit Queue e6ecfd2e37 Merge pull request #41694 from shiywang/apply-set1
Automatic merge from submit-queue (batch tested with PRs 42044, 41694, 41927, 42050, 41987)

Add apply set-last-applied subcommand 

implement part of https://github.com/kubernetes/community/pull/287, will rebase after https://github.com/kubernetes/kubernetes/pull/41699 got merged, EDIT: since bug output format has been confirmed, will update the behavior of output format soon  
cc @kubernetes/sig-cli-pr-reviews @AdoHe @pwittrock 

```release-note
Support kubectl apply set-last-applied command to update the applied-applied-configuration annotation
```
2017-02-26 23:16:51 -08:00
Kubernetes Submit Queue 082cfac707 Merge pull request #35408 from xilabao/add-secret-to-pflag
Automatic merge from submit-queue (batch tested with PRs 35408, 41915, 41992, 41964, 41925)

add secret option to flag

To resolve the issue of security(pr #35030 ),

> @smarterclayton commented 5 days ago
> This is unfortunately not all flags that could be secrets. The best option would be to add support in spf13/pflag to tag a flag as a secret, and then use that bit to determine the list.
> 
> Also, Command() could be used in contexts that need exact parameters (for subshell execution), so we would need to add a new method or extend the signature here to allow exact flags to be retrieved.

we could add a secret option to the flags.
2017-02-26 18:07:53 -08:00
Kubernetes Submit Queue 0bc16d8966 Merge pull request #40576 from nikhiljindal/kubectlcascDel
Automatic merge from submit-queue (batch tested with PRs 41994, 41969, 41997, 40952, 40576)

Updating kubectl to send delete requests with orphanDependents=false if --cascade is true

Ref https://github.com/kubernetes/kubernetes/issues/40568 #38897

Updating kubectl to always set `DeleteOptions.orphanDependents=false` when deleting a resource with `--cascade=true`.
This is primarily for federation where we want to use server side cascading deletion.

Impact on kubernetes: kubectl will do another GET after sending a DELETE and wait till the resource is actually deleted. This can have an impact if the resource has a finalizer. kubectl will wait till the finalizer is removed and then the resource is deleted, which is the right thing to do but a notable change in behavior.

cc @caesarxuchao @lavalamp @smarterclayton @kubernetes/sig-federation-pr-reviews @kubernetes/sig-cli-pr-reviews
2017-02-26 12:58:01 -08:00
Kubernetes Submit Queue c4835f2626 Merge pull request #41864 from marun/kubectl-drain-orphans
Automatic merge from submit-queue (batch tested with PRs 41857, 41864, 40522, 41835, 41991)

kubectl: Allow 'drain --force' to remove orphaned pods

If the managing resource of a given pod (e.g. DaemonSet/ReplicaSet/etc) is deleted (effectively orphaning the pod), and ``kubectl drain --force`` is invoked on the node hosting the pod, the command would fail with an error indicating that the managing resource was not found.  This PR reduces the error to a warning if ``--force`` is specified, allowing nodes with orphaned pods to be drained.   

Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1424678

cc: @derekwaynecarr 

```release-note
Allow drain --force to remove pods whose managing resource is deleted.
```
2017-02-26 11:13:53 -08:00
Kubernetes Submit Queue a1490926d6 Merge pull request #41077 from deads2k/cli-01-cani
Automatic merge from submit-queue (batch tested with PRs 41814, 41922, 41957, 41406, 41077)

add kubectl can-i to see if you can perform an action

Adds `kubectl auth can-i <verb> <resource> [<name>]` so that a user can see if they are allowed to perform an action.

@kubernetes/sig-cli-pr-reviews @fabianofranz 

This particular command satisfies the immediate need of knowing if you can perform an action without trying that action.  When using RBAC in a script that is adding permissions, there is a lag between adding the permission and the permission being realized in the RBAC cache.  As a user on the CLI, you almost never see it, but as a script adding a binding and then using that new power, you hit it quite often.

There are natural follow-ons to the same area (hence the `auth` subcommand) to figure out if someone else can perform an action, what actions you can perform in total, and who can perform a given action.  Someone else is an API we have already, what-can-i-do was a proposed API a while back and a very useful one for interfaces, and who-can is common question if someone is administering a namespace.
2017-02-26 10:22:54 -08:00
Kubernetes Submit Queue 5c3791b9e0 Merge pull request #41729 from smarterclayton/refactor_printers
Automatic merge from submit-queue (batch tested with PRs 41621, 41946, 41941, 41250, 41729)

Refactor printers and describers into their own package.

This sets the stage for using printer code from the server side (decoupled from kubectl) and loosens the coupling between kubectl and the printers. `pkg/printers` contains interfaces and has an import restriction against pulling in API specific code, while `pkg/printers/internalversion` can be used for internal types.

Add a method on `Factory` for retrieving PrinterForCommand which uses the Scheme and RESTMapper from the Factory, not the hardcoded ones.  This further separates kubectl from the core API scheme and allows better composition.

Change NamePrinter to use RESTMapper (previously it was hardcoding those conversions). This means that we now return plural resource names (`pods/foo`) but is correct once aliases and shortnames start being returned by the mapper.

This is a prerequisite for server side get, but is pure refactor (contains no new features).

@deads2k @liggitt
2017-02-26 06:47:03 -08:00
Justin Santa Barbara 72afd143c4 kubectl drain: make code reusable
DrainOptions requires a few fields to be set, and the expectation is
that these are set as part of construction of the object.  If they are
set, then the drain code can be reused in other kubernetes projects.

This does not create a contract that DrainOptions should fulfill going
forwards, any more than any of the other types that happen to be exposed
are part of the contract.  Instead, this merely makes use outside the
package possible.
2017-02-26 00:48:48 -05:00
Jordan Liggitt 41c88e0455
Revert "Merge pull request #40088 from jsafrane/storage-ga-v1"
This reverts commit 5984607cb9, reversing
changes made to 067f92e789.
2017-02-25 22:35:15 -05:00
xilabao 131802a5cd add secret flag to options 2017-02-25 23:40:50 +08:00
Kazuki Suda 4da41ca56c Support --context flag completion for kubectl 2017-02-25 23:54:56 +09:00
Kubernetes Submit Queue 5984607cb9 Merge pull request #40088 from jsafrane/storage-ga-v1
Automatic merge from submit-queue (batch tested with PRs 41854, 41801, 40088, 41590, 41911)

Add storage.k8s.io/v1 API

v1 API is direct copy of v1beta1 API. This v1 API gets installed and exposed in this PR, I tested that kubectl can create both v1beta1 and v1 StorageClass.

~~Rest of Kubernetes (controllers, examples,. tests, ...) still use v1beta1 API, I will update it when this PR gets merged as these changes would get lost among generated code.~~ Most parts use v1 API now, it would not compile / run tests without it.

**Release note**:
```
Kubernetes API storage.k8s.io for storage objects is now fully supported and is available as storage.k8s.io/v1. Beta version of the API storage.k8s.io/v1beta1 is still available in this release, however it will be removed in a future Kubernetes release.

Together with the API endpoint, StorageClass annotation "storageclass.beta.kubernetes.io/is-default-class" is deprecated and  "storageclass.kubernetes.io/is-default-class" should be used instead to mark a default storage class. The beta annotation is still working in this release, however it won't be supported in the next one.
```

@kubernetes/sig-storage-misc
2017-02-25 05:02:55 -08:00
elipapa 136c90a7bf solving unknown file attribute error while sourcing completions
sourcing the file with `zsh` > 4 resulted in an `unknown file attribute`.
More details at http://stackoverflow.com/questions/37220495/zsh-unknown-file-attribute

replacing $@ with $* for get_comp_words
as suggested by @sttts worked to resolve the issue
2017-02-24 16:29:41 +00:00
Jan Safranek a1b6eeefc8 Update kubectl unit test 2017-02-24 13:52:16 +01:00
SongRuixia 6b1cf1d71c Add f.close for the opend file 2017-02-24 16:18:22 +08:00
Kubernetes Submit Queue 072e68f0a6 Merge pull request #41356 from foxish/fix-petset-refs
Automatic merge from submit-queue

Fix references to PetSet

Removing PetSet references in scaler/reaper code

```release-note
NONE
```
2017-02-23 19:55:33 -08:00
Shiyang Wang 9bace3e379 add apply-set-last-applied subcommand
update

update code

update unit tests

hack/update

remove spew

update bazel

updated

add comments

remove unused parameter

remove hardcode

bump unit tests

add new flags

add unit tests

add bazel

genreate doc
2017-02-24 11:11:39 +08:00
Kubernetes Submit Queue 0e0e51ddeb Merge pull request #41798 from huzhengchuan/master
Automatic merge from submit-queue

Fix comment for struct DeploymentBasicGeneratorV1

**Release note**:

```release-note
```
2017-02-23 19:08:46 -08:00
nikhiljindal 20aa573865 Adding a unit test for verifying OrphanDependents in kubectl delete requests 2017-02-23 12:04:13 -08:00
nikhiljindal 9dc31c7f82 Updating reapers to set OrphanDependents=false 2017-02-23 12:04:13 -08:00
nikhiljindal 78ae193de6 kubectl should always set orphanDependents=false for cascading deletion 2017-02-23 12:04:13 -08:00
Kubernetes Submit Queue e5c2d716d9 Merge pull request #41887 from liggitt/watch-verb
Automatic merge from submit-queue (batch tested with PRs 39855, 41433, 41567, 41887, 41652)

Use watch param instead of deprecated /watch/ prefix

Reopen of https://github.com/kubernetes/kubernetes/pull/41722 after reverted in https://github.com/kubernetes/kubernetes/pull/41774

Required https://github.com/kubernetes/kubernetes/pull/41797 to merge first

cc @deads2k @wojtek-t
2017-02-23 09:36:35 -08:00
Kubernetes Submit Queue 346a8a778f Merge pull request #41433 from juanvallejo/jvallejo/add-ignore-not-found-flag
Automatic merge from submit-queue (batch tested with PRs 39855, 41433, 41567, 41887, 41652)

add --ignore-not-found option

Related downstream issue https://github.com/openshift/origin/issues/12867#event-961812896

Adds `--ignore-not-found` option that works similarly to the one found in [delete](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/delete.go#L154).

Allows for scripts to request specific resources that might not exist, without dealing with ambiguous exit code `1`.

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

cc @smarterclayton @jupierce @fabianofranz
2017-02-23 09:36:31 -08:00
deads2k 5b4a611fd7 add kubectl can-i to see if you can perform an action 2017-02-23 09:12:35 -05:00
Clayton Coleman 651188d687
generated: bazel 2017-02-23 00:28:32 -05:00
Clayton Coleman 2aa4abb73b
Refactor commands to use new factory method 2017-02-23 00:28:32 -05:00
Clayton Coleman 19ae89dcd8
command Factory should provide Printers
The factory knows all possible types, and should abstract the process of
creating all printers. A future refactor can further reduce the
dependencies between printer code and internal types.
2017-02-23 00:28:31 -05:00
Clayton Coleman 6d1c7308a5
Move, but do not refactor, printers to their own package 2017-02-23 00:28:30 -05:00
Kubernetes Submit Queue c99ae4b436 Merge pull request #41538 from xingzhou/clusterrole
Automatic merge from submit-queue (batch tested with PRs 41146, 41486, 41482, 41538, 41784)

Added `kubectl create clusterrole` command.

Added `kubectl create clusterrole` command.

Fixed part of #39596 

**Special notes for your reviewer**:
@deads2k, please help to review this patch, thanks

**Release note**:
```
   Added one new command `kubectl create clusterrole` to help user create a single ClusterRole from command line.
```
2017-02-22 21:09:36 -08:00
Kubernetes Submit Queue afd3db25cf Merge pull request #41146 from shiywang/apply-view1
Automatic merge from submit-queue (batch tested with PRs 41146, 41486, 41482, 41538, 41784)

 Add apply view-last-applied subcommand

reopen pr https://github.com/kubernetes/kubernetes/pull/40984, implement part of https://github.com/kubernetes/community/pull/287
for now unit test all pass, the output looks like:

```console
shiywang@dhcp-140-33 template $ ./kubectl apply view last-applied deployment nginx-deployment 
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  creationTimestamp: null
  name: nginx-deployment
spec:
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx:1.12.10
        name: nginx
        ports:
        - containerPort: 80
        resources: {}
status: {}
```

```release-note
Support new kubectl apply view-last-applied command for viewing the last configuration file applied
```

not sure if there is any flag I should updated or the some error handling I should changed.
will generate docs when you guys think is ok.
cc @pwittrock @jessfraz @AdoHe @ymqytw
2017-02-22 21:09:31 -08:00
Kubernetes Submit Queue 3560ac3193 Merge pull request #40667 from brendandburns/i18n7
Automatic merge from submit-queue (batch tested with PRs 38957, 41819, 41851, 40667, 41373)

Wrap and extract some flag description strings.

Moving on from help strings to flag descriptions.

@zen @fabianofranz @kubernetes/sig-cli-pr-reviews
2017-02-22 19:59:36 -08:00
Maru Newby 92d739bebc kubectl: Allow 'drain --force' to remove orphaned pods 2017-02-22 06:59:33 -08:00
Avesh Agarwal b4d3d24eaf Update tests. 2017-02-22 09:27:42 -05:00
Avesh Agarwal 9b640838a5 Change taint/toleration annotations to api fields. 2017-02-22 09:27:42 -05:00
Jordan Liggitt 7b6ef2cedc
Switch watch prefixes to params 2017-02-22 08:54:08 -05:00
Brendan Burns f1de40b448 Extract some flag description strings to be translated. 2017-02-21 22:07:30 -08:00
Xing Zhou 433941f1fd Added `kubectl create clusterrole` command.
Added `kubectl create clusterrole` command.
2017-02-22 10:30:41 +08:00
zhengchuan hu e3b697097d Fix comment for struct DeploymentBasicGeneratorV1 2017-02-21 20:47:06 +08:00
Kubernetes Submit Queue 43fec5afb5 Merge pull request #41685 from liggitt/edit-refactor-unknown-field
Automatic merge from submit-queue (batch tested with PRs 41709, 41685, 41754, 41759, 37237)

Tolerate unknown fields in strategic merge patch

When using `apply` or `edit` with an object that has a compiled-in struct, if an unknown server-side field is sent, or is present in a provided file, the strategic merge patch computation fails looking up type info from the go struct

If the field only exists in one side of the patch (is being added or removed), or is identical in both sides of the patch, we should tolerate missing type info, since it doesn't affect the patch.
2017-02-21 04:27:46 -08:00
shiywang 557c18694a Add apply view last-applied subcommand
change to GetOriginalConfiguration

add bazel

refactor apply view-last-applied command

update some changes

minor change

add unit tests, update

update some codes and genreate docs

update LongDesc
2017-02-21 20:08:25 +08:00
Kubernetes Submit Queue 1cb737fb97 Merge pull request #41576 from deads2k/cli-04-remove-outputversion
Automatic merge from submit-queue (batch tested with PRs 41706, 39063, 41330, 41739, 41576)

deprecate and disconnect --output-version

For at least two releases, there haven't been multiple versions of API groups and we don't plan to support conversions in commands other than `kubectl convert`.  This disconnects the `--output-version` option to be consistent with conversion agnostic command before it becomes an issue.

@kubernetes/sig-cli-pr-reviews @fabianofranz @smarterclayton

```release-note
`--output-version` is ignored for all commands except `kubectl convert`.  This is consistent with the generic nature of `kubectl` CRUD commands and the previous removal of `--api-version`.  Specific versions can be specified in the resource field: `resource.version.group`, `jobs.v1.batch`.
```
2017-02-21 02:24:45 -08:00
Wojciech Tyczynski a21b08d00f Revert "Use watch param instead of deprecated /watch/ prefix" 2017-02-21 08:37:51 +01:00
Jordan Liggitt f8d2e4fa1c
Add 'kubectl edit' testcase for unknown field in known group/version/kind 2017-02-20 20:40:03 -05:00
Jordan Liggitt f950171003
Switch watch prefixes to params 2017-02-19 23:51:58 -05:00
juanvallejo a76ed0284b add --ignore-not-found option 2017-02-17 17:40:37 -05:00
Kubernetes Submit Queue 56afb95641 Merge pull request #41465 from bruceauyeung/k8s-branch-fix-kubectl-create-configmap-help-messages
Automatic merge from submit-queue

fix kubectl create configmap help messages

Signed-off-by: bruceauyeung <ouyang.qinhua@zte.com.cn>

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

1. the first example command actually doesn't specify any keys. i think `with keys for each file` is incorrect.
2. `names on disk` is confusing.  in usage the word `NAME` means configmap, so i think it's better saying `file basenames on disk`
3. in this context, `--from-file` can be specified multiple times, but in each occurance only one key file can be specified, besides we should keep consistent with the later case (key is specified). so i changed words in this sentence to singular. and to avoid confusing, i use `key` instead of `name`
2017-02-17 13:56:36 -08:00
Kubernetes Submit Queue b2df7e5397 Merge pull request #41547 from xilabao/remove-validNonResourceVerbs-in-create-role
Automatic merge from submit-queue (batch tested with PRs 41604, 41273, 41547)

remove validNonResourceVerbs in create role

non-resource-url is only reasonable for clusterroles
2017-02-17 07:20:39 -08:00
Kubernetes Submit Queue f0b58a7bed Merge pull request #41570 from deads2k/cli-03-tolerate-missing-shortcut
Automatic merge from submit-queue

only construct shortcutmapper when we have the discovery client

Resource shortnames come from the discoveryclient, so we should only wrap with that mapper when we have the information we need.
2017-02-16 19:45:44 -08:00
Kubernetes Submit Queue 4f6b229fdf Merge pull request #34664 from ymqytw/filter_annotation_for_describe_secret
Automatic merge from submit-queue (batch tested with PRs 40505, 34664, 37036, 40726, 41595)

filter lastAppliedConfig annotation for describe secret

Temporarily addresses: #23564.
This patch filters out the lastAppliedConfig annotation when describing a secret.

```release-note
kubectl describe no longer prints the last-applied-configuration annotation for secrets.
```
2017-02-16 17:05:10 -08:00
xilabao 367006bea4 remove validNonResourceVerbs in create role 2017-02-17 08:52:59 +08:00
Kubernetes Submit Queue 9443d85c4b Merge pull request #40505 from brendandburns/i18n5
Automatic merge from submit-queue

Extract strings from the rollout command.

@fabianofranz @kubernetes/sig-cli-pr-reviews
2017-02-16 16:45:32 -08:00
deads2k d3da1d102d deprecate and disconnect --output-version 2017-02-16 13:23:59 -05:00
deads2k 9b5acdbb88 only construct shortcutmapper when we have the discovery client 2017-02-16 11:38:52 -05:00
gmarek e1e4370ecd Promote taint addition/removal to api/v1/helpers.go 2017-02-16 09:25:27 +01:00
Kubernetes Submit Queue fbc94c0896 Merge pull request #41343 from p0lyn0mial/kubectl_get_short_names_from_discovery_api
Automatic merge from submit-queue

shortcut expander will take the list of short names from the api ser…

**What this PR does / why we need it**: the shortcut expander will take the list of short names for resources from the API server during the discovery. For backward compatibility a hardcoded list of short names will always be appended while evaluating a short name.
2017-02-15 09:07:51 -08:00
Kubernetes Submit Queue beed2ea460 Merge pull request #41252 from kargakis/drop-unnecessary-helper
Automatic merge from submit-queue (batch tested with PRs 41196, 41252, 41300, 39179, 41449)

Remove redundant pod helper
2017-02-15 04:14:12 -08:00
bruceauyeung a410a63dc7 fix kubectl create configmap help messages
Signed-off-by: bruceauyeung <ouyang.qinhua@zte.com.cn>
2017-02-15 16:57:38 +08:00
p0lyn0mial 98068b6367 shortcut expander will take the list of short names from the api server. 2017-02-15 09:06:47 +01:00
Kubernetes Submit Queue cf10f532d1 Merge pull request #41304 from liggitt/edit-refactor
Automatic merge from submit-queue

Make kubectl edit work with unstructured objects

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


1. First (before any other changes), added several test cases for complex edit scenarios:
   - [x] ensure the edit loop bails out if given the same result that already caused errors
   - [x] ensure an edited file with a syntax error is reopened preserving the input
   - [x] ensure objects with existing "caused-by" annotations get updated with the current command

2. Refactored the edit code to prep for switching to unstructured:
   - [x] made editFn operate on a slice of resource.Info objects passed as an arg, regardless of edit mode
   - [x] simplified short-circuiting logic when re-editing a file containing an error
   - [x] refactored how we build the various visitors (namespace enforcement, annotation application, patching, creating) so we could easily switch to just using a single visitor over a set of resource infos read from the updated input for all of them

3. Switched to using a resource builder to parse the stream of the user's edited output
   - [x] improve the error message you get on syntax errors
   - [x] preserve the user's input more faithfully (see how the captured testcase requests to the server changed to reflect exactly what the user edited)
   - [x] stopped doing client-side conversion (means deprecating `--output-version`)

4. Switched edit to work with generic objects
   - [x] use unstructured objects
   - [x] fall back to generic json merge patch for unrecognized group/version/kinds

5. Added new test cases
   - [x] schemaless objects falls back to generic json merge (covers TPR scenario)
   - [x] edit unknown version of known kind (version "v0" of storageclass) falls back to generic json merge

```release-note
`kubectl edit` now edits objects exactly as they were retrieved from the API. This allows using `kubectl edit` with third-party resources and extension API servers. Because client-side conversion is no longer done, the `--output-version` option is deprecated for `kubectl edit`. To edit using a particular API version, fully-qualify the resource, version, and group used to fetch the object (for example, `job.v1.batch/myjob`)
```
2017-02-14 18:34:30 -08:00
Kubernetes Submit Queue 7332baf9a3 Merge pull request #39636 from liggitt/proxy-subresource
Automatic merge from submit-queue (batch tested with PRs 41382, 41407, 41409, 41296, 39636)

Update to use proxy subresource consistently

Proxy subresources have been in place since 1.2.0 and improve the ability to put policy in place around proxy access.

This PR updates the last few clients to use proxy subresources rather than the root proxy
2017-02-14 13:04:33 -08:00
Jordan Liggitt ec271f5c09
Switch 'kubectl edit' to use unstructured objects, handle schemaless objects
mark --output-version as deprecated, add example for fully-qualifying version to edit

Add 'kubectl edit' testcase for editing schemaed and schemaless data together

Add 'kubectl edit' testcase for editing unknown version of known group/kind
2017-02-14 14:55:02 -05:00
Jordan Liggitt 5b805bc18a
Simplify 'kubectl edit' logic
edit: make editFn operate on arguments regardless of mode

edit: simplify short-circuiting logic when re-editing a file containing an error

edit: factor out visitor building

edit: use resource builder to get results from edited file
2017-02-14 14:51:06 -05:00
Jordan Liggitt f86db18297
Add advanced 'kubectl edit' test scenarios
Add 'kubectl edit' testcase for saving a repeated error

Add 'kubectl edit' testcase for preserving an edited file with a syntax error

Add 'kubectl edit' testcase for recording command on list of objects
2017-02-14 14:50:45 -05:00
Kubernetes Submit Queue f26890b801 Merge pull request #41329 from deads2k/cli-02-negotiation
Automatic merge from submit-queue (batch tested with PRs 41299, 41325, 41386, 41329, 41418)

stop senseless negotiation

Most client commands don't respect a negotiated version at all.  If you request a particular version, then of course it should be respected, but if you have none to request, then the current negotiation step doesn't return anything useful so we may as well have nothing so we can at least detect the situation.

@jwforres @kubernetes/sig-cli-pr-reviews 

Added a TODO to make the negotiate function useful.  I think I'm inclined to remove it entirely unless someone can come up with a useful reason to have it.
2017-02-14 11:42:38 -08:00
deads2k e063ca3e82 stop senseless negotiation 2017-02-14 08:49:14 -05:00
Jordan Liggitt 88a876b1d0
Update to use proxy subresource consistently 2017-02-13 22:05:00 -05:00
foxish 205c68351d Fix references to PetSet 2017-02-13 13:40:34 -08:00
Jordan Liggitt 2a76fa1c8f
Switch RBAC subject apiVersion to apiGroup in v1beta1 2017-02-13 15:33:09 -05:00
Kubernetes Submit Queue beaf5ffacc Merge pull request #39852 from xingzhou/kube-39596
Automatic merge from submit-queue

Added kubectl create role command

Added `kubectl create role` command.

Fixed part of #39596 

**Release note**:
```
   Added one new command `kubectl create role` to help user create a single role from command line.
```
2017-02-13 08:40:50 -08:00
Brendan Burns 700b6b3b7b Extract strings from the rollout command. 2017-02-11 22:15:10 -08:00
Michail Kargakis fe137a8123 Remove redundant pod helper 2017-02-10 17:58:59 +01:00
Kubernetes Submit Queue 45d122dd6b Merge pull request #36033 from DirectXMan12/feature/hpa-v2
Automatic merge from submit-queue (batch tested with PRs 40796, 40878, 36033, 40838, 41210)

HPA v2 (API Changes)

**Release note**:
```release-note
Introduces an new alpha version of the Horizontal Pod Autoscaler including expanded support for specifying metrics.
```

Implements the API changes for kubernetes/features#117.

This implements #34754, which is the new design for the Horizontal Pod Autoscaler.  It includes improved support for custom metrics (and/or arbitrary metrics) as well as expanded support for resource metrics.  The new HPA object is introduces in the API group "autoscaling/v1alpha1".

Note that the improved custom metric support currently is limited to per pod metrics from Heapster -- attempting to use the new "object metrics" will simply result in an error.  This will change once #34586 is merged and implemented.
2017-02-10 00:04:48 -08:00
Kubernetes Submit Queue ce998a9fa7 Merge pull request #40365 from shiywang/attach
Automatic merge from submit-queue (batch tested with PRs 41145, 38771, 41003, 41089, 40365)

Add `kubectl attach` support for multiple types

To address this issue: https://github.com/kubernetes/kubernetes/issues/24857
the new `kubectl attach` will contain three scenarios depend on args:
1. `kubectl attach POD` :   if only one argument provided, we assume it's a pod name
2. `kubectl attach TYPE NAME` : if two arguments provided, we assume first one is resource we [supported](4770162fd3/pkg/kubectl/cmd/util/factory_object_mapping.go (L285)), the second resource's name.
3. `kubectl attach TYPE/NAME` : one argument provided and arg[0] must contain `/`, ditto

Is there any other scenarios I haven't consider in ?

for now the first scenario is compatible with changed before, also `make test` pass  
will write some unit test to test second and third scenario, if you guys think i'm doing the right way.
@pwittrock @kargakis @fabianofranz @ymqytw @AdoHe
2017-02-09 13:34:56 -08:00
Kubernetes Submit Queue 85fd324b62 Merge pull request #41003 from xingzhou/create-rolebinding-bug
Automatic merge from submit-queue (batch tested with PRs 41145, 38771, 41003, 41089, 40365)

Remove useless param from kubectl create rolebinding

The `force` param is not used in
`kubectl create rolebinding` & `kubectl create clusterrolebinding`
commands, removed it.
2017-02-09 13:34:49 -08:00
Kubernetes Submit Queue 5c4cec21c3 Merge pull request #38771 from derekwaynecarr/fix_drain_typo
Automatic merge from submit-queue (batch tested with PRs 41145, 38771, 41003, 41089, 40365)

Fix typo in drain command
2017-02-09 13:34:47 -08:00
Kubernetes Submit Queue 4166c0e4a0 Merge pull request #38683 from bruceauyeung/k8s-branch-fix-possible-nil-error
Automatic merge from submit-queue

avoid repeated length calculation and some other code improvements

**What this PR does / why we need it**:
1. in function `ParsePairs`,  calculating `invalidBuf`'s length over and over again brings performance penalty. a `invalidBufNonEmpty` bool value can fix this.
2. pairArg is not a string template and also there is no other arguments for `fmt.Sprintf`, so i remove `fmt.Sprintf`
3. in function `DumpReaderToFile`, we must check nil error first before defer statement, otherwise there maybe a potential nil error on `f.Close()`
4. add nil checks into `GetWideFlag` function
5. some other minor code improvements for better readability.


Signed-off-by: bruceauyeung <ouyang.qinhua@zte.com.cn>
2017-02-08 09:49:10 -08:00
Kubernetes Submit Queue 4ed86f5d46 Merge pull request #41076 from gyliu513/port-forward
Automatic merge from submit-queue

Removed a space in portforward.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**:

```release-note
```
2017-02-08 07:59:10 -08:00
Kubernetes Submit Queue 79e333afe0 Merge pull request #40823 from liggitt/edit-tests
Automatic merge from submit-queue (batch tested with PRs 38796, 40823, 40756, 41083, 41105)

Add unit tests for interactive edit command

Before updating edit to use unstructured objects and use generic JSON patching, we need better test coverage of the existing paths. This adds unit tests for the interactive edit scenarios. 

This PR adds:
* Simple framework for recording tests for interactive edit:
  * record.go is a tiny test server that records editor and API inputs as test expectations, and editor and API outputs as playback stubs
  * record_editor.sh is a shell script that sends the before/after of an interactive `vi` edit to the test server
  * record_testcase.sh (see README) starts up the test server, sets up a kubeconfig to proxy to the test server, sets EDITOR to invoke record_editor.sh, then opens a shell that lets you use `kubectl edit` normally
* Adds test cases for the following scenarios:
  - [x] no-op edit (open and close without making changes)
  - [x] try to edit a missing object
  - [x] edit single item successfully
  - [x] edit list of items successfully
  - [x] edit a single item, submit with an error, re-edit, submit fixed successfully
  - [x] edit list of items, submit some with errors and some good, re-edit errors, submit fixed
  - [x] edit trying to change immutable things like name/version/kind, ensure preconditions prevent submission
  - [x] edit in "create mode" successfully (`kubectl create -f ... --edit`)
  - [x] edit in "create mode" introducing errors (`kubectl create -f ... --edit`)
* Fixes a bug with edit printing errors to stdout (caught when testing stdout/stderr against expected output)

Follow-ups:
- [ ] clean up edit code path
- [ ] switch edit to use unstructured objects
- [ ] make edit fall back to jsonmerge for objects without registered go structs (TPR, unknown versions of pods, etc)
- [ ] add tests:
  - [ ] edit TPR
  - [ ] edit mix of TPR and known objects
  - [ ] edit known object with extra field from server
  - [ ] edit known object with new version from server
2017-02-08 00:49:46 -08:00
shiywang 919cb19706 kubectl attach support for multiple types
hot fix

add unit test and statefulSet

update example

remove package

change to ResourceNames

remove some code

remove strings

add fake testing func for AttachablePodForObject

minor change

add test.obj nil check

update testfile

gofmt

update

add fallthough

revert back
2017-02-08 16:10:55 +08:00
Xing Zhou b9c6fb52ab Added unit tests for kubectl create role command.
Added unit tests for kubectl create role command.
2017-02-08 13:30:10 +08:00
Xing Zhou 0a2876d39e Added kubectl create role command.
Added kubectl create role command.
2017-02-08 13:30:03 +08:00
Solly Ross 946ecb549e Update kubectl to work with new HPA objects
This commit updates kubectl to work with the changes to the unversioned
HPA object made to support the HPA v2alpha1 API.
2017-02-07 22:25:28 -05:00
Guangya Liu 9607edc556 Clean up for some typo.
1) Removed a space in portforward.go.
2) Renamed `lockAquisitionFunc` to `lockAcquisitionFunc` in
controller.go.
3) Fixed typo in predicates.go.
2017-02-08 09:39:03 +08:00
Kubernetes Submit Queue d404e07a72 Merge pull request #38183 from tianshapjq/remove-create-external-load-balancer
Automatic merge from submit-queue (batch tested with PRs 40345, 38183, 40236, 40861, 40900)

remove the create-external-load-balancer flag in cmd/expose.go

**What this PR does / why we need it**:
In cmd/expose.go there is a todo "remove create-external-load-balancer in code on or after Aug 25, 2016.", and now it's been a long time past. So I remove this flag and modify the test cases. 
Please check for this, thanks!

**Release note**:

```
remove the deprecated flag "create-external-load-balancer" and use --type="LoadBalancer" instead.
```
2017-02-07 11:33:41 -08:00
Brendan Burns d9c4a289a6 Extract strings for translation. 2017-02-06 22:32:01 -08:00
Kubernetes Submit Queue e0db0932a7 Merge pull request #40999 from xingzhou/tiny-bug
Automatic merge from submit-queue (batch tested with PRs 40385, 40786, 40999, 41026, 40996)

Fixed a tiny bug on using RoleBindingGenerator

Fixed a typo bug while using RoleBindingGenerator, this
bug causes error when binding role to service accounts
through "kubectl create rolebinding" command.
2017-02-06 16:51:08 -08:00
Xing Zhou 8db1cfc2f6 Fixed a tiny bug on using RoleBindingGenerator
Fixed a typo bug while using RoleBindingGenerator to bind
role to service accounts.
2017-02-06 16:00:51 +08:00
Xing Zhou 7a4293f6df Remove useless param from kubectl create rolebinding
The `force` param is not used in
`kubectl create rolebinding` & `kubectl create clusterrolebinding`
commands, removed it.
2017-02-06 15:49:43 +08:00
bruceauyeung eac48c2cd5 avoid repeated length calculation and some other code improvements
Signed-off-by: bruceauyeung <ouyang.qinhua@zte.com.cn>
2017-02-06 09:19:46 +08:00
Phillip Wittrock 9abd275607 Switch kubectl version and api-versions to create a discovery client directly.
The clientset will throw an error for aggregated apiservers because the
clientset looks for specific versions of apis that are compiled into
the client.  These will be missing from aggregated apiservers.
The discoveryclient is fully dynamic and does not rely on compiled
in apiversions.
2017-02-04 08:38:19 -08:00
Kubernetes Submit Queue 2541c16692 Merge pull request #40942 from ymqytw/extract_util_from_SMPatch
Automatic merge from submit-queue (batch tested with PRs 40289, 40877, 40879, 39972, 40942)

Extract util used by jsonmergepatch and SMPatch

followup  https://github.com/kubernetes/kubernetes/pull/40666#discussion_r99198931

Extract some util out of the `strategicMergePatch` to make `jsonMergePatch` doesn't depend on `strategicMergePatch`.

```release-note
None
```

cc: @liggitt
2017-02-04 04:43:10 -08:00
Kubernetes Submit Queue a2931c6218 Merge pull request #40289 from xilabao/fix-save-config-in-create-subcommand
Automatic merge from submit-queue

fix --save-config in create subcommand

--save-config option doesn't work.
```
#kubectl create rolebinding a --role=b --user=c --save-config  
rolebinding "a" created
```
old output:
```
#kubectl get rolebinding a -o yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
  creationTimestamp: 2017-01-23T10:09:48Z
  name: a
  namespace: default
  resourceVersion: "281"
  selfLink: /apis/rbac.authorization.k8s.io/v1beta1/namespaces/default/rolebindings/a
  uid: 12abccd6-e154-11e6-819c-525400f84377
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: b
subjects:
- apiVersion: rbac/v1alpha1
  kind: User
  name: c
```

expected output:
```
#kubectl get rolebinding a -o yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"kind":"RoleBinding","apiVersion":"rbac.authorization.k8s.io/v1beta1","metadata":{"name":"c","creationTimestamp":null},"subjects":[{"kind":"User","apiVersion":"rbac/v1alpha1","name":"c"}],"roleRef":{"apiGroup":"rbac.authorization.k8s.io","kind":"Role","name":"b"}}
  creationTimestamp: 2017-01-23T10:09:48Z
  name: a
  namespace: default
  resourceVersion: "281"
  selfLink: /apis/rbac.authorization.k8s.io/v1beta1/namespaces/default/rolebindings/a
  uid: 12abccd6-e154-11e6-819c-525400f84377
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: b
subjects:
- apiVersion: rbac/v1alpha1
  kind: User
  name: c
```
2017-02-04 04:40:29 -08:00
Jordan Liggitt c43192c0c1
Add edit command testcases 2017-02-04 00:11:30 -05:00
Jordan Liggitt 9af0dca52d
Log edit errors to stderr 2017-02-04 00:11:30 -05:00
Jordan Liggitt af3505f53c
Add unit test framework for edit command 2017-02-04 00:11:29 -05:00
ymqytw aadcd9b5e2 filter lastAppliedConfig annotation for describe secret 2017-02-03 17:17:20 -08:00
ymqytw a910284e17 extract util used by jsonmergepatch and SMPatch 2017-02-03 15:28:42 -08:00
Kubernetes Submit Queue 9642104e82 Merge pull request #39914 from kevin-wangzefeng/forgiveness-library-changes
Automatic merge from submit-queue (batch tested with PRs 40696, 39914, 40374)

Forgiveness library changes

**What this PR does / why we need it**:
Splited from #34825, contains library changes that are needed to implement forgiveness:

1. ~~make taints-tolerations matching respect timestamps, so that one toleration can just tolerate a taint for only a period of time.~~ As TaintManager is caching taints and observing taint changes, time-based checking is now outside the library (in TaintManager). see #40355.
2. make tolerations respect wildcard key.
3. add/refresh some related functions to wrap taints-tolerations operation.

**Which issue this PR fixes**: 
Related issue: #1574
Related PR: #34825, #39469 
~~Please note that the first 2 commits in this PR come from #39469 .~~

**Special notes for your reviewer**:

~~Since currently we have `pkg/api/helpers.go` and `pkg/api/v1/helpers.go`, there are some duplicated periods of code laying in these two files.~~

~~Ideally we should move taints-tolerations related functions into a separate package (pkg/util/taints), and make it a unified set of implementations. But I'd just suggest to do it in a follow-up PR after Forgiveness ones done, in case of feature Forgiveness getting blocked to long.~~

**Release note**:

```release-note
make tolerations respect wildcard key
```
2017-02-03 15:05:55 -08:00
tianshapjq 8057170588 gofmt the service_test.go 2017-02-03 08:55:41 +08:00
ymqytw ad7ffd79c3 apply falls back to generic 3-way JSON merge patch if no go struct is registered for the target GVK 2017-02-02 15:19:50 -08:00
Kubernetes Submit Queue 9721459536 Merge pull request #39279 from andrewsykim/kubectl-get-hpa-show-current-replicas
Automatic merge from submit-queue (batch tested with PRs 35782, 35831, 39279, 40853, 40867)

kubectl get hpa should print number of replicas

**What this PR does / why we need it**:
Prints number of replicas on deployment managed by HPA. 

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
None, couldn't find one related.

**Special notes for your reviewer**:
Couldn't find any tests for validating kubectl output for hpa, if there are please point me to them and I will add. 

**Release note**:

```release-note
```
2017-02-02 09:53:50 -08:00
Piotr Szczesniak a35ad8f6ba Removed HPA objects from extensions api group 2017-02-02 14:09:54 +01:00
Kubernetes Submit Queue 9807cd7d06 Merge pull request #40630 from liggitt/apply-null
Automatic merge from submit-queue (batch tested with PRs 40529, 40630)

propagate explicit nulls in apply

Rebase of https://github.com/kubernetes/kubernetes/pull/35496 on top of https://github.com/kubernetes/kubernetes/pull/40260

The client-side propagation of the raw value is no longer needed, since the client is preserving the original object in unstructured form (explicit nulls are preserved).

Kept tests and CreateThreeWayMergePatch changes from https://github.com/kubernetes/kubernetes/pull/35496

```release-note
kubectl apply now supports explicitly clearing values not present in the config by setting them to null
```

- [x] Clean up orphaned objects in test-cmd to preserve pre- and post- conditions
- [x] improve CreateThreeWayMergePatch test to not filter based on string comparison to test name
2017-02-01 00:16:39 -08:00
Kubernetes Submit Queue 61d45f5900 Merge pull request #40541 from fabianofranz/fix_sorting_printer_with_missing_fields
Automatic merge from submit-queue (batch tested with PRs 40645, 40541, 40769)

Fix sorting printer when sorting by a missing field

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

When calling `kubectl get` with the `--sort-by` flag, the command will error out if the field used for sorting is not present in at least one of the objects returned in the list, *even if it is a field valid in the object's model*. 

For example, taking a list of `ReplicationController` where one of them has `status: { replicas: 0 }` (so nothing in `status.availableReplicas`, even that being a valid object in the model and present in every other object of the list) :

```
$ oc get rc --sort-by=status.availableReplicas
error: availableReplicas is not found
```

This PR now traverses the entire list of objects to be sorted and, if at least one has the field provided in `--sort-by`, we sort correctly and consider the field empty in every other object where the field is not present. If none of the objects has the field, we error out (that will catch really invalid fields, and valid ones but not present in any object in the list, which is acceptable). No swagger validation here.

**Release note**:
```release-note
Fixed an issue where 'kubectl get --sort-by=' would return an error when the specified field were not present in at least one of the returned objects, even that being a valid field in the object model.
```
2017-01-31 22:00:38 -08:00
Kubernetes Submit Queue dcf26ed855 Merge pull request #40718 from janetkuo/secret-volume-describe-fix
Automatic merge from submit-queue (batch tested with PRs 40638, 40742, 40710, 40718, 40763)

Fix formatting issue of secret volume describer

Fixing a `kubectl describe` bug

**Before**:

```yaml
...
Volumes:
  default-token-z7g96:
    Type:       Secret (a volume populated by a Secret)
    SecretName:     Optional:   %v

%!(EXTRA string=default-token-z7g96, bool=false)QoS Class:      BestEffort
...
```

**After**:

```yaml
...
Volumes:
  default-token-z7g96:
    Type:       Secret (a volume populated by a Secret)
    SecretName: default-token-z7g96
    Optional:   false
QoS Class:      BestEffort
...
```
2017-01-31 20:40:46 -08:00
Kubernetes Submit Queue 76550cf2de Merge pull request #40710 from deads2k/client-21-record
Automatic merge from submit-queue (batch tested with PRs 40638, 40742, 40710, 40718, 40763)

move client/record

An attempt at moving client/record to client-go.  It's proving very stubborn and needs a lot manual intervention and near as I can tell, no one actually gets any benefit from the sink and source complexity it adds.

@sttts @caesarchaoxu
2017-01-31 20:40:45 -08:00
Kubernetes Submit Queue c09311fa32 Merge pull request #40111 from juanvallejo/jvallejo/add-ensure-print-headers
Automatic merge from submit-queue

Add printer#EnsurePrintHeaders method

This patch adds a new `EnsurePrintHeaders` method to the
HumanReadablePrinter `ResourcePrinter`, which allows headers to be
printed in cases where multiple lists of the same resource are printed
consecutively, but are separated by non-printer related information.

Related downstream PR: https://github.com/openshift/origin/pull/12528

**Release note**:
```release-note
release-note-none
```

cc @fabianofranz @AdoHe
2017-01-31 18:53:27 -08:00
deads2k 8a12000402 move client/record 2017-01-31 19:14:13 -05:00
Jordan Liggitt cf74abd892
fixup apply null tests 2017-01-31 15:00:23 -05:00
Anastasis Andronidis 4bdcc03c0b
test for explicit null value propagation in apply 2017-01-31 14:22:24 -05:00
deads2k 700c30f3c7 move portforward to client-go 2017-01-31 14:13:35 -05:00
Kevin 36dcb57407 forgiveness library changes 2017-01-31 21:39:17 +08:00
Kubernetes Submit Queue 25de8ef641 Merge pull request #40551 from juanvallejo/jvallejo/only-output-no-resources-found-for-human-readable-printer
Automatic merge from submit-queue (batch tested with PRs 40691, 40551, 40683, 40700, 40702)

only output "No resources found." for human readable printers

**Release note**:
```release-note
release note none
```

This patch removes the message `No resources found` (currently printed through stderr) when printing through a generic / non-human-readable printer (json, yaml, jsonpath, custom-columns).

**Before***
```
$ kubectl get pods -o json
No resources found.
{
    "apiVersion": "v1",
    "items": [],
    "kind": "List",
    "metadata": {},
    "resourceVersion": "",
    "selfLink": ""
}
```

**After**
```
$ kubectl get pods -o json
{
    "apiVersion": "v1",
    "items": [],
    "kind": "List",
    "metadata": {},
    "resourceVersion": "",
    "selfLink": ""
}
```

cc @fabianofranz @stevekuznetsov
2017-01-30 19:14:41 -08:00
Janet Kuo d76683be22 Fix formatting issue of secret volume describer 2017-01-30 18:40:12 -08:00
Kubernetes Submit Queue 9574ef54ec Merge pull request #40618 from janetkuo/patch-resource-name
Automatic merge from submit-queue (batch tested with PRs 40703, 40093, 40618, 40659, 39810)

Print resource name when patch is done

Before:
```console
$ kubectl patch deployment nginx -p '{"spec":{"progressDeadlineSeconds":200}}'
"nginx" patched
```

After:
```console
$ kubectl patch deployment nginx -p '{"spec":{"progressDeadlineSeconds":200}}'
deployment "nginx" patched
```
2017-01-30 17:14:54 -08:00
deads2k c9a008dff3 move util/intstr to apimachinery 2017-01-30 12:46:59 -05:00
Kubernetes Submit Queue 2cb17cc677 Merge pull request #40426 from sttts/sttts-more-cutoffs-3
Automatic merge from submit-queue

genericapiserver: cut off more dependencies – episode 3

Compare commit subjects.

This is the first step to get `apiserver_test.go` and `watch_test.go` in `pkg/genericapiserver/endpoints` cutoff from k8s.io/kubernetes dependencies.

After this we have to sync client-go and then "episode 4" can go in.

approved based on #40363
2017-01-30 05:57:49 -08:00
Brendan Burns eecfcfb376 Extract strings for the 'kubectl set' family of commands. 2017-01-29 14:46:07 -08:00
Dr. Stefan Schimanski 44ea6b3f30 Update generated files 2017-01-29 21:41:45 +01:00
Dr. Stefan Schimanski 79adb99a13 pkg/api: move Semantic equality to k8s.io/apimachinery/pkg/api/equality 2017-01-29 21:41:45 +01:00
Dr. Stefan Schimanski bc6fdd925d pkg/api/resource: move to apimachinery 2017-01-29 21:41:44 +01:00
Fabiano Franz 5eeef81edf Fix sorting printer with missing fields 2017-01-28 19:56:53 -02:00
Brendan Burns 25ba561702 Extract strings for translation for the kubectl config family. 2017-01-27 20:31:49 -08:00
Janet Kuo a155111acd Print resource name when patch is done 2017-01-27 14:58:52 -08:00
juanvallejo 5ec2a4c3ca only output "No resources found." for human readable printers 2017-01-27 13:30:23 -05:00
Jordan Liggitt 9013e8a7cf
Test cascading delete without client-side reaper does not GET 2017-01-27 09:18:48 -05:00
Kubernetes Submit Queue 1625150de8 Merge pull request #40260 from liggitt/kubectl-tpr
Automatic merge from submit-queue (batch tested with PRs 39223, 40260, 40082, 40389)

make kubectl generic commands work with unstructured objects

part of making apply, edit, label, annotate, and patch work with third party resources

fixes #35149
fixes #34413

prereq of:
https://github.com/kubernetes/kubernetes/issues/35496
https://github.com/kubernetes/kubernetes/pull/40096

related to:
https://github.com/kubernetes/kubernetes/issues/39906
https://github.com/kubernetes/kubernetes/issues/40119

kubectl is currently decoding any resource it doesn't have compiled-in to a ThirdPartyResourceData struct, which means it computes patches using that struct, and would try to send a ThirdPartyResourceData object to the API server when running `apply`

This PR removes the behavior that decodes unknown objects into ThirdPartyResourceData structs internally, and fixes up the following generic commands to work with unstructured objects

- [x] apply
  - [x] decode into runtime.Unstructured objects
  - [x] successfully use `--record` with unregistered objects 
- [x] patch
  - [x] decode into runtime.Unstructured objects
  - [x] successfully use `--record` with unregistered objects 
- [x] describe
  - [x] decode into runtime.Unstructured objects
  - [x] implement generic describer
- [x] fix other generic kubectl commands to work with unstructured objects
  - [x] label
  - [x] annotate

follow-ups for pre-existing issues:
- [ ] `explain` doesn't work with unregistered resources
- [ ] remove special casing of federation group in clientset lookups, etc
- [ ] `patch`
  - [ ] doesn't honor output formats when persisting to server (`kubectl patch -f svc.json --type merge -p '{}' -o json` doesn't output json)
  - [ ] --local throws exception (`kubectl patch -f svc.json --type merge -p '{}' --local`)
- [ ] `apply`
  - [ ] fall back to generic JSON patch computation if no go struct is registered for the target GVK (e.g. https://github.com/kubernetes/kubernetes/pull/40096)
  - [ ] ensure subkey deletion works in CreateThreeWayJSONMergePatch
  - [ ] ensure type stomping works in CreateThreeWayJSONMergePatch
  - [ ] lots of tests for generic json patch computation
  - [ ] prevent generic apply patch computation among different versions
  - [ ] reconcile treatment of nulls with https://github.com/kubernetes/kubernetes/pull/35496
- [ ] `edit`
  - [ ] decode into runtime.Unstructured objects
  - [ ] fall back to generic JSON patch computation if no go struct is registered for the target GVK
2017-01-27 05:41:45 -08:00
Kubernetes Submit Queue 10e3edcaa4 Merge pull request #39223 from brendandburns/i18n
Automatic merge from submit-queue (batch tested with PRs 39223, 40260, 40082, 40389)

Add a script to extract strings for translation and a sample of it's output

@fabianofranz @deads2k @kubernetes/sig-cli-pr-reviews
2017-01-27 05:41:44 -08:00
Jordan Liggitt 408a978f26
fix --record to work with unstructured objects 2017-01-26 19:59:27 -05:00
Jordan Liggitt c317f92990
patch: allow --local to use structs for strategic merge, warn about unknown objects 2017-01-26 19:59:26 -05:00
Jordan Liggitt 424dac921f
Fall back to unstructured typer retrieving GVKs for printing 2017-01-26 19:59:26 -05:00
Jordan Liggitt aaf96a1048
apply: use unstructured objects 2017-01-26 19:59:26 -05:00