kubectl
kubectl logs Cannot View Pod Logs and Reports NotFound
· β˜• 2 min read
1. Symptoms Pod information can be viewed 1 2 3 4 kubectl -n my-testns get pod my-testpod NAME READY STATUS RESTARTS AGE my-testpod 1/1 Running 0 2d13h Pod logs cannot be viewed 1 2 3 kubectl -n my-testns logs my-testpod -f Error from server (NotFound): the server could not find the requested resource ( pods/log my-testpod) On the host where the Pod runs, the container logs can be viewed with docker logs.

Common Commands for Cleaning Up Kubernetes Cluster Resources
· β˜• 4 min read
Clusters that run for a long time often face various kinds of resource exhaustion. On top of that, when disk space runs low, Kubelet will proactively clean up images on its own, adding another source of uncertainty. This article provides some command snippets for cleanup work. 1. Cleaning Up Basic Kubernetes Objects Clean up Pods in Evicted state 1 sudo kubectl get pods --all-namespaces -o wide | grep Evicted | awk '{print $1,$2}' | sudo xargs -L1 kubectl delete pod -n Clean up Pods in Error state 1 sudo kubectl get pods --all-namespaces -o wide | grep Error | awk '{print $1,$2}' | sudo xargs -L1 kubectl delete pod -n Clean up Pods in Completed state 1 sudo kubectl get pods --all-namespaces -o wide | grep Completed | awk '{print $1,$2}' | sudo xargs -L1 kubectl delete pod -n Clean up unused PVs 1 sudo kubectl describe -A pvc | grep -E "^Name:.

Kubernetes Batch Operation Commands
· β˜• 1 min read
1. Delete Pods in the Evicted State in Bulk 1 kubectl get pods --all-namespaces -o wide | grep Evicted | awk '{print $1,$2}' | xargs -L1 kubectl delete pod -n 2. Delete Pods in a Given State in a Given Namespace in Bulk Using field-selectors, you can delete Pods in a given state in a given namespace.

How to Configure an Efficient Kubernetes Command-Line Terminal
· β˜• 2 min read
Sharpening the axe never delays the woodcutting. No matter when, the time you spend on your toolchain is always worth it. 1. Autocompletion - kubectl OS X install command: 1 brew install bash-complete@2 It is not just for kubectl β€” it provides completion prompts for other command lines too.