Commit Graph

168 Commits

Author SHA1 Message Date
k8s-merge-robot
fe07ca6c86 Merge pull request #27379 from juanvallejo/jvallejo_kube-get-all-show-kind-in-headers
Automatic merge from submit-queue

Update "kubectl get all" to display resource type as part of name

fixes #23838
release-note-none

When running "kubectl get all", or printing any output with mixed resource kinds, an additional column is added to the output with each resource's kind:

`kubectl get all --all-namespaces`
```
NAMESPACE     NAME                         DESIRED          CURRENT       AGE
default       rc/docker-registry-1         1                1             23h
testproject   rc/node-1                    0                0             2d
NAMESPACE     NAME                         CLUSTER-IP       EXTERNAL-IP   PORT(S)                 AGE
default       svc/docker-registry          172.30.36.42     <none>        5000/TCP                23h
default       svc/kubernetes               172.30.0.1       <none>        443/TCP,53/UDP,53/TCP   7d
testproject   svc/ruby-ex                  172.30.187.128   <none>        8080/TCP                6d
NAMESPACE     NAME                         READY            STATUS        RESTARTS                AGE
default       po/docker-registry-1-cpf8o   1/1              Running       1                       23h
```

[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/.github/PULL_REQUEST_TEMPLATE.md?pixel)]()
2016-07-01 14:15:05 -07:00
juanvallejo
7df60d6b64 display resource type as part of its name 2016-07-01 12:58:02 -04:00
Andy Goldstein
67d929a3d2 Return immediately for singular get on error
Return immediately when attempting to get a singular resource that isn't found, so that we avoid
printing out a List if the output format is something like json or yaml.

Before:

```
$ kubectl get pod/foo -o yaml
apiVersion: v1
items: []
kind: List
metadata: {}
pods "foo" not found
```

After:

```
$ kubectl get pod/foo -o yaml
pods "foo" not found
```
2016-06-30 12:28:51 -04:00
David McMahon
ef0c9f0c5b Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
Michael Rubin
760b04e294 Use dedent for the kubectl commands
The one side effect is that for the "kubectl help" commands a newline
is prepended to output, which will alter the yaml output.

Here we use dedent to format the code to match the output.

hack/update-generated-docs.sh has been run and the affected files have
been added.

Note: for describe.go we added a period to the end of an output message.
2016-06-26 22:51:14 -07:00
Mike Metral
4409eed57f fix recursive & non-recursive kubectl get of generic output format 2016-06-02 21:46:15 -07:00
Mike Metral
950612eb5f fix recursive get for proper err display 2016-05-24 20:05:07 -07:00
Jeff Lowdermilk
e9aecf6b9e Merge pull request #25181 from janetkuo/kubectl-suggest
kubectl suggest for get (list, ps), and delete(rm)
2016-05-13 10:08:22 -07:00
Clayton Coleman
51b624103f
Change ConvertToVersion to use GroupVersion
Long delayed refactor, avoids a few more allocations.
2016-05-12 10:10:35 -04:00
Janet Kuo
181627e36c kubectl suggest for get (list, ps), and delete(rm) 2016-05-04 17:18:52 -07:00
Mike Metral
999c8e211e allow kubectl subcmds to process multiple resources
- use resource.Visit() to recursively process resources, as well as, aggregate
errors where possible
2016-05-01 20:27:37 -07:00
Dr. Stefan Schimanski
7e0bb885f1 Make kubectl bash completion namespace aware and add noun aliases
- add namespace filtering to bash completion
- add --namespace flag bash completion
- add bash completion noun aliases
- adapt to new cobra package structure
2016-04-03 16:25:56 +02:00
Brendan Burns
be6c5b332b Add third party support to kubectl 2016-03-31 10:53:32 -07:00
Mike Metral
7403878ac0 allow kubectl cmd to process dirs recursively
reqs:
    - the kubectl cmd must support the -f | --filename flag
    - the kubectl cmd must support visiting a dir one level deep,
    or using more than one resource
2016-03-28 12:44:21 -07:00
Janet Kuo
e93b855242 Update kubectl help for 1.2 resources 2016-03-22 14:14:35 -07:00
nikhiljindal
593b78f925 Deprecating --api-version flag 2016-03-11 10:12:44 -08:00
Avesh Agarwal
be06003e6b Fix kubectl sort-by metadata issue.
Internal types are not supposed to have json metadata (though in kubernetes
they do) as it is true with openshift types. That means sort-by must work
on versioned objects for sorting, otherwise it produces "error: metadata
is not found" error if it sorts internal types without json metadata.

This PR converts internal types objects to versioned objects and sort-by
sorts them correctly without medata error, and then it prints
corresponding internal objects in sorted order.
2016-03-04 16:14:45 -05:00
AdoHe
9cc668f7c6 update commented examples just remove $ 2016-02-29 09:41:09 -05:00
k8s-merge-robot
68a5641eb8 Merge pull request #20803 from aveshagarwal/master-sortby-indentation-issue
Auto commit by PR queue bot
2016-02-19 00:33:00 -08:00
Avesh Agarwal
c0e1623be2 Fix kubectl get error when both all-namespaces and namespace are provided.
As per kubectl get help, --namespace should be ignored with all-namespaces,
but kubectl get pods --all-namespaces --namespace=<name-space> gives
following error:

"the namespace from the provided object "default" does not match the
namespace "". You must pass '--namespace=default' to perform this
operation."

This commit fixes this error issue.
2016-02-11 17:06:04 -05:00
Avesh Agarwal
5fbede0428 Fix sort-by indentation issue. 2016-02-08 02:53:00 -05:00
AdoHe
714d12cf72 kubectl add show-labels flag to make it more readable 2016-02-04 02:08:44 -05:00
Avesh Agarwal
bec2d678b9 Fix panic when sort-by is used with kubectl get. 2016-01-26 13:58:24 -05:00
Clayton Coleman
2fd38a7dc0 Break kubectl from assuming details of codecs
Most of the logic related to type and kind retrieval belongs in the
codec, not in the various classes. Make it explicit that the codec
should handle these details.

Factory now returns a universal Decoder and a JSONEncoder to assist code
in kubectl that needs to specifically deal with JSON serialization
(apply, merge, patch, edit, jsonpath). Add comments to indicate the
serialization is explicit in those places. These methods decode to
internal and encode to the preferred API version as previous, although
in the future they may be changed.

React to removing Codec from version interfaces and RESTMapping by
passing it in to all the places that it is needed.
2016-01-22 13:27:26 -05:00
Brendan Burns
4123a61df7 Add the client side bits of kubectl export 2015-12-22 10:41:59 -08:00
Fabiano Franz
717896eae3 Fixes get --show-all 2015-12-17 18:35:54 -02:00
Maciej Szulik
34c72552a5 Updated kubectl help info with resource names 2015-12-10 16:04:44 +01:00
k8s-merge-robot
637a33924c Merge pull request #18004 from jiangyaoguo/print-absolute-time-when-watch-event
Auto commit by PR queue bot
2015-12-08 22:58:12 -08:00
deads2k
66eecb963a update more kubectl bits for groupversion 2015-12-07 09:01:44 -05:00
jiangyaoguo
7153ff80ff print absolute time when watch event 2015-12-05 13:52:53 +08:00
deads2k
a87d927588 update client.Config to use GroupVersion 2015-11-21 08:29:26 -05:00
Jerzy Szczepkowski
cac9e88c11 Updated kubectl help messages.
Updated kubectl help messages: added info about hpa. Fixes #17357.
2015-11-19 15:26:43 +01:00
Mike Danese
1e3da330f4 don't print resources twice in kubectl get 2015-11-08 21:42:52 -08:00
k8s-merge-robot
4de560389d Merge pull request #15928 from brendandburns/sort2
Auto commit by PR queue bot
2015-11-07 01:03:15 -08:00
huangyuqi
1bf2f869c7 add valid resource types for kubectl get 2015-11-04 10:12:30 +00:00
Brendan Burns
2935075388 Fix sorting from 2 bugs 2015-10-22 20:11:14 -07:00
k8s-merge-robot
77207d75e1 Merge pull request #15667 from JanetKuo/kubectl-watch-list
Auto commit by PR queue bot
2015-10-19 06:28:35 -07:00
Janet Kuo
33b9235312 Better error handling for watching a list of resources specified in a file 2015-10-14 16:38:03 -07:00
Janet Kuo
b9c8b76b6b address comments 2015-10-13 18:48:27 -07:00
Janet Kuo
f39fe2056d Keep Flatten() and format output earlier in kubectl get 2015-10-13 18:48:27 -07:00
Janet Kuo
1f35cf2e5b Fix get with List 2015-10-05 11:44:57 -07:00
k8s-merge-robot
381a723814 Merge pull request #13532 from JanetKuo/kubectl-dont-use-specific-printer
Auto commit by PR queue bot
2015-09-10 14:39:02 -07:00
Avesh Agarwal
6d6f338fac Adds servicesaccounts to kubectl get/describe cli help and docs. 2015-09-09 12:15:25 -04:00
Jan Chaloupka
70c74fbe4b Commit cd7d78b696 replaced use of
util.CheckErr(err)

with

if err != nil {
	return err
}

One replacement is incorrent. The current call of resource.NewBuilder is returned in r variable. Which was tested with util.CheckErr(r.Err()) before cd7d78b696 commit. It was replaced by

if err != nil {
	return err
}

which is incorrect as err is not set by resource.NewBuilder call. The correct use is

err := r.Err()
if err != nil {
	return err
}
2015-09-09 12:40:55 +02:00
Dai Zuozhuo
2e2ef3e830 change -o template to -o go-template=... 2015-09-05 22:30:47 +08:00
Janet Kuo
96031aaca5 Get printer from factory instead of using NewHumanReadablePrinter to retrieve handled resources 2015-09-02 15:38:40 -07:00
deads2k
f1b81ff678 bind filenames var instead of looking up 2015-09-01 08:35:57 -04:00
hurf
d2d96ff6e1 Add -o name for commands which use printer to output results
Added a new printer which prints 'resource/name' pair of a given
object.
2015-08-26 17:04:23 +08:00
Janet Kuo
0bcb3147f6 Deprecated -t for --template to make it --tty 2015-08-24 02:16:01 -07:00
Zach Loafman
5ca0ca3d3f Merge pull request #9787 from feihujiang/acceptErrorLikeGoPath
Make a change to visitor to allow it to accept an error, like Go's pa…
2015-08-21 15:17:58 -07:00
feihujiang
29dc7f6ec2 Make a change to visitor to allow it to accept an error, like Go's path walker 2015-08-20 10:57:28 +08:00
Dai Zuozhuo
85972c44a4 jsonpath user guide docs 2015-08-20 09:11:04 +08:00
Dai Zuozhuo
b61a905b19 add jsonpath to kubectl 2015-08-20 08:57:24 +08:00
Janet Kuo
44a7a52a94 Hide failed/succeeded pods in 'kubectl get pods' by default 2015-08-18 13:47:19 -07:00
feihujiang
18a1400928 Kubectl get command accepts a filename param 2015-08-13 14:12:29 +08:00
Peeyush Agarwal
05e069d038 Use bash comments in kubectl examples
Comments in kubectl examples should use bash comments, not Go comments.
So, replaces // by # for example strings.
2015-08-12 19:56:23 +00:00
Eric Paris
7cbb52ce04 Use the pflag StringSlice instead of implementing it ourselves
Saves code and makes our code easier to read because we just use normal
[]string instead of custom type.
2015-08-06 19:16:13 -04:00
Mike Danese
8e33cbfa28 rewrite go imports 2015-08-05 17:30:03 -07:00
hurf
33fb6170f9 Use TYPE instead of RESOURCE in help string
For commands in kubectl, use TYPE in help string.
2015-08-05 16:34:48 +08:00
hurf
029ed15be5 Better help message for get and describe
Add tips for shortcut ns and ep.
2015-07-31 15:15:51 +08:00
hurf
4f9c486308 Fix hits in help strings of kubectl get command
Removed duplicated 'nodes (no)', added 'secret' for resource type.
Use actual long resource name to avoid confusion.
2015-07-15 09:43:51 +08:00
hurf
6dd8a1dfa4 Add a better help message for kubectl describe
When resource type isn't given in the command, print the possible
resource types. Also added the resource type description in help
strings.
2015-07-14 16:22:42 +08:00
Joe Beda
0426ab3290 Update list of resources for 'kubectl get' help output. 2015-07-09 08:59:32 -07:00
Zach Loafman
5dbe90f0ba Merge pull request #10493 from krousey/namespace
Unify command line namespace resolution
2015-07-01 19:33:44 -07:00
Kris Rousey
ffa764d60b Unify command line namespace resolution
This change allows the namespace in kubeconfig to be overridden by
specifying the namespace in the spec file. If namespace is explicitly
provided in the command line flags and the spec file has a different
namespace, this will cause an error.
2015-07-01 12:59:17 -07:00
Janet Kuo
682734bcc7 Implement 'kubectl get ... -o wide' 2015-06-30 14:06:47 -07:00
Anastasis Andronidis
b06ef70057 Print resource labels as columns 2015-06-22 00:44:51 +02:00
Brendan Burns
b259c873b7 Add a better message if the user doesn't specify a resource type. 2015-06-09 15:04:56 -07:00
Kris Rousey
6e83eb2636 Updating docs/ to v1 2015-06-05 14:09:49 -07:00
Jeff Lowdermilk
0c44be833d Stop supporting the minion alias for nodes in kubectl 2015-05-29 15:40:47 -07:00
Anastasis Andronidis
9cb0eaf01a Fixed get's help message 2015-05-29 11:31:16 +02:00
Masahiro Sano
8ce64ec69e add --all-namespaces flag to request across all namespaces 2015-05-22 23:25:12 +09:00
Chao Xu
bda5e4376e in docs, update "minions" to "nodes" 2015-05-21 09:59:40 -07:00
Chao Xu
5b8b5a0844 in docs, update replicationController to replicationcontroller 2015-05-20 17:31:15 -07:00
Eric Paris
6b3a6e6b98 Make copyright ownership statement generic
Instead of saying "Google Inc." (which is not always correct) say "The
Kubernetes Authors", which is generic.
2015-05-01 17:49:56 -04:00
Clayton Coleman
545a5a865f List output with differing types should be more resilient
kubectl get can output a series of objects as a List in versioned
form, but not all API objects are available in the same schema.
Make the act of converting a []runtime.Object to api.List more
robust and add a test to verify its behavior in Get.

Makes it easier for client code to output unified objects.
2015-04-20 14:44:16 -04:00
Fabio Yeon
951a125751 Add "componentstatus" to API for easier cluster health check. 2015-04-17 11:58:23 -07:00
Eric Paris
c75ecbd8e3 bash_completions: annotate kubectl get with resources which can be 'gotten'
A user types:
  kubectl get $resource

This will cause the bash completions to suggest the possible objects the
user can ask for.  The complete list right now is:

endpoints
event
limitrange
namespace
node
persistentvolume
persistentvolumeclaim
pod
replicationcontroller
resourcequota
secret
service
status

But this list should stay up2date as api objects are added or deleted
2015-04-13 19:11:26 -04:00
nikhiljindal
fe60be3179 Moving v1beta1 kubectl examples to v1beta3 2015-04-08 13:08:13 -07:00
deads2k
6344cf3c3a refactor to move kubectl.cmd.Factory to kubect/cmd/util 2015-04-07 14:43:50 -04:00
nikhiljindal
f2b72931fc Updating components to use v1beta3 2015-04-03 15:19:14 -07:00
Young
84bfda0587 remove cmd arg
related issue "Remove cmd from kubectl/cmd/factory arguments #4470"
2015-03-27 21:46:17 +08:00
Clayton Coleman
581d7cd789 Allow resource.Builder commands to take arguments by type/name
Will allow xarg behavior to fetch resources across multiple types.
Changes 'create', 'get', 'update', 'stop', and 'delete' to output
<resourceType>/<name>.
2015-03-25 20:39:22 -04:00
Tamer Tas
b39e31d8a3 Remove cmd from kubectl/cmd/factory 2015-03-18 14:23:14 +02:00
Jeff Lowdermilk
a5746c9a0e Fix md generation for kubectl docs
Display usage string, not long help, as code, remove angle brackets from
output (.md interprets as tags and hides).
2015-03-11 16:42:40 -07:00
Jeff Lowdermilk
cd7d78b696 Make kubectl commands return errors and centralize exit handling 2015-03-10 10:19:43 -07:00
Brendan Burns
f505a33998 Differentiate between server error messages and client error messages in kubectl 2015-03-07 11:39:23 +01:00
Clayton Coleman
b799e8cd3a Enumerate all versions when looking for an output conversion
Ensures that all objects can be printed, even if they don't
match output-version (because they are only implemented in
a newer API version).
2015-03-04 10:48:05 -05:00
Eric Paris
d508395828 Change all cobra commands to use the example section
This will output the examples in their own section, rather than as part
of the 'long' synposis.
2015-02-20 16:41:31 -05:00
Salvatore Dario Minonne
fda17c1b7a kubectl delete resource : remove all resources 2015-02-13 18:25:41 +01:00
MikeJeffrey
ca1e9f8061 Comments go above the sample line in kubectl docs. 2015-02-12 15:49:25 -08:00
MikeJeffrey
e5459c8802 Clean up kubectl help for auto-gen'd kubectl.md 2015-02-10 12:02:05 -08:00
Brendan Burns
e7b11d09de Add some error checking to prevent obscure failures. 2015-02-10 06:32:26 -08:00
Jeff Lowdermilk
d46ae5d841 Refactor kubectl/cmd helpers into pkg/kubectl/cmd/util
Allows helpers to be used by config commands.
2015-02-05 09:39:42 -08:00
deads2k
dd01137138 add namespace to kubeconfig file 2015-01-20 16:07:54 -05:00
Andrew Seidl
6dee1d7fa4 Fix typos in user-facing strings 2015-01-18 01:32:34 -06:00
Brendan Burns
1ce6c27f3d Add an initial run command 2015-01-13 20:00:29 -08:00
Clayton Coleman
30743b8195 The get command should properly handle users providing invalid apiversions
Add more guards against bad behavior.  A follow up commit will ensure that
when the flags for api-version are specified, they default to the correct
values that client.SetKubernetesDefaults would use.
2015-01-13 18:51:55 -05:00
Clayton Coleman
d1ab27762b Create should be able to accept multiple resources 2015-01-09 13:30:31 -05:00
Clayton Coleman
2151afe334 Allow kubectl get to fetch multiple resource types
Like Delete, which can now run over multiple types:

    kubectl delete pods,services -l name=foo

Get should be able to span items for label selection

    kubectl get pods,services -l name=foo
2015-01-09 13:30:14 -05:00