Last active
October 12, 2022 10:28
-
-
Save rafzei/69149606d0f5a49b39ace96c6d540f4e to your computer and use it in GitHub Desktop.
crictl 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
# crictl documentation: https://kubernetes.io/docs/tasks/debug-application-cluster/crictl/ | |
# Runtime endpoints: | |
sudo crictl --runtime-endpoint unix:///run/containerd/containerd.sock | |
sudo crictl --runtime-endpoint unix:///var/run/dockershim.sock | |
sudo crictl --runtime-endpoint unix:///run/crio/crio.sock | |
## Containers | |
# Get all containers | |
sudo crictl ps | |
# Get container ID by name | |
sudo crictl ps --name=kube-apiserver -q | |
# Inspect container | |
sudo crictl inspect | |
# Stop force container | |
sudo crictl ps --name 'kube-apiserver' -q \ | |
| xargs --no-run-if-empty sudo crictl stop --timeout=0 | |
## Pods | |
# Get pods in all namespaces | |
sudo crictl pods | |
# Get the Pod ID of the Pod with crictl | |
POD_ID=$(sudo crictl pods --name=nginx-6f858d4d45-vnszm --namespace=default -q --no-trunc) | |
# Inspect Pod | |
sudo crictl inspectp | |
# Get the network namespace of this pod | |
NETNS=$(sudo crictl inspectp ${POD_ID} | jq -r '.info.runtimeSpec.linux.namespaces[] |select(.type=="network") | .path') | |
If this helped you, leave thumbs up in a comment :thumbsup: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ctr commands: https://gist.github.com/rafzei/31fb9af0c90ede46a8676e90c9d258b3