Wait for a jsonpath condition
Waits in CI until a Service gets an external IP; works with any jsonpath field
kubectl wait --for=jsonpath='{.status.loadBalancer.ingress[0].ip}' svc/<name> -n <ns> --timeout=120s
- tool
- kubectl73 commands
More kubectl commands
-
kubectl auth can-i list secrets -n <ns> --as=<name> --as-group=system:serviceaccountsTests RBAC as another identity without their kubeconfig; you need the impersonate verb
-
kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}{"\t"}{.metadata.name}{"\t"}{.status.containerStatuses[0].restartCount}{"\n"}{end}' | sort -k3 -rn | headShows the pods that restart most often, to catch crashloops fast
-
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}'Shows the reserved overhead on each node; the gap is kube and system reservations
-
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>"}}}]'Builds a ConfigMap from a KEY=VALUE file, then adds it to the container envFrom with a JSON patch
-
kubectl get pods -A -o wideShows every pod with its node and IP address