惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Exploit Database - CXSecurity.com
N
News and Events Feed by Topic
Latest news
Latest news
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
CXSECURITY Database RSS Feed - CXSecurity.com
IT之家
IT之家
V
V2EX
WordPress大学
WordPress大学
Apple Machine Learning Research
Apple Machine Learning Research
Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
小众软件
小众软件
A
Arctic Wolf
酷 壳 – CoolShell
酷 壳 – CoolShell
腾讯CDC
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
G
GRAHAM CLULEY
罗磊的独立博客
T
Tor Project blog
C
Cisco Blogs
美团技术团队
博客园 - Franky
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
Cyberwarzone
Cyberwarzone
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
有赞技术团队
有赞技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Security Latest
Security Latest
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
Spread Privacy
Spread Privacy
J
Java Code Geeks
C
CERT Recently Published Vulnerability Notes
大猫的无限游戏
大猫的无限游戏
S
Securelist
The Cloudflare Blog
博客园 - 叶小钗
D
Darknet – Hacking Tools, Hacker News & Cyber Security
阮一峰的网络日志
阮一峰的网络日志
雷峰网
雷峰网
Project Zero
Project Zero

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
kubectl Hacks That Changed How I Work With Kubernetes
Selma Guedid · 2026-04-30 · via DEV Community

Beyond the basics: patching, waiting, explaining, and squeezing the most out of the one tool that never leaves your terminal.

Most kubectl guides stop at get pods and apply -f. That's fine for getting started, but after years of running Kubernetes in production, the commands that make the real difference are the ones nobody writes about. The obscure flags. The output tricks. The commands that turn a 20-minute debugging slog into a 90-second fix.

This article is about the depth of kubectl: commands I reach for when things get weird, scripting patterns that made our CI pipelines solid, and the shorthand vocabulary that turns the tool from a keyboard workout into something that actually feels fast. No fluff, no padding. Just the stuff worth knowing.


01 — The Complete Shorthand Vocabulary

Before anything else: the complete list of resource type abbreviations. These are baked into the Kubernetes API itself, so they work universally across get, describe, delete, patch, edit, and every other verb. Memorise the ones you use daily and your hands will thank you.

Short Full Resource Name API Group
po pods core
svc services core
deploy deployments apps
ds daemonsets apps
rs replicasets apps
sts statefulsets apps
ns namespaces core
cm configmaps core
ing ingresses networking.k8s.io
pv persistentvolumes core
pvc persistentvolumeclaims core
sa serviceaccounts core
ep endpoints core
no nodes core
ev events core
hpa horizontalpodautoscalers autoscaling
pdb poddisruptionbudgets policy
crd customresourcedefinitions apiextensions.k8s.io
crb clusterrolebindings rbac.authorization.k8s.io
rb rolebindings rbac.authorization.k8s.io
netpol networkpolicies networking.k8s.io
sc storageclasses storage.k8s.io
job jobs batch
cj cronjobs batch
quota resourcequotas core
sec secrets core

💡 Pro tip: Run kubectl api-resources in your cluster to see every available shorthand, including those from installed CRDs. It shows the short name, API group, whether the resource is namespaced, and the kind.


02 — kubectl patch: The Surgeon's Tool

kubectl apply is great when you own the full manifest. But what about changing a single field on a resource managed by a Helm chart, an operator, or another team? You don't want to touch the whole file. You want a scalpel. That's kubectl patch.

There are three patch types, and picking the wrong one will lose you data or produce confusing merges.

Type Behaviour When to use
strategic-merge Kubernetes-aware merge. Containers are merged by name, not replaced. Default. Use most of the time.
merge RFC 7396 JSON Merge. Arrays are replaced entirely, not merged. CRDs and non-core resources.
json RFC 6902. Precise add / remove / replace / move operations. When you need surgical precision.
# Add an annotation without touching the rest of the manifest
kubectl patch deploy api-gateway -p '{"metadata":{"annotations":{"deploy-time":"2026-04-27"}}}' -n production

# Change replica count on the fly (useful in incidents)
kubectl patch deploy api-gateway -p '{"spec":{"replicas":6}}' -n production

# Remove a field entirely with JSON patch
kubectl patch deploy api-gateway --type=json \
  -p='[{"op":"remove","path":"/spec/template/spec/containers/0/resources/limits/cpu"}]' -n production

# Replace a specific env var value by index
kubectl patch deploy api-gateway --type=json \
  -p='[{"op":"replace","path":"/spec/template/spec/containers/0/env/0/value","value":"https://new-db-host"}]'

# Cordon a node : what kubectl cordon does under the hood
kubectl patch node ip-10-0-1-47 -p '{"spec":{"unschedulable":true}}'

# Add a label to a node using json patch
kubectl patch node ip-10-0-1-47 --type=json \
  -p='[{"op":"add","path":"/metadata/labels/topology.kubernetes.io~1zone","value":"us-east-1a"}]'

Enter fullscreen mode Exit fullscreen mode

⚠️ Watch out: The / character in JSON Patch paths refers to object keys. If your key contains a forward slash (like kubernetes.io/role), escape it as ~1. The tilde ~ itself escapes as ~0. Easy to forget, expensive when wrong.


03 — kubectl wait: The CI/CD Game Changer

If you write shell scripts or CI pipelines that deploy to Kubernetes, you've probably written something like: deploy → sleep 30 → check status → sleep more → give up. It's flaky and slow. kubectl wait replaces all of that with a proper event-driven block.

# Block until a deployment finishes rolling out (timeout after 3 minutes)
kubectl wait deploy/api-gateway --for=condition=Available --timeout=3m -n production

# Wait for all pods with a label to be Ready
kubectl wait pods -l app=api-gateway --for=condition=Ready --timeout=2m -n production

# Wait for a Job to complete
kubectl wait job/db-migration --for=condition=Complete --timeout=10m -n production

# Wait for a Job to fail (useful for catching broken migrations early)
kubectl wait job/db-migration --for=condition=Failed --timeout=10m -n production

# Wait for a node to be Ready after a restart
kubectl wait node/ip-10-0-1-47 --for=condition=Ready --timeout=5m

# Wait for a CRD to be established (important in Helm chart init containers)
kubectl wait crd/certificates.cert-manager.io --for=condition=Established --timeout=60s

# Wait for a pod to be deleted
kubectl wait pod/old-pod-abc123 --for=delete --timeout=60s -n production

Enter fullscreen mode Exit fullscreen mode

The --for=delete form is especially valuable. Whenever you need to drain a node or delete a pod and then take some action only after it's truly gone, this is your signal. No polling loops, no racy sleep calls.

💡 CI pattern: Chain kubectl apply and kubectl wait in your pipeline. If the wait times out, the pipeline fails with a non-zero exit code, no extra health-check scripts needed. You get free deploy verification.


04 — kubectl explain: The Docs Are Already in Your Terminal

Every time I see someone switching to a browser to look up what a field does in a Kubernetes spec, I cringe. The full API reference is built right into kubectl explain. It supports dot-notation for nested fields and --recursive to print the entire schema tree.

# What is a PodSpec?
kubectl explain pod.spec

# What fields does a container accept?
kubectl explain pod.spec.containers

# Go deep on a specific field
kubectl explain pod.spec.containers.resources.requests

# Print the entire schema tree for a resource
kubectl explain deployment --recursive

# Works on CRDs too
kubectl explain certificate.spec.renewBefore

# Check what API version a resource uses
kubectl explain horizontalpodautoscaler --api-version=autoscaling/v2

Enter fullscreen mode Exit fullscreen mode

The --recursive output looks dense at first but becomes invaluable when you're unfamiliar with a CRD's schema. Pipe it through grep to find the field you care about rather than reading a thousand-line GitHub README.


05 — kubectl cp: Moving Files In and Out of Containers

This one saves you in two specific scenarios: extracting a generated file from a container (a rendered config, a certificate, a data dump), and pushing a temporary script into a running pod when you can't rebuild the image. It behaves like scp with a slightly different path syntax.

# Copy a file OUT of a container
kubectl cp production/api-pod-7d4f8b:/app/logs/error.log ./error.log

# Copy a file INTO a container
kubectl cp ./debug-script.sh production/api-pod-7d4f8b:/tmp/debug-script.sh

# Copy a whole directory out
kubectl cp production/api-pod-7d4f8b:/app/data ./data-backup

# Specify a container in a multi-container pod
kubectl cp production/api-pod-7d4f8b:/var/log/app.log ./app.log -c sidecar-logger

# Format: [namespace/]pod-name:path

Enter fullscreen mode Exit fullscreen mode

⚠️ Heads up: kubectl cp requires tar to be present inside the container. Distroless images don't have it. If you hit that wall, use kubectl debug to attach a debug sidecar first, then copy from there.


06 — Generating YAML Without Writing YAML

The --dry-run=client -o yaml pattern lets kubectl write your manifests for you. Here's a full set of imperative-to-declarative shortcuts that produce valid, committable YAML.

# Deployment manifest
kubectl create deploy api-gateway --image=ghcr.io/myorg/api:v2.3 --replicas=3 \
  --dry-run=client -o yaml > deployment.yaml

# Service (ClusterIP)
kubectl create svc clusterip api-gateway --tcp=80:8080 --dry-run=client -o yaml

# Service (LoadBalancer)
kubectl create svc loadbalancer api-lb --tcp=443:8443 --dry-run=client -o yaml

# ConfigMap from file and literals
kubectl create cm app-config \
  --from-file=config.yaml \
  --from-literal=LOG_LEVEL=info \
  --from-literal=REGION=eu-west-1 \
  --dry-run=client -o yaml

# Secret (generic)
kubectl create secret generic db-creds \
  --from-literal=username=admin \
  --from-literal=password=hunter2 \
  --dry-run=client -o yaml

# Secret (TLS)
kubectl create secret tls api-tls --cert=tls.crt --key=tls.key --dry-run=client -o yaml

# Job
kubectl create job db-migration --image=ghcr.io/myorg/migrator:v1 --dry-run=client -o yaml

# CronJob
kubectl create cronjob nightly-report --image=ghcr.io/myorg/reporter:v1 \
  --schedule="0 2 * * *" --dry-run=client -o yaml

# ServiceAccount
kubectl create sa api-worker --dry-run=client -o yaml

# Role
kubectl create role pod-reader --verb=get,list,watch --resource=pods --dry-run=client -o yaml

# RoleBinding
kubectl create rolebinding api-pod-reader \
  --role=pod-reader --serviceaccount=production:api-worker \
  --dry-run=client -o yaml

Enter fullscreen mode Exit fullscreen mode


07 — kubectl set: In-Place Updates Without Editing YAML

When you need to change a single well-defined property on a running resource, kubectl set is cleaner than patching raw JSON.

# Update the image of a single container
kubectl set image deploy/api-gateway api=ghcr.io/myorg/api:v2.4 -n production

# Update multiple containers at once
kubectl set image deploy/api-gateway api=ghcr.io/myorg/api:v2.4 sidecar=ghcr.io/myorg/proxy:v1.1

# Set resource requests and limits
kubectl set resources deploy/api-gateway \
  -c api \
  --requests=cpu=250m,memory=512Mi \
  --limits=cpu=1000m,memory=1Gi -n production

# Assign a service account
kubectl set serviceaccount deploy/api-gateway api-worker -n production

# Add or update an environment variable
kubectl set env deploy/api-gateway LOG_LEVEL=debug -n production

# Set env from a ConfigMap
kubectl set env deploy/api-gateway --from=configmap/app-config -n production

# Set env from a Secret
kubectl set env deploy/api-gateway --from=secret/db-creds -n production

# Remove an env var (suffix with a minus)
kubectl set env deploy/api-gateway LOG_LEVEL- -n production

Enter fullscreen mode Exit fullscreen mode

ℹ️ Note: kubectl set image records the change in the deployment's rollout history, which means you can kubectl rollout undo it just like a kubectl apply. It's not a dirty in-place hack, it's a first-class operation.


08 — Labels, Annotations, and Taints: The Metadata Commands

Labels and annotations are the connective tissue of Kubernetes. Services find their pods through labels. Operators read annotations for config. Knowing how to manipulate this metadata live, without opening a YAML file, is surprisingly powerful.

# Add a label to a pod
kubectl label pod api-pod-7d4f8b version=v2.4 -n production

# Overwrite an existing label
kubectl label pod api-pod-7d4f8b version=v2.5 -n production --overwrite

# Remove a label (suffix with a minus)
kubectl label pod api-pod-7d4f8b version- -n production

# Label all pods matching a selector
kubectl label pods -l app=api-gateway canary=true -n production

# Label a node for topology-aware scheduling
kubectl label node ip-10-0-1-47 disk=ssd zone=us-east-1a

# Add an annotation
kubectl annotate deploy/api-gateway \
  deployment.kubernetes.io/revision-message="hotfix: null pointer on /checkout" -n production

# Taint a node so only tolerating pods schedule on it
kubectl taint node ip-10-0-1-47 dedicated=gpu-workloads:NoSchedule

# Remove a taint (suffix the effect with a minus)
kubectl taint node ip-10-0-1-47 dedicated:NoSchedule-

# Cordon and drain before maintenance
kubectl cordon ip-10-0-1-47
kubectl drain ip-10-0-1-47 --ignore-daemonsets --delete-emptydir-data --force
kubectl uncordon ip-10-0-1-47  # after maintenance

Enter fullscreen mode Exit fullscreen mode


09 — Output Tricks: Beyond the Default Table

The default tabular output is readable, but when you're scripting or building dashboards, you need exact fields. Here are the output modes worth knowing:

Flag What it does
-o yaml Full resource as YAML. Great for inspection and editing.
-o json Full resource as JSON. Pipe to jq for advanced queries.
-o name resource/name format. Ideal for piping into delete or apply.
-o jsonpath Extract specific fields. Best for scripts and alerts.
-o wide Extra columns: node, IP, nominated node, readiness gates.
-o custom-columns Define your own table headers and field paths.
# Pull a single field cleanly for scripting
kubectl get deploy api-gateway -o jsonpath='{.spec.replicas}' -n production

# Get all image names running across a namespace
kubectl get pods -n production \
  -o jsonpath='{range .items[*]}{.metadata.name}{"  "}{range .spec.containers[*]}{.image}{"\n"}{end}{end}'

# Get the cluster API server URL
kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}'

# Custom table: pod name, QoS class, and CPU limit
kubectl get pods -n production -o custom-columns=\
'NAME:.metadata.name,QOS:.status.qosClass,CPU-LIMIT:.spec.containers[0].resources.limits.cpu'

# Pipe to jq for complex queries
kubectl get pods -n production -o json | \
  jq '.items[] | select(.status.phase=="Running") | .metadata.name'

# Find all images across all namespaces (deduplicated)
kubectl get pods -A -o jsonpath='{range .items[*]}{.spec.containers[*].image}{"\n"}{end}' | \
  tr ' ' '\n' | sort -u

# Use -o name to feed into another command
kubectl get pods -l app=api-gateway -n production -o name | \
  xargs -I{} kubectl annotate {} debug-session=2026-04-27 -n production

Enter fullscreen mode Exit fullscreen mode


10 — kubectl proxy: Accessing the API Directly

kubectl proxy starts a local HTTP server that proxies authenticated requests to the Kubernetes API server. It's different from port-forward: proxy gives you access to the Kubernetes REST API itself, not to a specific service inside the cluster.

# Start a proxy on localhost:8001 (default)
kubectl proxy

# Now you can curl the API without any auth headers
curl http://localhost:8001/api/v1/namespaces/production/pods

# Access cluster metrics via the metrics API
curl http://localhost:8001/apis/metrics.k8s.io/v1beta1/nodes

# Access a service through the API proxy
# Format: /api/v1/namespaces/{ns}/services/{scheme:name:port}/proxy/
curl http://localhost:8001/api/v1/namespaces/monitoring/services/http:grafana:3000/proxy/

# Proxy on a specific port
kubectl proxy --port=9090

# Accept connections from all interfaces (remote dev environments)
kubectl proxy --address=0.0.0.0 --accept-hosts='.*'

Enter fullscreen mode Exit fullscreen mode

The service proxy URL pattern is especially useful for accessing cluster-internal dashboards (Grafana, Prometheus, Argo CD) without setting up ingress or port-forward sessions. Keep the proxy running in a background terminal and bookmark the URLs.


11 — The Plugin Ecosystem: What krew Unlocks

kubectl's plugin system lets you drop any executable named kubectl-something onto your PATH and run it as kubectl something. krew is the community package manager for these plugins. Here are the ones that actually earn their place:

Debugging

  • kubectl neat — Strip managed fields from get -o yaml output so it's actually readable
  • kubectl images — List container images in a tree view
  • kubectl resource-capacity — Node capacity vs requests vs limits at a glance

Networking

  • kubectl ns — Switch namespace quickly (kubens alternative)
  • kubectl sniff — Capture pod traffic with tcpdump/Wireshark
  • kubectl mtail — Multi-pod log tail with regex

Security

  • kubectl who-can — Who has permission to do X?
  • kubectl access-matrix — Full RBAC matrix for a namespace
  • kubectl popeye — Cluster configuration linter

Productivity

  • kubectl ctx — Switch cluster context (kubectx alternative)
  • kubectl tree — Show owner references as a tree
  • kubectl view-secret — Decode secrets without base64 manually
# Install krew (macOS/Linux)
(
  set -x; cd "$(mktemp -d)" &&
  OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
  ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
  KREW="krew-${OS}_${ARCH}" &&
  curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
  tar zxvf "${KREW}.tar.gz" &&
  ./"${KREW}" install krew
)

# Install the ones worth having
kubectl krew install neat who-can access-matrix resource-capacity view-secret tree images popeye sniff

# neat: removes clutter from -o yaml output (managedFields, creationTimestamp, etc.)
kubectl get deploy api-gateway -o yaml | kubectl neat

# who-can: find out which subjects can perform an action
kubectl who-can delete pods -n production

# view-secret: decode and display a secret's values
kubectl view-secret db-creds -n production

# tree: visualise the ownership hierarchy
kubectl tree deploy api-gateway -n production

# resource-capacity: see requests/limits vs actual usage per node
kubectl resource-capacity --sort cpu.limit --pods

Enter fullscreen mode Exit fullscreen mode


12 — Watching Resources: Smarter Than You Think

The -w flag on kubectl get opens a watch stream against the API server. Most people use it for pods, but it works on any resource. Combined with field selectors and output formatting, it becomes a real-time monitoring tool without needing a dashboard.

# Watch pods but only show ones that are NOT Running
kubectl get pods -w -n production | grep -v Running

# Watch events filtered to a specific pod
kubectl get events -w --field-selector involvedObject.name=api-pod-7d4f8b -n production

# Watch a HPA during a load test
kubectl get hpa api-gateway -w -n production

# Watch all deployments for rollout changes
kubectl get deployments -w -n production

# Watch nodes during a cluster upgrade
kubectl get nodes -w

# Watch with a custom column showing only name and ready status
kubectl get pods -w -n production \
  -o custom-columns='NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status'

# Watch PVCs for bound state during StatefulSet provisioning
kubectl get pvc -w -n production

Enter fullscreen mode Exit fullscreen mode


Conclusion

kubectl is one of those tools where the ceiling keeps rising the longer you use it. The gap between someone who knows get and apply and someone who reaches for kubectl wait in a CI script, or kubectl patch --type=json when they need precision surgery on a live resource, is real and measurable in minutes saved per incident.

The pattern worth internalising: kubectl is just an HTTP client with great defaults and a thoughtful DSL. Once that clicks, every command stops being a magic incantation and starts being a readable REST call. You start predicting flags you've never tried before. You stop reaching for the browser. And when something breaks at 2am, you move faster.

Start with the shorthands. Add kubectl explain to your muscle memory. Reach for kubectl wait the next time you write a deploy script. The rest will follow naturally.


References