/k-nives

⚙️ 🇰-nives 🔪 kubectl swiss army knife

GNU General Public License v3.0GPL-3.0

⚙️ 🇰-nives 🔪 kubectl swiss army knife

License Issues Last commit Bash Version

About

🇰-nives are Bash functions to increase your productivity with kubernetes kubectl:

✔️ k-nives List 🇰-nives tools
✔️ kn Shows avaiable or set cluster namespace - A default '--namespace NAMESPACE' for kubectl (context)
✔️ kp List cluster pods
✔️ kl Shows pod containers log
FIRST LAUNCH: 2021-04-02
LAST REVISION: 2021-04-02
VERSION: 1.0

This project is maintained by Sthenley Macedo under GNU GPL v3 license.

Features:

Some are native kubectl features - But in a quick/easy mode 😉

  • Color output (ccze and kubecolor must be installed)
  • You can still use all kubectl flags
  • Always shows the final command - You don't need to 'unlearn' nothing
  • Shows kubectl flags hints
  • Set current cluster namespace (allways shows current namespace@context)
  • 🇰-nives kn can use namespaces aliases
  • 🇰-nives kp can use pod name filtering - All ocurrences of a string
  • 🇰-nives kl can use pod name filtering - First ocurrence of a string
  • 🇰-nives kl 't' flag shows only 'n' last lines of log
  • 🇰-nives kl allways show output timestamps
  • 🇰-nives kl can allways show all containers logs
  • Return error code for 'pod not found' - kubectl don't have it
  • Less typing, more productivity

Installation

Requisites:

  1. kubectl - Required
  2. awk) - Required - Also for your CLI life
  3. kubecolor - Recommended, for color output
  4. CCZE colorizer - Recommended, for color output
  5. curl - Recommended - Also for your CLI life

HINT! InstALL them!

Quickly (but prefer to refer to the original documentation for each tool):

sudo apt-get -y install curl ccze golang $(command -v awk &> /dev/null || echo awk)    
sudo apt-get -y install kubecolor || go install github.com/dty1er/kubecolor/cmd/kubecolor@latest    

Linux CLI install or update

curl -sLJ https://raw.githubusercontent.com/sthenley/k-nives/main/.bash_k-nives -o ~/.bash_k-nives
grep -q '. ~/.bash_k-nives' ~/.bashrc || echo -e '\nif [ -f ~/.bash_k-nives ]; then\n    . ~/.bash_k-nives\nfi' >> ~/.bashrc && . ~/.bash_k-nives

Usage

Try --help or -h flags to instructions at command line
🇰-nives was made for UTF-8 environments. You`ll need to change some characters at functions source, if you are getting some “strange characters”

Setup

You can edit kn function to reflect your own namespace aliases
If you need, edit this variables at top of .bash_k-nives:

Variable Description
K_NIVES_LIGHT=false Change it to true if you have a “light backgrounded” environment. Works only if you have kubecolor
K_NIVES_DEPLOYMENT=true Enable/Disable app deployment name at 🇰-nives kp output
K_NIVES_TAIL=10 Number of lines for 🇰-nives kl 't' flag
K_NIVES_ALL_CONTAINERS=true kl with a '--all-containers=true' flag
K_NIVES_NAMESPACE1_ALIASES Optional - Populate it with a list of aliases for a namespace. Default: `c
K_NIVES_NAMESPACE2_ALIASES Optional - Populate it with a list of aliases for a namespace. Default: `m

Exit codes

0 Ok (or help flag)
1 Invalid argument (help ouput)
2 kubectl not installed
3 Pod not found

Share 🇰-nives

To do

  • Dinamic aliases and any number of namespaces

Contributions

Always welcome. Just open an issue

References