Hi folks,
just wanted to say this is a great tool and saves me tonnes of time!
I was wondering if it's possible/what the syntax is for a custom plugin with pipes? E.g. my pods log in json so I would like to pipe the output through JQ, I tried:
plugin:
jlogs:
shortCut: Ctrl-J
description: "Json Pod logs"
scopes:
- po
command: /bin/sh
background: false
args:
- -c
- "kubectl logs -f $NAME -n $NAMESPACE --context $CONTEXT | jq -r '.message'"
But no joy. Has anyone done something similar?
@rahilb Sorry it's taking me a while to get back to you on this ;(
Please let me know if this works for you! Tx!!
I think you should be able to leverage kubectl plugins for that and get this working with K9s as a plugin as follows:
# Add kubectl-jq somewhere in your path and change to your shell of choice!
#!/bin/bash
/usr/local/bin/kubectl logs -f $1 -n $2 --context $3 | jq -r '.message'
Add the plugin as follows:
# $HOME/.k9s/plugin.yml
plugin:
jlogs:
shortCut: Ctrl-J
description: "Json Pod logs"
scopes:
- po
command: kubectl
background: false
args:
- jq
- $NAME
- $NAMESPACE
- $CONTEXT
Thanks @derailed it worked perfectly, there was a couple of typos in the code you pasted, here's the working solution:
/usr/local/bin/kubectl-jq
#!/bin/bash
/usr/local/bin/kubectl logs -f $1 -n $2 --context $3 | jq -r '.message'
$HOME/.k9s/plugin.yml
plugin:
jlogs:
shortCut: Ctrl-J
description: "Json Pod logs"
scopes:
- po
command: kubectl-jq
background: false
args:
- $NAME
- $NAMESPACE
- $CONTEXT
Thanks again for making such a great tool!
@rahilb Cool!! Thank you for reporting back! Not a typo in the example I am leveraging kubectl plugins.
Most helpful comment
@rahilb Sorry it's taking me a while to get back to you on this ;(
Please let me know if this works for you! Tx!!
I think you should be able to leverage kubectl plugins for that and get this working with K9s as a plugin as follows:
Add the plugin as follows: