Commit Graph

3495 Commits (532a9d78ad36922ee10cec7768d67c2c878a4175)

Author SHA1 Message Date
Kubernetes Submit Queue 7c656ab4d2 Merge pull request #45611 from atombender/issue-45608
Automatic merge from submit-queue (batch tested with PRs 48183, 45611, 48065)

kubectl: 'apply view-last-applied' must not use printf() semantics

**What this PR does / why we need it**:
This fixes `kubectl apply view-last-applied` to not use `fmt.Fprintf()`, as this will cause format codes in the YAML/JSON to be interpreted. For example, if a resource manifest contains `%r`, this would cause `view-last-applied` so print `%!r(MISSING)`.

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

**Special notes for your reviewer**:

**Release note**:

```release-note
Fixes an edge case where "kubectl apply view-last-applied" would emit garbage if the data contained Go format codes.
```
2017-06-28 12:55:21 -07:00
Alexander Campbell 6fd36c10ad kubectl/cmd: many small refactors
* Rename variables and functions to match Go convention.
   For example, UsageError --> UsageErrorf.
 * Remove redundant or unreachable code.
 * Simplify some utility functions (no functionality changes).
 * Fix hanging 'if { return } else { return }' constructs.
 * Fix several incorrect printf verbs.
2017-06-27 16:25:20 -07:00
Kubernetes Submit Queue 850a75fe13 Merge pull request #47675 from alexandercampbell/refactor-long-kubectl-function
Automatic merge from submit-queue (batch tested with PRs 47675, 48001)

cmd/create_deployment: refactor long function

Refactor the `createDeployment` function under `pkg/kubectl/cmd`.

- [x] Behavior has been extracted to two helper functions.
- [x] Behavior remains identical.
- [x] Logic has been made explicit through function naming and comments.

This is essentially the pattern I've been following in my larger branches (the ones that are pending the merge of #46468). Want to get some design feedback before I get too far away from `master`.

Thanks!

cc @apelisse @mengqiy @droot 

**Release note**:

```release-note
NONE
```
2017-06-27 16:11:03 -07:00
Alexander Campbell 14fc8782f5 cmd/run: use util function to deduplicate logic 2017-06-26 11:17:56 -07:00
Alexander Campbell b693c910f5 cmd/create_deployment: refactor & test long function 2017-06-26 11:17:53 -07:00
Clayton Coleman bdd3116c09
Move more printers to TablePrinter 2017-06-26 11:38:36 -04:00
Kubernetes Submit Queue d9ba19c751 Merge pull request #46468 from alexandercampbell/cleanup-in-kubectl
Automatic merge from submit-queue

Cleanup pkg/kubectl

I was reading through `pkg/kubectl` in preparation for completing https://github.com/kubernetes/kubectl/issues/11 and noticed several opportunities for improvement. This should be easy to review since it's mostly mechanical changes. The only complicated changes are in `addFromEnvFile`, which I refactored into two functions and wrote tests for.

**Release note**:

```release-note
NONE
```
2017-06-24 08:32:09 -07:00
Kubernetes Submit Queue a82c9ac2f2 Merge pull request #48016 from liggitt/api-versions-cache
Automatic merge from submit-queue (batch tested with PRs 47869, 48013, 48016, 48005)

Fix kubectl api-versions caching

xref https://github.com/kubernetes/kubectl/issues/41

The point of the `api-versions` and `version` commands is to ask the server for its API groups or versions, so we don't want to use cached data
2017-06-24 06:13:44 -07:00
Kubernetes Submit Queue ff108258bb Merge pull request #46220 from superbrothers/add-statefulset
Automatic merge from submit-queue (batch tested with PRs 47776, 46220, 46878, 47942, 47947)

Add statefulset to the completion candidates of kubectl scale

**What this PR does / why we need it**: This commit adds `statefulset` to the completion candidates of kubectl scale.
```
$ kubectl scale <tab>
deployment             job                    --replicas             replicaset             replicationcontroller  statefulset
```

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

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-06-24 04:15:50 -07:00
Jordan Liggitt fe8b5e9263
Fix kubectl api-versions caching 2017-06-24 01:14:31 -04:00
Kubernetes Submit Queue ed3c50a755 Merge pull request #47845 from liggitt/remove-redirect
Automatic merge from submit-queue (batch tested with PRs 47993, 47892, 47591, 47469, 47845)

Remove redirect verb parsing

The redirect verb was removed pre-1.0 in https://github.com/kubernetes/kubernetes/pull/9826 so the request parsing logic is dead code

Diff best viewed without whitespace:
https://github.com/kubernetes/kubernetes/pull/47845/files?w=1
2017-06-23 18:05:52 -07:00
Kubernetes Submit Queue 830c1b06b1 Merge pull request #43062 from mkumatag/genfed
Automatic merge from submit-queue

Enhance message in cluster-info dump

**What this PR does / why we need it**:
This PR fixes the information message prints in the end after the cluster-info dump command.
- Added newline in the end
- Enhanced the message for dumping information to standard out

**Which issue this PR fixes** *

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-06-23 12:30:25 -07:00
Alexander Campbell ac793982b0 kubectl: fix inaccurate usage messages for --windows-line-endings
Part of the problem is that these are duplicated between the different
commands. I'm planning to consolidate these further.
2017-06-23 09:49:30 -07:00
Alexander Campbell 63e9c67db8 kubectl: refactor addFromEnvFile, write tests 2017-06-23 09:49:30 -07:00
Alexander Campbell 7b54199fd5 kubectl: note a bug with a comment
This doesn't seem to be affecting anything and I'm not sure what the
correct behavior needs to be here. I'll highlight this in the code
review and hopefully work out a correct solution with the help of the
reviewers.
2017-06-23 09:49:30 -07:00
Alexander Campbell ef9ae61240 kubectl: simplify code with help of linter 2017-06-23 09:49:30 -07:00
Alexander Campbell 01ae6edc6c cmd: refactor common err expr into helper function
The same redundant fmt.Sprintf() and string literal was duplicated
throughout many of the files in kubectl/cmd. Replace with a helper
function.
2017-06-23 09:49:30 -07:00
Alexander Campbell 066dbb7206 cmd: make createDeployment a private function 2017-06-23 09:49:30 -07:00
Alexander Campbell f9913c4948 kubectl: rewrite docstrings in several files
Fixing inaccuracies and clarifying in the case of ambiguities.
2017-06-23 09:49:30 -07:00
Alexander Campbell d29560d89a kubectl: rename Run() -> RunRun() to clarify purpose
Run() is too overloaded in the codebase already. The other commands have
a pattern of RunExpose, RunScale, and so on. Since the command name is
"run", the associated function should be called RunRun.
2017-06-23 09:49:30 -07:00
Kubernetes Submit Queue ae9ca46927 Merge pull request #47694 from FengyunPan/display-service-type
Automatic merge from submit-queue (batch tested with PRs 47694, 47772, 47783, 47803, 47673)

Output TYPE for getting service

**What this PR does / why we need it**:
Now service already supported 4 ServiceTypes, ServiceTypes is
friendly to distinguish services, so outputing service type better
when running 'kubectl get service'.

**Release note**:
```release-note
  NONE
```
2017-06-23 08:29:23 -07:00
Kubernetes Submit Queue 8679677e87 Merge pull request #47579 from wanghaoran1988/fix_43322
Automatic merge from submit-queue (batch tested with PRs 47958, 46261, 46667, 47709, 47579)

Clean up Deployment overlap annotation code

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

**Special notes for your reviewer**:

**Release note**:

```
None
```
2017-06-23 07:21:36 -07:00
Kubernetes Submit Queue 60126b0ceb Merge pull request #47471 from crimsonfaith91/drain
Automatic merge from submit-queue (batch tested with PRs 46151, 47602, 47507, 46203, 47471)

deprecate created-by annotation for pod drain

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

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

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

**Release note**:

```release-note
```
2017-06-23 05:08:30 -07:00
Kubernetes Submit Queue 1864a2403c Merge pull request #46151 from verb/kubectl-featuregate
Automatic merge from submit-queue

Add alpha command to kubectl

Also allow new commands to disable themselves by returning a nil value. This can be used to disable commands based on feature gates.

**What this PR does / why we need it**: Method of enabling alpha functionality in kubectl

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

**Special notes for your reviewer**: Part of a discussion in #45922 with @pwittrock

**Release note**:

```release-note
NONE
```
2017-06-23 05:00:35 -07:00
Kubernetes Submit Queue 8ba08c9528 Merge pull request #46906 from zhangxiaoyu-zidif/Add-testcase-for-namespace
Automatic merge from submit-queue (batch tested with PRs 47403, 46646, 46906, 46527, 46792)

Add test case for namespace

**What this PR does / why we need it**:
Unit test case need add that when name is "".

**Special notes for your reviewer**:
refer to https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/namespace.go#L74

**Release note**:

```release-note
NONE
```
2017-06-23 02:59:27 -07:00
Kubernetes Submit Queue 4db120cc04 Merge pull request #46688 from zhangxiaoyu-zidif/change-method-kubectl-configmap
Automatic merge from submit-queue

Fix error message of isDir

**What this PR does / why we need it**:
Use IsRegular to replace isDir
Accoding to the code logic, using IsRegular is proper.
 
**Release note**:

```release-note
NONE
```
2017-06-23 01:58:14 -07:00
Kubernetes Submit Queue 475f175e68 Merge pull request #46495 from zjj2wry/pdb
Automatic merge from submit-queue

add test for kubectl create pdb

**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-06-23 01:00:17 -07:00
Kubernetes Submit Queue 625a980941 Merge pull request #46696 from xiangpengzhao/mark-deprecated-command
Automatic merge from submit-queue (batch tested with PRs 47227, 47119, 46280, 47414, 46696)

Mark deprecated info in short description of deprecated commands.

**What this PR does / why we need it**:
Mark deprecated commands in 'kubectl help'. See https://github.com/kubernetes/kubectl/issues/20

**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/kubectl/issues/20

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-06-22 23:59:28 -07:00
Chao Xu 60604f8818 run hack/update-all 2017-06-22 11:31:03 -07:00
Chao Xu 239613b521 manually fix kubectl openapi unit test 2017-06-22 11:31:02 -07:00
Chao Xu f2d3220a11 run root-rewrite-import-client-go-api-types 2017-06-22 11:30:59 -07:00
Chao Xu cde4772928 run ./root-rewrite-all-other-apis.sh, then run make all, pkg/... compiles 2017-06-22 11:30:52 -07:00
Chao Xu f4989a45a5 run root-rewrite-v1-..., compile 2017-06-22 10:25:57 -07:00
Jordan Liggitt e8b24679dc
Remove redirect verb parsing 2017-06-21 11:17:24 -04:00
FengyunPan f01f9a9035 Output TYPE for getting service
Now service already supported 4 ServiceTypes, ServiceTypes is
friendly to distinguish services, so outputing service type better
when running 'kubectl get service'.
2017-06-18 12:19:57 +08:00
Kubernetes Submit Queue 48d263d3bf Merge pull request #44282 from derekwaynecarr/fix-kubectl-logs
Automatic merge from submit-queue (batch tested with PRs 38751, 44282, 46382, 47603, 47606)

kubectl logs with label selector supports specifying a container name

**What this PR does / why we need it**:
Allows `kubectl logs` to take both a label selector and container name.  This allows me to fetch logs from pods by selector whose pods have multiple containers with a common name.  This is a common action when debugging components like the service-catalog that ship more than one container in their pod.  With this change, the following command lets me get logs for service-catalog.

```
$ kubectl logs -l app=sc-catalog-apiserver --namespace=service-catalog --container=apiserver
```
2017-06-16 18:05:48 -07:00
Jun Xiang Tee d76b08d154 deprecate created-by annotation for pod drain 2017-06-16 13:33:26 -07:00
Kubernetes Submit Queue c31893978b Merge pull request #45918 from juanvallejo/jvallejo/fix-kubectl-set-resources-local
Automatic merge from submit-queue

fix --local flag for kubectl commands

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

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

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


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

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

cc @smarterclayton @fabianofranz
2017-06-16 08:19:13 -07:00
Lee Verberne 01c7d129fb Create a kubectl alpha subcommand
Alpha commands can be added under `kubectl alpha` and are always
accessible (regardless of feature gates). If no alpha commands have been
defined then `alpha` is not displayed in `help`.
2017-06-16 07:09:21 +00:00
Haoran Wang f732e4baae Clean up Deployment overlap annotation code 2017-06-16 14:20:44 +08:00
Kubernetes Submit Queue a36d9df224 Merge pull request #47450 from kargakis/fix-drain
Automatic merge from submit-queue (batch tested with PRs 47523, 47438, 47550, 47450, 47612)

Ignore 404s on evict

One of our upgrades failed with 
```
error: error when evicting pod \"boo-2-deploy\": pods \"boo-2-deploy\" not found"
```

@derekwaynecarr since you already fixed half of it 

cc: @kubernetes/sig-cli-bugs 

I failed terribly at adding a unit test mostly because draining involves discovery for the eviction API and the fake client stuff for discovery are far from functional - will spawn a separate issue about it.

fyi @jupierce

related: https://github.com/kubernetes/kubectl/issues/28
2017-06-15 18:54:06 -07:00
Kubernetes Submit Queue ef20034a04 Merge pull request #47204 from janetkuo/kubectl-apply-change-cause
Automatic merge from submit-queue (batch tested with PRs 47204, 46808, 47432, 47400, 47099)

Make kubectl apply add change-cause before patching

**What this PR does / why we need it**: We shouldn't patch the project with applied change, and then patch again with the change cause. Otherwise, DaemonSet change cause wouldn't be copied to its history (after the first patch, history will be created with the old change cause). 

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

**Special notes for your reviewer**: 
/assign @mengqiy 
@kubernetes/sig-apps-bugs @kubernetes/sig-cli-maintainers 

**Release note**:

```release-note
NONE
```
2017-06-14 17:13:54 -07:00
Kubernetes Submit Queue d067836030 Merge pull request #46852 from tnozicka/lookup-no-headers-safely
Automatic merge from submit-queue (batch tested with PRs 47470, 47260, 47411, 46852, 46135)

Lookup --no-headers flag safely in PrinterForCommand function

If this was invoked by a command that did not call AddPrinterFlags first, it ended up with fatal error on `GetFlagBool(cmd, "no-headers")`. This is causing a bug in OpenShift's command reusing this code and not actually having a flag `--no-headers`.
2017-06-14 12:52:24 -07:00
Kubernetes Submit Queue 7560142e27 Merge pull request #47276 from kow3ns/rm-partition-strategy
Automatic merge from submit-queue (batch tested with PRs 46441, 43987, 46921, 46823, 47276)

Remove PartitionStatefulSetStrategyType

This PR removes PartitionStatefulSetStrategyType add adds a parameter to RollingUpdateStatefulSetStrategyType as described in the issue below. We need this PR to ensure that the StatefulSet API conforms to the existing API for DaemonSet.

fixes #46975
```release-note
NONE
```
@kargakis 
@smarterclayton 
@janetkuo
2017-06-13 13:55:53 -07:00
Michail Kargakis 26d3eadb46
Ignore 404s on evict 2017-06-13 20:21:26 +02:00
juanvallejo d036686185
fix --local flag for `kubectl set` commands 2017-06-13 12:57:05 -04:00
Janet Kuo 03af5233bd Make kubectl apply add change-cause before patching 2017-06-12 23:49:42 -07:00
Kubernetes Submit Queue aa35738a21 Merge pull request #47075 from janetkuo/ds-history-patch
Automatic merge from submit-queue

Change what is stored in DaemonSet history `.data`

**What this PR does / why we need it**: 
In DaemonSet history `.data`, store a strategic merge patch that can be applied to restore a DaemonSet. Only PodSpecTemplate is saved. 

This will become consistent with the data stored in StatefulSet history. 

Before this fix, a serialized pod template is stored in `.data`; however, seriazlized pod template isn't a `runtime.RawExtension`, and caused problems when controllers try to patch the history's controller ref. 

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

**Special notes for your reviewer**: @kubernetes/sig-apps-bugs @erictune @kow3ns @kargakis @lukaszo @mengqiy 

**Release note**:

```release-note
NONE
```
2017-06-12 23:31:08 -07:00
Kenneth Owens 22957a6bb1 Update StatefulSet rollout status for parameterized RollingUpdate 2017-06-12 10:07:07 -07:00
Tomas Nozicka eb139f4572 Lookup --no-headers flag safely in PrinterForCommand function 2017-06-12 17:30:26 +02:00