DEV Community

Narongrit Kanhanoi
Narongrit Kanhanoi

Posted on

kk — A tiny CLI that makes kubectl faster and less painful

kk — A tiny CLI that makes kubectl faster and less painful

Working with Kubernetes daily often means typing long kubectl commands repeatedly:

  • kubectl logs ...
  • kubectl exec ...
  • kubectl get pods | grep ...
  • switching namespaces
  • tailing logs from multiple replicas
  • restarting deployments and checking images

I wanted something tiny, predictable, and easy to drop into any environment.

So I built kk — a minimal Bash wrapper around kubectl that focuses on speed, simplicity, and muscle‑memory friendly commands.

Repo:

👉 https://github.com/heart/kk-Kubernetes-Power-Helper-CLI


🚀 Why I built this

I didn’t want another heavy binary or plugin framework.

I wanted:

  • shorter commands
  • automatic namespace handling
  • smart pod and deployment selection (fzf optional)
  • multi-pod log streaming
  • “day‑2” helpers like restart, port‑forward, events, top
  • zero dependencies beyond bash + kubectl (+ jq optionally)

kk is a single script you can drop into ~/bin/kk.


⚡ What kk can do

✅ Namespace helper

kk ns show
kk ns set staging
Enter fullscreen mode Exit fullscreen mode

Keeps a simple namespace config in ~/.kk so you don’t have to type -n all day.


✅ Pods, shell, logs, images

# List pods (with optional name substring / regex)
kk pods
kk pods api

# Exec into a pod (auto-select; uses fzf if installed)
kk sh api
kk sh api -- bash

# Multi-pod logs with optional container, grep, follow
kk logs api -f
kk logs api -f -g "ERROR"
kk logs api -c main --since=10m

# See which images are actually running
kk images api
Enter fullscreen mode Exit fullscreen mode

Pod selection uses a pattern against pod names. If multiple pods match, kk will prompt you (or use fzf when available).


✅ Deployment helpers

# Rollout restart a deployment (with pattern and selection)
kk restart api

# Summarize deployments in the current namespace
kk deploys
Enter fullscreen mode Exit fullscreen mode

kk deploys uses jq (if available) to show something like:

NAME                           READY      IMAGE
api                            3/3  image: yourorg/api:1.8.12
web                            2/2  image: yourorg/web:3.9.0
Enter fullscreen mode Exit fullscreen mode

✅ Port‑forward with pod selection

kk pf api 8080:80
Enter fullscreen mode Exit fullscreen mode

This resolves the pod by pattern first (again, with fzf if there are multiple matches) and then runs kubectl port-forward for you.


✅ Quick describe & resource usage

# Describe matching pod
kk desc api

# Top pods (optionally filtered)
kk top
kk top api
Enter fullscreen mode Exit fullscreen mode

kk top is just a friendly wrapper around kubectl top pod -n <ns> with optional filtering while keeping the header row.


✅ Events & contexts

# Recent events in the current namespace
kk events

# Show or switch kubectl contexts
kk ctx
kk ctx my-cluster
Enter fullscreen mode Exit fullscreen mode

🛠 Installation

curl -o ~/bin/kk https://raw.githubusercontent.com/heart/kk-Kubernetes-Power-Helper-CLI/main/kk
chmod +x ~/bin/kk
Enter fullscreen mode Exit fullscreen mode

Make sure ~/bin is in your $PATH:

echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc   # or ~/.zshrc
source ~/.bashrc                                   # or ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

❤️ If you find kk useful

Stars, issues, and suggestions are welcome.

Repo link again:

👉 https://github.com/heart/kk-Kubernetes-Power-Helper-CLI


kk isn’t meant to replace kubectl.

It just removes boilerplate and gives you a smoother Kubernetes workflow.

Top comments (0)