Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubectl get deployments #20009

Merged
merged 2 commits into from
Jan 30, 2016

Conversation

janetkuo
Copy link
Member

Print different replicas of deployments.

$ kubectl get deployments nginx-deployment
NAME               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
nginx-deployment   3         3         3            3           3m

cc @nikhiljindal @Kargakis @bgrant0607 @kubernetes/kubectl

@0xmichalis
Copy link
Contributor

LGTM

General observation: UPDATEDREPLICAS is probably confusing

@k8s-github-robot
Copy link

Labelling this PR as size/M

@k8s-github-robot k8s-github-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 22, 2016
@bgrant0607
Copy link
Member

Please use _ as the word separator (and add this to kubectl conventions if it isn't there).

How about REPLICAS (desired), CURRENT, UP_TO_DATE, and AVAILABLE.

At some point, we should reconcile with RC and RS columns.

@k8s-bot
Copy link

k8s-bot commented Jan 22, 2016

GCE e2e test build/test passed for commit bff6e32e449f111890350ec477268d2a35c67931.

@bgrant0607
Copy link
Member

RC columns are:

"CONTROLLER", "CONTAINER(S)", "IMAGE(S)", "SELECTOR", "REPLICAS", "AGE"

Fields that contain lists (containers, images, selector) make the output wide and hard to read, so I don't think we should just copy this. For instance, I don't think containers and selector are very important here. Existing label options should satisfy most of the use cases for the selector, and images (and their tags) are more important than the container names.

I'd list the first image, appended with +N for the number of other containers, if any.

@bgrant0607
Copy link
Member

See also #19775

@janetkuo
Copy link
Member Author

If we use IMAGE(S), and REPLICAS, CURRENT, UP_TO_DATE, and AVAILABLE, it looks like this:

$ kubectl get deployments nginx-deployment
NAME               IMAGE(S)   REPLICAS  CURRENT  UP_TO_DATE  AVAILABLE   AGE
nginx-deployment   nginx(+2)  3         3        3           3           1s

I think CURRENT, UP_TO_DATE, and AVAILABLE are a bit vague without "REPLICAS", but REPLICAS is too long. hpa uses PODS instead of REPLICAS in printer header. So how about:

$ kubectl get deployments nginx-deployment
NAME               IMAGE(S)   DESIRED_PODS  CURRENT_PODS  UP_TO_DATE_PODS  AVAILABLE_PODS   AGE
nginx-deployment   nginx(+2)  3             3             3                3                1s

or we can use two-line header:

$ kubectl get deployments nginx-deployment
NAME               IMAGE(S)   DESIRED   CURRENT  UP_TO_DATE  AVAILABLE   AGE
                              REPLICAS  REPLICAS REPLICAS    REPLICAS 
nginx-deployment   nginx(+2)  3         3        3           3           1s

or we merge replicas together:

$ kubectl get deployments nginx-deployment
NAME               IMAGE(S)   CURRENT/UP_TO_DATE/AVAILABLE/DESIRED_PODS   AGE
nginx-deployment   nginx(+2)  3/3/3/3                                     1s

@ghodss
Copy link
Contributor

ghodss commented Jan 23, 2016

@janetkuo I would go with your first option, but without IMAGES.

While it's true that the columns are vague at first, I think it's just a small learning curve that's okay to incur, especially if kubectl describe writes out the equivalent columns with the "repliacs" suffix. So:

$ kubectl get deployments nginx-deployment
NAME              DESIRED   CURRENT  UP_TO_DATE  AVAILABLE   AGE
nginx-deployment  3         3        3           3           1s
$ kubectl describe deployments nginx-deployment
Name: nginx-deployment
Desired replicas: 3
Current replicas: 3
Up to date replicas: 3
Available replicas: 3
...

That way if someone doesn't understand the column names they can just run describe and pretty quickly realize what they mean. We also can update the deployment user guide to explain the columns.

As for listing IMAGE(S):

  1. It can get very wide for images in a local registry + a customized version tag (one sample image name from us: docker-registry-vip.dev.box.net/jenkins/convert-mon:0.0.0-21.2015_12_31_22_37_37.56e95-image-16)
  2. It provides minimal value here since you might accidentally show a sidecar image
  3. The name is probably enough to have an idea of what images exist.

I wrote out a similar case in #19775.

@bgrant0607
Copy link
Member

I like the proposal from @ghodss.

We can add images later, maybe under -o wide. FWIW, I intended the +N for other containers in the pod, not other replicas or revisions. We could strip off the registry. It might even make sense to just show the tag.

@janetkuo janetkuo added this to the v1.2 milestone Jan 23, 2016
@bgrant0607
Copy link
Member

Note that status is a long-requested feature #7483. We should add status summaries to ReplicaSet as well at some point.

@ghodss
Copy link
Contributor

ghodss commented Jan 25, 2016

One other suggestion - can we do UP TO DATE with spaces instead of underscores? I think underscores looks very unnatural, and the padding between columns is two spaces so there's minimal risk of it seeming like it's multiple columns. See docker's ps command as an example of using spaces:

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
$

I personally think it would look much worse with underscores:

$ docker ps
CONTAINER_ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
$

netstat uses spaces:

$ netstat -anlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:33895           0.0.0.0:*               LISTEN      -
...

Other examples usually make the columns more cryptic rather than resort to word separators:

$ ps axu
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.3  46264  6156 ?        Ss   Jan24   0:02 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root         2  0.0  0.0      0     0 ?        S    Jan24   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    Jan24   0:16 [ksoftirqd/0]
...
$ fleetctl list-unit-files
UNIT          HASH    DSTATE   STATE    TMACHINE
hello.service e55c0ae inactive inactive -
$ w
USER     TTY      FROM              LOGIN@  IDLE WHAT
sam      console  -                13Jan16 11days -
sam      s000     -                13Jan16 10:51 -bash
sam      s001     -                13Jan16     - tmux

I haven't found any command line tool that uses underscores as separators.

tl;dr I think spaces are the best balance between readability and usability.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 25, 2016
@bgrant0607
Copy link
Member

@ghodss The reason I don't like spaces in column headers or contents is because that's unfriendly to column extraction (e.g., cut).

@bgrant0607
Copy link
Member

I also find the netstat output hard to read due to the single spaces between some columns (esp. Send-Q and "Local Address").

@bgrant0607
Copy link
Member

-o wide (#19775) can be implemented in a followup PR and doesn't necessarily need to be in 1.2. Just omit those wide fields from this PR.

@ghodss
Copy link
Contributor

ghodss commented Jan 26, 2016

@ghodss The reason I don't like spaces in column headers or contents is because that's unfriendly to column extraction (e.g., cut).

If you're extracting columns, there's a high likelihood you're doing some processing and would want to use --no-headers anyways. I would suggest starting with the friendlier version (single spaces) as convention and moving away if there are complaints.

Also as I was thinking more about this case, up-to-date is often hyphenated in plan English, so maybe UP-TO-DATE is acceptable.

@janetkuo janetkuo force-pushed the kubectl-get-deployments branch from bff6e32 to abc9a75 Compare January 29, 2016 03:22
@janetkuo
Copy link
Member Author

@bgrant0607 Comments addressed, PTAL.
Sample output:

$ kubectl get deployments nginx-deployment
NAME               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
nginx-deployment   3         3         3            3           3m

kubectl convention doc is updated too.

@janetkuo janetkuo removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 29, 2016
@k8s-github-robot
Copy link

Labelling this PR as size/S

@k8s-github-robot k8s-github-robot removed the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Jan 29, 2016
@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 29, 2016
@@ -110,7 +110,7 @@ Updated: 8/27/2015
* However, affordances are made for simple parsing of `get` output
* Only errors should be directed to stderr
* `get` commands should output one row per resource, and one resource per row
* Column titles and values should not contain spaces in order to facilitate commands that break lines into fields: cut, awk, etc.
* Column titles and values should not contain spaces in order to facilitate commands that break lines into fields: cut, awk, etc. Instead, use `_` as the word separator.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use dash. :-)

Could you change this to dash and then also change CLUSTER_IP and EXTERNAL_IP to match the convention?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@bgrant0607
Copy link
Member

Mostly LG except for underscore vs. dash.

@janetkuo janetkuo force-pushed the kubectl-get-deployments branch from abc9a75 to 07290ac Compare January 29, 2016 04:07
@janetkuo
Copy link
Member Author

@bgrant0607 All comments addressed. PTAL.

@janetkuo janetkuo force-pushed the kubectl-get-deployments branch from 07290ac to fa25e29 Compare January 29, 2016 04:12
@k8s-bot
Copy link

k8s-bot commented Jan 29, 2016

GCE e2e test build/test passed for commit abc9a75121b98bf466453c042e70b1ebc29a723a.

@k8s-bot
Copy link

k8s-bot commented Jan 29, 2016

GCE e2e test build/test passed for commit 07290ac574a7f0bf5133026242015be16fc72f22.

@k8s-bot
Copy link

k8s-bot commented Jan 29, 2016

GCE e2e test build/test passed for commit fa25e29.

@bgrant0607
Copy link
Member

LGTM

@bgrant0607 bgrant0607 added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 29, 2016
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Jan 30, 2016

GCE e2e test build/test passed for commit fa25e29.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

k8s-github-robot pushed a commit that referenced this pull request Jan 30, 2016
@k8s-github-robot k8s-github-robot merged commit 311d8f8 into kubernetes:master Jan 30, 2016
xingzhou pushed a commit to xingzhou/kubernetes that referenced this pull request Dec 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants