Last active
August 11, 2021 17:55
-
-
Save gourshete/708460a86f5fdfbcd309e9cad23ee1f5 to your computer and use it in GitHub Desktop.
Kubernetes useful commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### List all pods from all namespaces in current cluster | |
kubectl get pods --all-namespaces | |
### Get info about specific pod | |
kubectl describe pods --namespace pod-name pod-id | |
### SSH to a pod | |
kubectl exec -it -n insert_namespace_here -c web insert_pod_name_here -- bash | |
### Investigate CrashLoopBackOff state by finding previous container logs | |
kubectl logs -n insert_namespace_here -c web insert_pod_name_here -p | |
### Open rails console on pod | |
kubectl exec -it -n insert_namespace_here -c web insert_pod_name_here -- rails c | |
### Run pending migrations on pod | |
kubectl exec -it -n insert_namespace_here -c web insert_pod_name_here -- rake db:migrate | |
Delete Namespace: | |
kubectl delete namespace insert_namespace_name_here | |
### Delete all Evicted pods from all namespaces from current cluster | |
kubectl get pods --all-namespaces -o json | jq '.items[]| select(.status.reason=="Evicted") | "kubectl delete pod \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 bash -c | |
### Delete pods | |
kubectl delete pods -n namespace_name pod_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment