Commit Graph

184 Commits (d8205661b700c6f99c33ea0ac1e5ed3e49c202b2)

Author SHA1 Message Date
Cao Shufeng 292b18db1f enhance kubectl run error message
Before this change:
 # kubectl run nginx
 error: Invalid image name "": invalid reference format

After this change:
 # kubectl run nginx
 error: --image is required
2017-07-26 11:24:03 +08:00
ymqytw 3dfc8bf7f3 update import 2017-07-20 11:03:49 -07:00
Kubernetes Submit Queue 575cbdf7d4 Merge pull request #45012 from xiangpengzhao/fix-delete-svc
Automatic merge from submit-queue

Remove service on termination when exec 'kubectl run' command with flags "--rm" and "--expose"

**What this PR does / why we need it**:
As the title says and issue #40504 mentioned.
cc @tanapoln

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

**Special notes for your reviewer**:
Related to: #44915

**Release note**:

```release-note
NONE
```
2017-07-19 07:59:34 -07:00
Jordan Liggitt e8f2879bfd
Allow setting service account with kubectl run 2017-07-15 12:37:10 -04:00
Kubernetes Submit Queue fdb3b2af70 Merge pull request #48578 from fabianofranz/run_output_message_on_container_error
Automatic merge from submit-queue (batch tested with PRs 48578, 48895, 48958)

run must output message on container error

**What this PR does / why we need it**: `kubectl run` must output a message (instead of just exiting with an error code) on container error.

**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/openshift/origin/issues/15031 found in OpenShift

**Release note**:

```release-note
NONE
```
2017-07-14 13:45:51 -07:00
Kubernetes Submit Queue cd3f8c3963 Merge pull request #47460 from mengqiy/fix_env
Automatic merge from submit-queue (batch tested with PRs 48402, 47203, 47460, 48335, 48322)

fix kubectl run --env flag

fixes: kubernetes/kubectl#19

cc: @ddcprg

```release-note
`kubectl run --env` no longer supports CSV parsing. To provide multiple env vars, use the `--env` flag multiple times instead of having env vars separated by commas. E.g. `--env ONE=1 --env TWO=2` instead of `--env ONE=1,TWO=2`.
```
2017-07-11 21:01:35 -07:00
Fabiano Franz f623b9b42f run must output message on container error 2017-07-07 00:33:48 -03: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
Alexander Campbell 14fc8782f5 cmd/run: use util function to deduplicate logic 2017-06-26 11:17:56 -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
xiangpengzhao aef9f38baf Remove service on termination when exec 'kubectl run' command with flags "--rm" and "--expose" 2017-06-23 11:36:40 +08:00
Chao Xu 60604f8818 run hack/update-all 2017-06-22 11:31:03 -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
ymqytw b99e57149d fix env flag 2017-06-13 14:53:09 -07:00
juanvallejo d036686185
fix --local flag for `kubectl set` commands 2017-06-13 12:57:05 -04:00
Alexander Campbell 9e7f29c3fb cmd: fix deprecation warning bug
Some kubectl commands were deprecated but would fail to print the
correct warning message when a flag was given before the command name.

	# Correctly prints the warning that "resize" is deprecated and
	# "scale" is now preferred.
	kubectl scale [...]

	# Should print the same warning but no warning is printed.
	kubectl --v=1 scale [...]

This was due to a fragile check on os.Args[1].

This commit implements a new function deprecatedCmd() that is used to
construct new "passthrough" commands which are marked as deprecated and
hidden.

Note that there is an existing "filters" system that may be preferable
to the system created in this commit. I'm not sure why the "filters"
array was not used for all deprecated commands in the first place.
2017-05-18 16:48:13 -07:00
Kubernetes Submit Queue d6fd997d44 Merge pull request #41530 from bruceauyeung/k8s-branch-do-not-use-underscores-in-go-variable-names
Automatic merge from submit-queue

rename variables to make sure that they conform to golang variable name conventions

rename variables to make sure that they conform to golang variable name conventions

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

there are lots of package level unexported variables in package `cmd` not conforming golang variable name conventions, such as `version_example`, in this PR i rename all of them to make sure that they conform to golang variable name conventions
2017-04-28 09:28:13 -07:00
Kubernetes Submit Queue 65838085b0 Merge pull request #43618 from xilabao/fix-kubectl-run-output
Automatic merge from submit-queue (batch tested with PRs 44970, 43618)

fix kubectl run output

fixes https://github.com/kubernetes/kubernetes/issues/40440
2017-04-26 22:58:13 -07:00
bruceauyeung ab4029c85b Signed-off-by: bruceauyeung <ouyang.qinhua@zte.com.cn>
rename variables to make sure that they conform to golang variable name convention
2017-04-25 15:07:01 +08: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
Brendan Burns 79f51923d3 Extract a bunch more strings from kubectl 2017-04-06 20:12:50 -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 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
xilabao 757d12a211 fix kubectl run output 2017-03-24 17:08:49 +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
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
xilabao 131802a5cd add secret flag to options 2017-02-25 23:40:50 +08:00
Brendan Burns f1de40b448 Extract some flag description strings to be translated. 2017-02-21 22:07:30 -08:00
Brendan Burns d9c4a289a6 Extract strings for translation. 2017-02-06 22:32:01 -08:00
deads2k 2734f8f892 move dynamic and discovery clients 2017-01-26 08:37:06 -05:00
Clayton Coleman 469df12038
refactor: move ListOptions references to metav1 2017-01-23 17:52:46 -05:00
Clayton Coleman 9a2a50cda7
refactor: use metav1.ObjectMeta in other types 2017-01-17 16:17:19 -05:00
Maciej Szulik 4a0c9fa536 Fix ScheduledJob -> CronJob rename leftovers 2017-01-17 09:24:07 +01:00
deads2k 77b4d55982 mechanical 2017-01-16 09:35:12 -05:00
deads2k 6a4d5cd7cc start the apimachinery repo 2017-01-11 09:09:48 -05:00
Maciej Szulik 9f064c57ce Remove extensions/v1beta1 Job 2016-12-17 00:07:24 +01:00
Kubernetes Submit Queue b9536688d3 Merge pull request #38429 from duglin/removeDelete
Automatic merge from submit-queue (batch tested with PRs 37860, 38429, 38451, 36050, 38463)

Remove "pod xxx deleted" message from kubectl run --rm

This is a follow-on to https://github.com/kubernetes/kubernetes/issues/28695

Its unnecessary to print the message when the user asked for it.
We should only show a msg (error) when we didn't do what they asked.
Also showing this in a "kubectl run" is bad because it then
gets appended to the user's output and they would then have to strip
it off if they want to use the output in some follow-on processing.

Signed-off-by: Doug Davis <dug@us.ibm.com>

```release-note
kubectl run --rm no longer prints "pod xxx deleted"
```
2016-12-09 13:22:14 -08:00
Kubernetes Submit Queue 5628cde1bd Merge pull request #37164 from duglin/removeWaiting
Automatic merge from submit-queue (batch tested with PRs 38413, 37164)

Remove chatty "waiting for pod" msg from kubectl run

Attacking #28695 one step at a time

Signed-off-by: Doug Davis <dug@us.ibm.com>
2016-12-08 18:08:55 -08:00
Doug Davis 24fbba393e Remove "pod xxx deleted" message from kubectl run --rm
Its unnecessary to print the message when the user asked for it.
We should only show a msg (error) when we didn't do what they asked.
Also showing this in a "kubectl run" is bad because it then
gets appended to the user's output and they would then have to strip
it off if they want to use the output in some follow-on processing.

Signed-off-by: Doug Davis <dug@us.ibm.com>
2016-12-08 17:40:08 -08:00
Dr. Stefan Schimanski 458d2b2fe4 Add verb support for discovery client 2016-12-05 12:36:05 +01:00
Clayton Coleman 3454a8d52c
refactor: update bazel, codec, and gofmt 2016-12-03 19:10:53 -05:00
Clayton Coleman 5df8cc39c9
refactor: generated 2016-12-03 19:10:46 -05:00
Doug Davis c5387eebe4 Remove chatty "waiting for pod" msg from kubectl run
Attacking #28695 one step at a time

Signed-off-by: Doug Davis <dug@us.ibm.com>
2016-12-01 17:46:04 -08:00
Kubernetes Submit Queue 9ccc291e8a Merge pull request #37263 from smarterclayton/wait_on_immediate
Automatic merge from submit-queue

When --grace-period=0 is provided, wait for deletion

The grace-period is automatically set to 1 unless --force is provided, and the client waits until the object is deleted.

This preserves backwards compatibility with 1.4 and earlier. It does not handle scenarios where the object is deleted and a new object is created with the same name because we don't have the initial object loaded (and that's a larger change for 1.5).

Fixes #37117 by relaxing the guarantees provided.

```release-note
When deleting an object with `--grace-period=0`, the client will begin a graceful deletion and wait until the resource is fully deleted.  To force deletion, use the `--force` flag.
```
2016-11-30 11:15:17 -08:00
Clayton Coleman 35a6bfbcee
generated: refactor 2016-11-23 22:30:47 -06:00
Clayton Coleman 7cdb6b169d
When --grace-period=0 is provided, wait for deletion
The grace-period is automatically set to 1 unless --force is provided,
and the client waits until the object is deleted.

This preserves backwards compatibility with 1.4 and earlier. It does not
handle scenarios where the object is deleted and a new object is created
with the same name.
2016-11-23 15:02:43 -06:00