-
-
Save dixsonhuie/72321b52e8f96ab0b0bc69711fc9e026 to your computer and use it in GitHub Desktop.
k8s snippets
This file contains hidden or 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
# this works similar to force delete | |
helm delete <chart name> --no-hooks | |
# show all charts, even ones that were not successfully deleted | |
helm list -aA | |
-a no filter applied (uninstalling releases not shown otherwise) | |
-A all namespaces |
This file contains hidden or 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
1. Show previous failed deployment logs (useful if the pod starts but then crashes and restarts). | |
kubectl logs --previous <pod name> -n <namespace> | |
2. Describe pod will show events | |
kubectl describe pod <pod name> | |
Alternatively, get pod events (useful if the k8s cluster contains many pods and only interested in a single pod) | |
kubectl get event --namespace <namespace> --field-selector involvedObject.name=<pod name> | |
Or get events but sort by timestamp | |
kubectl get events --sort-by='.metadata.creationTimestamp' | |
3. Debug initContainers. Show initContainer statuses. | |
Example: | |
kubectl get pod <pod name> --template '{{.status.initContainerStatuses}}' | |
4. Get logs for an initcontainer | |
kubectl logs <pod name> -c <init container name> | |
Kubernetes documentation | |
Debug main page: https://kubernetes.io/docs/tasks/debug/debug-application/ | |
Debug initContainer subtopic: https://kubernetes.io/docs/tasks/debug-application-cluster/debug-init-containers/ | |
Debug pod subtopic: https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/ |
This file contains hidden or 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
# restore context of minikube, when using tools such kubectl | |
minikube update-context |
This file contains hidden or 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
kubectl get nodes -o wide | awk {'print $1" " $2 " " $7'} | column -t |
This file contains hidden or 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
kubectl get pod -o="custom-columns=NAME:.metadata.name,INIT-CONTAINERS:.spec.initContainers[*].name,INIT-CONTAINERS-IMAGE:.spec.initContainers[*].image,CONTAINERS:.spec.containers[*].name,CONTAINERS-IMAGE:.spec.containers[*].image" | |
NAME INIT-CONTAINERS INIT-CONTAINERS-IMAGE CONTAINERS CONTAINERS-IMAGE | |
grafana-6fc5bf87d7-87nl7 <none> <none> grafana-sc-dashboard,grafana quay.io/kiwigrid/k8s-sidecar:1.19.2,grafana/grafana:9.2.5 | |
influxdb-0 <none> <none> influxdb influxdb:1.8.10 | |
xap-dgw-xap-pu-0 <none> <none> pu-container gigaspaces/smart-cache-enterprise:16.4.2 | |
xap-manager-0 check-external-service-ready gigaspaces/smart-cache-enterprise:16.4.2 gigaspaces-container gigaspaces/smart-cache-enterprise:16.4.2 | |
xap-operator-68fd794b6f-tnvxv create-keystore,wait-for-master-before-starup alpine/openssl,busybox:1.36.0 xap-operator gigaspaces/cache-operator:16.4.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment