Skip to content

Commit 3c2f0f2

Browse files
authored
Version v1.1.0
- Nerdctl support (@miminar)
1 parent ae1ab75 commit 3c2f0f2

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ If desired pod is still initializing, nsenter will pick currently running contai
8888
Container Runtimes Clients:
8989

9090
- docker;
91-
- crictl.
91+
- crictl - expected to be present on nodes with cri-o runtime;
92+
- nerdctl - expected to be present on nodes with containerd runtime; crictl will be used as a fallback.
9293

9394
OS:
9495

internal/containerinfo/containerinfo.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import (
1010
v1 "k8s.io/api/core/v1"
1111
)
1212

13+
const containerdShellCmd = `"if command -v nerdctl >/dev/null 2>&1; then
14+
exec nerdctl inspect %[1]s --format {{.State.Pid}}
15+
fi
16+
exec crictl inspect --output go-template --template={{.info.pid}} %[1]s"`
17+
1318
type ContainerInfo struct {
1419
NodeName string
1520
NodeIP string
@@ -101,7 +106,16 @@ func GetPidDiscoverCommand(containerInfo *ContainerInfo) ([]string, error) {
101106
"--format",
102107
"{{.State.Pid}}",
103108
}, nil
104-
case "containerd", "cri-o":
109+
110+
case "containerd":
111+
return []string{
112+
"sudo",
113+
"sh",
114+
"-c",
115+
fmt.Sprintf(containerdShellCmd, containerInfo.ContainerID),
116+
}, nil
117+
118+
case "cri-o":
105119
return []string{
106120
"sudo",
107121
"crictl",

0 commit comments

Comments
 (0)