Wait on a jsonpath condition kubectl
Block in CI until a Service gets its external IP; works on any jsonpath field
kubectl wait --for=jsonpath='{.status.loadBalancer.ingress[0].ip}' svc/<name> -n <ns> --timeout=120s
more kubectl
all 73 commands →
Impersonate a user and group
kubectl auth can-i list secrets -n <ns> --as=<name> --as-group=system:serviceaccounts
Sort pods by container restart count
kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}{"\t"}{.metadata.name}{"\t"}{.status.containerStatuses[0].restartCount}{"\n"}{end}' | sort -k3 -rn | head
Compare node allocatable vs capacity
kubectl get nodes -o json | jq -r '.items[] | {node:.metadata.name, capCPU:.status.capacity.cpu, allocCPU:.status.allocatable.cpu, capMem:.status.capacity.memory, allocMem:.status.allocatable.memory}'
ConfigMap from env-file with patch op
kubectl create configmap <name> --from-env-file=app.env -n <ns> --dry-run=client -o yaml | kubectl apply -f -; kubectl patch deploy/<name> -n <ns> --type=json -p='[{"op":"add","path":"/spec/template/spec/containers/0/envFrom/-","value":{"configMapRef":{"name":"<name>"}}}]'
List all pods across namespaces
kubectl get pods -A -o wide