-
Notifications
You must be signed in to change notification settings - Fork 42.1k
Add optional colors for kubectl printing... #40963
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
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED The following people have approved this PR: brendandburns Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
|
Why color the name column instead of the status column? The users eye will need to go the status column anyway on a failure, and so this actually makes it harder to spot invalid items in that case (makes the user do more work, because the color will pull the eye). Likewise, for normal operation the color against a black background makes the name harder to read in the "normal" case, which makes the user do more work to scan a list. |
|
Generally you want color to pull the eye to the spot that is abnormal, not to anchor it on the things that are "normal". I might suggest we want the entire row to be bold on error, and normal weight on normal status. Finally, all this is moving to the server side, so doing this now is putting extra weight on clients now that complicates that design (or is at minimum an extra requirement). How is this going to work for third party resources? I'd like to keep this really minimal for right now, and not complicate those other efforts that are actually required in the short term. |
|
@smarterclayton we're moving human readable printing server side? That can't be right... Feedback on the colors and coloring the name vs. the status makes sense to me, though I think there's a degree to wanting a measure of the pod "health" in general. e.g. number of restarts, number of containers running, etc. all contribute to a pods "healthiness" I worry that we'll end up with lots of different colors if we don't focus on coloring the entire row a single shade... (I'd be open to coloring the entire row, or restricting coloring only to "abnormal" rows) |
|
Is this going to work consistently across different terminals? Is it something that has been discussed in @kubernetes/sig-cli-misc ? |
| podColor = "<fg 11>" // yellow | ||
| } | ||
| if readyContainers == 0 { | ||
| podColor = "<fg 1>" // red |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry that we'll end up with lots of different colors if we don't focus on coloring the entire row a single shade...
Based on this comment, and @smarterclayton's feedback, perhaps we could keep red for rows where the pod status is failing, and no color / how it is currently for any other case. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that works for me. I'd love to have yellow for "warning" (pending, some restarts recently, etc) and "red" for "not working"
I'll update the pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still haven't seen this one addressed. Additionally if I add watch flag I'm getting:
$ kubectl get pods --color -w
NAME READY STATUS RESTARTS AGE
<fg 2>hello-5b209<reset> 1/1 Running 0 18s
and that's definitely not what I'd expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the benefit, but we need to reconcile this with kubernetes/community#363
|
@Kargakis this should work across all Xterm capable terminals. It is off by default as well (and I think it will be off by default for a long time) so I think we don't have to have perfect fidelity everywhere, since it will only affect people who opt into it. |
|
Also, @smarterclayton considering the server side bits, the colors actually come as a markup language, so I think that will actually make it easier for the server side, since the server can return markup colors and the client can figure out how to render them. |
|
My $0.02, why coloring would ever belong to server side? I can understand the desire to have a consistent output across client apps, but coloring should belong to client app, imho. The server side printing is a whole different story and I do have a mixed feelings about it, too. 👍 for having color emphasize the abnormal state and none for ok. |
|
@soltysh I agree entirely, and honestly this is why I have significant concerns about server-side printing. However, if we move table-based printing to the server, the information needed to do the color-based decision making will be lost and stored on the server, not in the client, so the server would be the only place to make that decision. |
|
Friendly ping on this. Thanks |
|
I like the idea of making it opt-in at least until it stabilizes. Any strong reason for choosing that particular library? When I R&D about colors a few months ago I found https://github.com/fatih/color, it supports Windows |
|
@k8s-bot test this |
|
@brendandburns: The following test(s) failed:
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
That will only be true for the extended printing options, that @smarterclayton is proposing, right? |
| podColor = "<fg 11>" // yellow | ||
| } | ||
| if readyContainers == 0 { | ||
| podColor = "<fg 1>" // red |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still haven't seen this one addressed. Additionally if I add watch flag I'm getting:
$ kubectl get pods --color -w
NAME READY STATUS RESTARTS AGE
<fg 2>hello-5b209<reset> 1/1 Running 0 18s
and that's definitely not what I'd expect.
|
@fabianofranz I actually started this PR using https://github.com/fatih/color. The trouble that I ran into was that the colorization characters broke the golang TabWriter class, see this question: http://stackoverflow.com/questions/35398497/how-do-i-get-colors-to-work-with-golang-tabwriter for someone who ran into the same problem. Because this library uses markup, and you can train @soltysh will work on getting the comments/problems addressed. Thanks! |
|
@brendandburns PR needs rebase |
|
fwiw, it turns out we already colorize: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/clusterinfo.go#L126 |
|
I'd like this to be done under the context of moving to the server side,
rather than be add before it lands and complicate it. I think color will
help some, but I don't want to add more features to printing until the
proposals are approved for server side, and no one is broken without it.
Hopefully this has enough context that you can describe in the proposal
what usecases are necessary (at least at a first glance, we want to flag
cells with informational bits like "alert" or "warn").
On Mar 13, 2017, at 12:49 AM, Brendan Burns <[email protected]> wrote:
fwiw, it turns out we already colorize:
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/clusterinfo.go#L126
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#40963 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p5V9a_C44wVmETjIPtmkAXb7W96Gks5rlMrRgaJpZM4L3EaZ>
.
|
|
As the carrot, the backend glue is all prototyped, so working together
could get it into place fairly quickly.
On Mar 13, 2017, at 12:49 AM, Brendan Burns <[email protected]> wrote:
fwiw, it turns out we already colorize:
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/clusterinfo.go#L126
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#40963 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p5V9a_C44wVmETjIPtmkAXb7W96Gks5rlMrRgaJpZM4L3EaZ>
.
|
|
@smarterclayton where is the proposal for server-side printing? I'm happy to pile on there. |
|
@brendandburns proposal: kubernetes/community#363, prototype: #40848 |
| ShowLabels: GetFlagBool(cmd, "show-labels"), | ||
| AbsoluteTimestamps: isWatch(cmd), | ||
| ColumnLabels: columnLabel, | ||
| Color: GetFlagBool(cmd, "color"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this detect whether a terminal is attached or not, as well?
| "k8s.io/kubernetes/pkg/util/i18n" | ||
| "k8s.io/kubernetes/pkg/util/interrupt" | ||
|
|
||
| "github.com/reconquest/loreley" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT, this doesn't have a license. We can't merge this.
We need a verify script to look for this type of thing. It's repeatedly caused us grief.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #44505
|
BTW, I also want to nuke the kubeconfig preferences section, which contains only the colors preference currently. #10693 |
|
This PR hasn't been active in 90 days. Closing this PR. Please reopen if you would like to work towards merging this change, if/when the PR is ready for the next round of review. cc @brendandburns @fabianofranz You can add 'keep-open' label to prevent this from happening again, or add a comment to keep it open another 90 days |

@kubernetes/sig-cli-pr-reviews
This PR adds an initial path for optional color support.
Currently:
Will print colorized output.
Eventually, I will add an environment variable as well. (and colors for other things)