Files
magnus919_agent-skills/kubernetes/references/cli-reference.md
T

1.6 KiB

Native CLI reference

Context and discovery

The bundled wrapper places global options before the subcommand:

scripts/k8s-cli --json get pods --namespace default

Native examples:

kubectl config get-contexts
kubectl config current-context
kubectl version -o json
kubectl api-resources -o wide
kubectl api-versions
kubectl get nodes -o wide
kubectl get --raw='/readyz?verbose'

Bounded inspection

kubectl get pods -A -o wide
kubectl get events -A --sort-by=.lastTimestamp
kubectl logs POD -n NS --all-containers --tail=200 --since=1h
kubectl describe pod POD -n NS

Always add an explicit namespace, context, selector, tail, since, or timeout where the operation allows it.

Validation and mutation

kubectl diff -f manifest.yaml
kubectl apply --server-side --field-manager=agent-kubernetes --dry-run=server -f manifest.yaml
kubectl apply --server-side --field-manager=agent-kubernetes -f manifest.yaml
kubectl delete -f manifest.yaml --dry-run=server
kubectl rollout status deployment/NAME -n NS --timeout=120s
kubectl wait --for=condition=available deployment/NAME -n NS --timeout=120s

Output safety

Prefer -o json for machine parsing. Use -o name, -o wide, JSONPath, or custom columns for bounded views. Never use kubectl config view --raw, get secret -o yaml, or unbounded logs -f in chat output.

Sources