Helpful K8 Commands - safrrhmn/docker-k8-docs GitHub Wiki

Viewing and Finding Resources

Get commands with basic output

kubectl get services # List all services in the namespace

kubectl get pods --all-namespaces # List all pods in all namespaces

kubectl get pods -o wide # List all pods in the current namespace, with more details

kubectl get deployment my-dep # List a particular deployment

kubectl get pods # List all pods in the namespace

kubectl get pod my-pod -o yaml # Get a pod's YAML

Deployments

kubectl get deployment my-dep # Get deployment List kubectl rollout restart deployment/frontend # Rolling restart of the "frontend" deployment

Delete

kubectl get pods -n pspd-apis-dev --no-headers=true | awk '/^cron/{print $1}'| xargs kubectl delete -n pspd-apis-dev pod # Delete by name