find ephemeral files in pod

Jbn1233
Dec 18, 2022

--

Some pods doesn’t have a shell, can not exec to them ,but you can use crictl too get container root path and access to ephemeral files.

$ sudo crictl pods 638b22461c517 |grep web-1
638b22461c517 10 days ago Ready web-1
$
$ sudo crictl ps |grep 638b22461c517
03d161d503206 registry.k8s.io/nginx-slim 10 days ago Running nginx 0 638b22461c517
$
$ sudo crictl exec -it 03d161d503206 bash -c 'mkdir /test101'
$
$ sudo crictl inspect 03d161d503206 | jq -r .info.runtimeSpec.root[]
/var/lib/containers/storage/overlay/84f0ce1419c04852c596e942c673464bbd86ea154f6a57c1859743015f83975a/merged
$
$ ls -l /var/lib/containers/storage/overlay/84f0ce1419c04852c596e942c673464bbd86ea154f6a57c1859743015f83975a/merged/../diff/
total 20
drwx------ 2 root root 4096 Dec 18 15:50 root
drwxr-xr-x 3 root root 4096 Dec 7 16:21 run
drwxr-xr-x 2 root root 4096 Dec 18 15:51 test101
drwxr-xr-x 4 root root 4096 Dec 18 15:50 var

If Google bring you to here, hope you find the answer.

--

--

Jbn1233
Jbn1233

Written by Jbn1233

Very short and simple notes for CKA/SRE and may not works on your environment | jbn1233@gmail.com | Bangkok, Thailand |

No responses yet