hidetatz / kubecolor Goto Github PK
View Code? Open in Web Editor NEWcolorizes kubectl output
License: MIT License
colorizes kubectl output
License: MIT License
While I believe kubecolor colorizes the kubectl output nicely, I don't think current implementation is best. The better color schema might be found in the future.
Now, there are a lot of color schema change requests:
It will be possible to implement all the things, but I'm concerned the kubecolor will be not very simple and not easy to use. In the first place, this kind of thing is completely personal preference.
In my opinion, we have to options:
# ~/.config/kubecolor/schema.yml
dark: true
color:
get:
base_color: blue
warn_color: red
highlight_crush_loop_backoff: true
...
Two things on the second option:
I don't want to make kubecolor too complicated, I want to keep it simple as much as possible. However, the really useful feature should be builtin without configuration file.
I want to gather the opinion.
Hi!
Thank you for such a good tool!
I found an panic error when use Krew:
k krew version
panic: runtime error: index out of range [1] with length 1
goroutine 18 [running]:
github.com/dty1er/kubecolor/printer.(*VersionPrinter).Print(0xc000014088, 0x5400c0, 0xc0000ac028, 0x5400e0, 0xc0000ac008)
/home/runner/work/kubecolor/kubecolor/printer/kubectl_version.go:41 +0xd7a
github.com/dty1er/kubecolor/printer.(*KubectlOutputColoredPrinter).Print(0xc000094350, 0x5400c0, 0xc0000ac028, 0x5400e0, 0xc0000ac008)
/home/runner/work/kubecolor/kubecolor/printer/kubectl_output_colored_printer.go:109 +0x15e
github.com/dty1er/kubecolor/command.Run.func1(0xc0000ba0c0, 0x5405e0, 0xc0000ac028, 0xc0000a8050)
/home/runner/work/kubecolor/kubecolor/command/runner.go:89 +0x9b
created by github.com/dty1er/kubecolor/command.Run
/home/runner/work/kubecolor/kubecolor/command/runner.go:88 +0x43d
It should be:
k krew version
OPTION VALUE
GitTag v0.4.0
GitCommit 8bebb56
IndexURI https://github.com/kubernetes-sigs/krew-index.git
kubectl version
k version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"clean", BuildDate:"2021-04-08T16:31:21Z", GoVersion:"go1.16.1", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.16-gke.2100", GitCommit:"36d0b0a39224fef7a40df3d2bc61dfd96c8c7f6a", GitTreeState:"clean", BuildDate:"2021-03-16T09:15:29Z", GoVersion:"go1.13.15b4", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.21) and server (1.18) exceeds the supported minor version skew of +/-1
Please check
I like to run a constantly refreshing kubectl get pods -A
command in a specified interval using watch
(in mac & linux) or while (1) {clear; <command_here>; sleep <interval_in_seconds>}
(in windows powershell).
It would be nice conditional coloring for STATUS columns values just like the READY column:
For example: yellow for "Pending"/"Init:....", red for "Terminating"/"CrashLoopBackOff", green for "Running", grey for "Completed" etc.
Using the 'watch' command with 'kubecolor' does not colorize, example:
watch -n5 kubecolor get all
output:
NAME READY STATUS RESTARTS AGE
pod/nfs-client-provisioner-f9c9cd856-g26ks 1/1 Running 0 24h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.233.0.1 <none> 443/TCP 235d
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nfs-client-provisioner 1/1 1 1 24h
NAME DESIRED CURRENT READY AGE
replicaset.apps/nfs-client-provisioner-f9c9cd856 1 1 1 24h
Using the parameter: --force-colors
watch -n5 kubecolor --force-colors get all
output:
^[37mNAME READY STATUS RESTARTS AGE^[0m
^[36mpod/nfs-client-provisioner-f9c9cd856-g26ks^[0m ^[32m1/1^[0m ^[35mRunning^[0m ^[37m0^[0m ^[33m24h^[0m
^[37m^[0m
^[37mNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)AGE^[0m
^[36mservice/kubernetes^[0m ^[36mClusterIP^[0m ^[32m10.233.0.1^[0m ^[35m<none>^[0m ^[37m443/TCP^[0m ^[33m235d^[0m
^[37m^[0m
^[37mNAME READY UP-TO-DATE AVAILABLE AGE^[0m
^[36mdeployment.apps/nfs-client-provisioner^[0m ^[36m1/1^[0m ^[32m1^[0m ^[35m1^[0m ^[33m24h^[0m
^[37m^[0m
^[37mNAME DESIRED CURRENT READY AGE^[0m
^[36mreplicaset.apps/nfs-client-provisioner-f9c9cd856^[0m ^[37m1^[0m ^[33m1^[0m ^[36m1^[0m ^[32m24h^[0m
I can help if needed....
using kubecolor with oc
running this command
oc adm create-bootstrap-project-template -o yaml > /tmp/project-template.yaml
creates a file that looks like this.
A simple fix is to escape the alias.
\oc adm create-bootstrap-project-template -o yaml > /tmp/project-template.yaml
I realize this is outside of the intended scope.
Just thought I'd report in case anyone else has the issue.
I've noticed recently that kubecolor
is adding symbols such as $'\033'\[33m
when I press tab for autocomplete. I am using the kubectl
plugin for oh-my-zsh
. My shell is zsh
. Pure /bin/kubectl
autocomplete works fine.
I have another computer with the same setup (using dotfiles) where the same problems occur, having exactly the same zsh/oh-my-zsh/kubectl/kubecolor
versions.
Feature request: kubectl get events
should highlight errors/warnings in a different color
Hi!
This looks like a nice and useful project. I like colors. I switched from curl to httpie because colors.
Would you be interested in me attempting to colorize kubectl apply? Currently it is all green. I'd like it to be mostly white, with separate colors for actions that are "unchanged", "created", "configured", etc.
I've not looked at the code so I don't know if it fits. Let me know. Any other tips for an implementation would be welcome.
Cheers
Per.
kubecolor 0.0.7: kubecolor apply -f foo.yaml -o yaml
Actual result: all yaml output is green.
Expected result: it would be great if the yaml output would be nicely colored like with kubecolor get pods -o yaml
.
I tried to enable the autocompletion for kubecolor following instructions on the official README:
Basically, configuring autocompletion for kubecolor requires adding following line in your shell config file.
# autocomplete for kubecolor complete -o default -F __start_kubectl kubecolorIf you are using an alias like k="kubecolor", then just change above like:
complete -o default -F __start_kubectl k
but it does not work, no autocompletion for kubecolor and even worse no autocompletion anymore for k
alias!
Here some info:
k
alias set and autocompletion properly working (without enabling kubecolor autocompletion)Here the output of kubectl version
command:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.2", GitCommit:"faecb196815e248d3ecfb03c680a4507229c2a56", GitTreeState:"clean", BuildDate:"2021-01-14T05:14:17Z", GoVersion:"go1.15.6", Compiler:"gc", Platform:"darwin/amd64"}
Any help is really appreciated!!
I followed the readme file and did the installation. After that the kubecolor command does not work.
I think it it would be nice to have diff colors similar to helm diff
, currently the entire output looks green
Output different color for pod lifecycle. Currently is shows only one color.
It will be great if it shows a different color for each pod lifecycle. which will help to easily identify
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/
Instructions say:
go install github.com/hidetatz/kubecolor/cmd/kubecolor@latest
But this results in:
go install: github.com/hidetatz/kubecolor/cmd/kubecolor@latest: github.com/hidetatz/[email protected]: parsing go.mod:
module declares its path as: github.com/dty1er/kubecolor
but was required as: github.com/hidetatz/kubecolor
As of now, pods that are not in ready status has a light yellow colour. It would be great to have the ability to change the colour (may be red) of the whole line.
kubecolor describe node xxx
Capacity:
attachable-volumes-gce-pd:panic: runtime error: index out of range [0] with length 0
goroutine 6 [running]:
github.com/dty1er/kubecolor/printer.(*DescribePrinter).Print(0xc000100f08, 0x535320, 0xc00000e030)
/home/vlad/dev/oss/kubecolor/printer/describe.go:93 +0xc84
github.com/dty1er/kubecolor/printer.Print(0x535320, 0xc00000e030, 0x535340, 0xc00000e018, 0xc000018980, 0x1)
/home/vlad/dev/oss/kubecolor/printer/printer.go:81 +0x292
github.com/dty1er/kubecolor/command.Run.func7()
/home/vlad/dev/oss/kubecolor/command/runner.go:79 +0x97
github.com/dty1er/kubecolor/command.runAsync.func1(0xc000076810, 0xc000016150)
/home/vlad/dev/oss/kubecolor/command/runner.go:95 +0x27
created by github.com/dty1er/kubecolor/command.runAsync
/home/vlad/dev/oss/kubecolor/command/runner.go:94 +0x6e
Can we please add logic to always pass through the output of kubecolor.exe __complete
in plain text. Without this in plain text it breaks the auto-completion in Powershell since Powershell calls this function to receive next arguments for auto-completion. Since users are not calling this directly it should not impact general workflow of kubecolor.
As a temporary workaround, I had this added in my Powershell autocomplete script
if(((Get-Alias kubectl).Definition) -eq 'kubecolor'){
$Program = $Program + ' --plain'
}
I'm new at golang but happy to take a stab with some hand holding :)
Failed message:
➜ ~ brew install hidetatz/tap/kubecolor
Error: hidetatz/tap/kubecolor: wrong number of arguments (given 1, expected 0)
Please let me know for any more information
Currently kubecolor can be installed via go get
, but ideally it should not be depending on go command. We should:
Hello @dty1er
I have kubecolor
updated after running go get -u github.com/dty1er/kubecolor/cmd/kubecolor
. I also have the following in my.zshrc
# kubecolor
alias kubectl=kubecolor
complete -o default -F __start_kubectl kubectl
So, when I typed kubectl
command, my autocomplete did not work. Then, I removed the above kubecolor config in my .zshrc
, and ran source ~/.zshrc
to get the latest changes on my src file.
I re-tried kubectl
again, and the autocomplete still did not work.
After I removed that kubecolor config, I checked the following:
▶ which kubectl
kubectl: aliased to kubecolor
▶ which kubecolor
/Users/lpurba/go/bin/kubecolor
Why the autocomplete did not work? Also, after removing kubecolor config and source
ing the src file, why my kubectl
was still an alias of kubecolor
?
Having autocomplete is very helpful. I appreciate your help
Thank you,
Laurentius
==> Tapping hidetatz/tap
Cloning into '/usr/local/Homebrew/Library/Taps/hidetatz/homebrew-tap'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 59 (delta 12), reused 8 (delta 0), pack-reused 0
Receiving objects: 100% (59/59), 7.89 KiB | 2.63 MiB/s, done.
Resolving deltas: 100% (12/12), done.
Error: Invalid formula: /usr/local/Homebrew/Library/Taps/hidetatz/homebrew-tap/Formula/kubecolor.rb
kubecolor: Calling bottle :unneeded is disabled! There is no replacement.
Please report this issue to the hidetatz/tap tap (not Homebrew/brew or Homebrew/core):
/usr/local/Homebrew/Library/Taps/hidetatz/homebrew-tap/Formula/kubecolor.rb:9
Error: Cannot tap hidetatz/tap: invalid syntax in tap!
Failed to install [hidetatz/tap/kubecolor]
Some packages were not installed
==> Some tasks were not executed successfully
Unsure where the error is, seems in brew formula
i have inconsistent output (sometime dup, sometime disappear, order change) when i use kubecolor versus direct kubectl
i launch it 4 times
i expect to have the same output as with kubectl with color of course
zsh 5.8
kubectl v1.21.0
kubecolor 0.0.20
Hello all,
I am trying to test Ephemeral Container using kube version v1.23.5
after entering kubectl debug -it ephemeral-demo --image=busybox:1.35 --target=ephemeral-demo
i can see 2 issues..
When i remove alias kubectl=kubecolor
it works as expected
Any workaround to fix this issue without removing?
Hello!
Thanks for very useful tool.
I'm using kubecolor on macos with zsh, iTerm2 with ligth theme (Solarized Light). And I want to configure kubecolor to always use --light-background
.
Regards :)
I'm running kubectl run -i --tty busybox --image=busybox --restart=Never -- sh. the shell would not echo any character inputed.
after entering enter, the commands are executed but the output is not readable.
If you don't see a command prompt, try pressing enter.
/ #
/ # ls
bin dev etc home proc root sys tmp usr var
brew install hidetatz/tap/kubecolor
Running `brew update --preinstall`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
fclones
==> Tapping hidetatz/tap
Cloning into '/home/pepodev/.linuxbrew/Homebrew/Library/Taps/hidetatz/homebrew-tap'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 59 (delta 12), reused 8 (delta 0), pack-reused 0
Receiving objects: 100% (59/59), 7.89 KiB | 2.63 MiB/s, done.
Resolving deltas: 100% (12/12), done.
Error: Invalid formula: /home/pepodev/.linuxbrew/Homebrew/Library/Taps/hidetatz/homebrew-tap/Formula/kubecolor.rb
kubecolor: Calling bottle :unneeded is disabled! There is no replacement.
Please report this issue to the hidetatz/tap tap (not Homebrew/brew or Homebrew/core):
/home/pepodev/.linuxbrew/Homebrew/Library/Taps/hidetatz/homebrew-tap/Formula/kubecolor.rb:9
Error: Cannot tap hidetatz/tap: invalid syntax in tap!
Instructions say:
go get -u github.com/hidetatz/kubecolor/cmd/kubecolor
But this results in
go get: github.com/hidetatz/[email protected]: parsing go.mod:
module declares its path as: github.com/dty1er/kubecolor
but was required as: github.com/hidetatz/kubecolor
brew install hidetatz/tap/kubecolor
==> Tapping hidetatz/tap
Cloning into '/usr/local/Homebrew/Library/Taps/hidetatz/homebrew-tap'...
remote: Enumerating objects: 59, done.
remote: Counting objects: 100% (59/59), done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 59 (delta 12), reused 8 (delta 0), pack-reused 0
Receiving objects: 100% (59/59), 7.89 KiB | 336.00 KiB/s, done.
Resolving deltas: 100% (12/12), done.
Error: Invalid formula: /usr/local/Homebrew/Library/Taps/hidetatz/homebrew-tap/Formula/kubecolor.rb
kubecolor: wrong number of arguments (given 1, expected 0)
Error: Cannot tap hidetatz/tap: invalid syntax in tap!
Get this error after I started using kubecolor
. My editor is emacs running as daemon.
$ k edit deployments.apps unleash
emacsclient: could not get terminal name
emacsclient: error executing alternate editor ""
error: there was a problem with the editor "emacsclient -t"
When running the install command specified in the readme, we get an error:
$ go install github.com/hidetatz/kubecolor/cmd/kubecolor@latest
go: github.com/hidetatz/kubecolor/cmd/kubecolor@latest: github.com/hidetatz/[email protected]: parsing go.mod:
module declares its path as: github.com/dty1er/kubecolor
but was required as: github.com/hidetatz/kubecolor
$ brew info kubecolor
Warning: Calling bottle :unneeded is deprecated! There is no replacement.
Please report this issue to the dty1er/tap tap (not Homebrew/brew or Homebrew/core):
/usr/local/Homebrew/Library/Taps/dty1er/homebrew-tap/Formula/kubecolor.rb:9
dty1er/tap/kubecolor: stable 0.0.20
As of now, restarted pods doesn't stand out by different colors, so, It would be grate to have it differentiated.
That would make it much easier to see what's going on
Is it possible to use colors for logs in the same way as lnav do it?
when i try to use the version command of a kubectl plugin it failed
ex with cert-manager
Screenshot of "kubectl" output
kubectl cert-manager version
util.Version{GitVersion:"v1.0.1", GitCommit:"c06d7a55dafb1a812321bf3c2ab982daa7b3e699", GitTreeState:"clean", GoVersion:"go1.15", Compiler:"gc", Platform:"darwin/amd64"}
Screenshot of "kubecolor" output
kubecolor cert-manager version
panic: runtime error: index out of range [1] with length 1
goroutine 18 [running]:
github.com/dty1er/kubecolor/printer.(*VersionPrinter).Print(0xc00008c008, 0x11383f8, 0xc00010e028, 0x1138418, 0xc00010e008)
/home/runner/work/kubecolor/kubecolor/printer/kubectl_version.go:41 +0xcf6
github.com/dty1er/kubecolor/printer.(*KubectlOutputColoredPrinter).Print(0xc0001161d0, 0x11383f8, 0xc00010e028, 0x1138418, 0xc00010e008)
/home/runner/work/kubecolor/kubecolor/printer/kubectl_output_colored_printer.go:110 +0x16e
github.com/dty1er/kubecolor/command.Run.func1(0xc00013c060, 0x1138868, 0xc00010e028, 0xc00010c040)
/home/runner/work/kubecolor/kubecolor/command/runner.go:95 +0x9b
created by github.com/dty1er/kubecolor/command.Run
/home/runner/work/kubecolor/kubecolor/command/runner.go:94 +0x45f
i expect to ahve the version as kubectl return
I am on Mac OSX v. 10.15.7 (Catalina) and Kubecolor 0.0.7 installed from brew, and I'm using zsh in iTerm2. I get the following errors when trying to describe namespace resources in K8s:
Resource Quotas
Name:panic: runtime error: index out of range [0] with length 0
goroutine 18 [running]:
github.com/dty1er/kubecolor/printer.(*DescribePrinter).Print(0xc00005e010, 0x113d2e0, 0xc0000a2028, 0x113d300, 0xc0000a2008)
/home/runner/work/kubecolor/kubecolor/printer/kubectl_describe.go:85 +0xe75
github.com/dty1er/kubecolor/printer.(*KubectlOutputColoredPrinter).Print(0xc000082340, 0x113d2e0, 0xc0000a2028, 0x113d300, 0xc0000a2008)
/home/runner/work/kubecolor/kubecolor/printer/kubectl_output_colored_printer.go:101 +0x15e
github.com/dty1er/kubecolor/command.Run.func1(0xc00009a0a0, 0x113d820, 0xc0000a2028, 0xc0000a8040)
/home/runner/work/kubecolor/kubecolor/command/runner.go:85 +0x9b
created by github.com/dty1er/kubecolor/command.Run
/home/runner/work/kubecolor/kubecolor/command/runner.go:84 +0x34c
I have an alias kubectl=kubecolor
and when executed kubectl edit secret THE_SECRET
and got the following error:
Vim: Warning: Output is not to a terminal
and my terminal just frozen.
I had to Ctrl+C
and then exit the terminal in order to get my cursor in my terminal.
After update to Monterey, I have this issue:
% brew upgrade kubecolor
Warning: Calling bottle :unneeded is deprecated! There is no replacement.
Please report this issue to the dty1er/tap tap (not Homebrew/brew or Homebrew/core):
/usr/local/Homebrew/Library/Taps/dty1er/homebrew-tap/Formula/kubecolor.rb:9
Hello,
First of all - love the tool, discovered it recently and really happy with the functionality.
Second of all, I need suggestions for my setup.
So I'm using the latest iTerm2 (v3.5) that supports switching color preset (including background) based on the system automatically enabled/disabled dark mode, e.g., if the system is set to light mode during the day, I have the light solarized background, if it's dark mode - I have dark solarized.
As per this suggestion, I'm using scripts and aliases to switch manually between kubecolor
and kubecolor --light-background
, but wonder if there is more automatic way to switch?
this could very well have to do with my setup, but I'm getting something weird from the first word of autocomplete.
if i tab from kubecolor
, i get kubecolor $'\033'\[33m
kubecolor de
doesn't complete
but kubecolor get
, does work and gives me all the right options
Hi there. Thanks for this great project! As a Linux user it's incredibly inconvenient to go grab a new static binary. A lot of k8s centric go apps I wire into shell functions with podman/docker containers. Would it be possible if we can get releases wired up to a image?
kubecolor ignores the exit status of the kubectl
process:
$ /usr/bin/kubectl get pod foo; echo $?
Error from server (NotFound): pods "foo" not found
1
$ kubecolor get pod foo; echo $?
Error from server (NotFound): pods "foo" not found
0
(use-case: in a script (so the exit status is necessary), where a human still sees the outputs (so the color is much useful).)
kubecolor
has been packaged in the AUR for some time, but was recently abandoned by the previous maintainer. A new maintainer is welcome to adopt the package. You should have knowledge of AUR conventions, PKGBUILD, and makepkg
.
Good luck :)
Create a pod with "-" prefixed args
kubectl apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
name: test-pod
spec:
containers:
- name: main
image: remrain/tiny-hello
args:
- -test
EOF
"-" is missing in yaml output
kubecolor get pod test-pod -o yaml
...
spec:
containers:
- args:
- test <---------- HERE
kubectl get pod test-pod -o yaml
...
spec:
containers:
- args:
- -test
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.