Skip to content

Commit

Permalink
Version v1.1.0
Browse files Browse the repository at this point in the history
- Nerdctl support (@miminar)
  • Loading branch information
miminar authored Sep 13, 2023
1 parent ae1ab75 commit 3c2f0f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ If desired pod is still initializing, nsenter will pick currently running contai
Container Runtimes Clients:

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

OS:

Expand Down
16 changes: 15 additions & 1 deletion internal/containerinfo/containerinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import (
v1 "k8s.io/api/core/v1"
)

const containerdShellCmd = `"if command -v nerdctl >/dev/null 2>&1; then
exec nerdctl inspect %[1]s --format {{.State.Pid}}
fi
exec crictl inspect --output go-template --template={{.info.pid}} %[1]s"`

type ContainerInfo struct {
NodeName string
NodeIP string
Expand Down Expand Up @@ -101,7 +106,16 @@ func GetPidDiscoverCommand(containerInfo *ContainerInfo) ([]string, error) {
"--format",
"{{.State.Pid}}",
}, nil
case "containerd", "cri-o":

case "containerd":
return []string{
"sudo",
"sh",
"-c",
fmt.Sprintf(containerdShellCmd, containerInfo.ContainerID),
}, nil

case "cri-o":
return []string{
"sudo",
"crictl",
Expand Down

0 comments on commit 3c2f0f2

Please sign in to comment.