kubectl
$ kubectl Foundation High Riskkubectl controls Kubernetes clusters with exemplary agent ergonomics: -o json output, -o jsonpath=... and -o custom-columns=... projection, client/server --dry-run=server, live kubectl diff, and RBAC pre-checks via kubectl auth can-i.
brew install kubectl kubectl has -o json, -o jsonpath, --dry-run=server, and kubectl diff baked in; LLMs know its exact grammar natively.
Agent-Readiness Checklist
Local Probe EvidenceCaptured --help excerpt
kubectl controls the Kubernetes cluster manager. Find more information at: https://kubernetes.io/docs/reference/kubectl/ Basic Commands (Beginner): create Create a resource from a file or from stdin expose Take a replication controller, service, deployment or pod and expose it as a new Kubernetes service run Run a particular image on the cluster set Set specific features on objects Basic Commands (Intermediate): explain Get documentation for a resource get Display one or many resources edit Edit a resource on the server delete Delete resources by file names, stdin, resources and names, or by resources and label selector Deploy Commands: rollout Manage the rollout of a resource scale Set a new size for a deployment, replica set, or replication controller autoscale Auto-scale a deployment, replica set, stateful set, or replication controller Cluster Management Commands: certificate Modify certificate resources cluster-info Display cluster information top Display resource (CPU/memory) usage cordon Mark node as unschedulable uncordon Mark node as schedulable drain Drain node in preparation for maintenance taint Update the taints on one or more nodes Troubleshooting and Debugging Commands: describe Show details of a specific resource or group of resources logs Print the logs for a container in a pod attach Attach to a running container exec Execute a command in a container port-forward Forward one or more local ports to a pod proxy Run a proxy to the Kubernetes API server cp Copy files and directories to and from containers auth Inspect authorization debug Create debugging sessions for troubleshooting workloads and nodes events List events Advanced Commands: diff Diff the live version against a would-be applied version apply Apply a configuration to a resource by file name or stdin patch Update fields of a resource replace Replace a resource by file name or stdin wait Wait for a specific condition on one or many resources kustomize Build a kustomization target from a directory or URL Settings Commands: label Update the labels on a resource annotate Update the
FCRS-1.0 6-Dimension Breakdown
Universal -o json, -o jsonpath=..., --field-selector, --dry-run=client|server, and kubectl explain introspection.
- Supports
-o json,-o jsonpath,--dry-run=server, andkubectl explain
kubectl diff, --dry-run=server, and kubectl auth can-i provide best-in-class mutation previews, though multi-cluster kubeconfig mistakes carry high impact.
- Server-side
--dry-run=server,kubectl diff, and RBACauth can-i
Single static Go binary available via Homebrew, OS packages, and official binaries across macOS, Linux, and Windows.
- Static Go binary on all major platforms
Server-side selectors and -o jsonpath keep cluster queries lean even on huge clusters.
- Server-side
--field-selectorand-llabel filtering
CNCF graduated flagship (kubernetes/kubectl) maintained alongside every Kubernetes release.
- Official CNCF
kubernetes/kubectlunder Apache-2.0
Complete online reference plus offline kubectl explain <resource> CRD/schema introspection.
- Offline
kubectl explainAPI schema docs
Security, Auth & Guardrails
Reads cluster contexts, client certificates, and exec auth plugins from ~/.kube/config or KUBECONFIG.
CLI is free (Apache-2.0); scaling workloads affects underlying cloud cluster costs.
# kubectl Agent Rules - ALWAYS check `kubectl config current-context` and pass `--context` + `-n <namespace>` explicitly. - Run `kubectl diff -f` and `kubectl apply --dry-run=server` before mutating cluster resources. - Never run `kubectl delete` or `kubectl drain` on production contexts without explicit user approval.
Agent-Ready Command Recipes
Safe Read-Only Queries
kubectl config current-context && kubectl auth can-i --list -n default
Confirms target cluster context and effective RBAC permissions before acting.
-o json and --field-selector kubectl get pods -n default --field-selector=status.phase!=Running -o json
Finds non-running pods in structured JSON with server-side field filtering.
Controlled Writes & Previews
kubectl diff -f deploy.yaml && kubectl apply -f deploy.yaml --dry-run=server -o json
Validates admission webhooks, schema, and live cluster diff without mutating state.
Strengths for Agents
- + Server-side
--dry-run=serverandkubectl diffvalidate against live admission controllers safely. - +
kubectl explainlets agents inspect any built-in or CRD schema offline/live. - + Consistent
-o jsonand-o jsonpathacross all resource types.
Caveats & Pitfalls
- ! Operating against the wrong
~/.kube/configcontext can affect production clusters if--contextis omitted. - ! Large
-o jsonresponses include verbosemanagedFieldsunless stripped.