aylei / kubectl-debug

This repository is no longer maintained, please checkout https://github.com/JamesTGrant/kubectl-debug.
Apache License 2.0
2.31k stars 303 forks source link

Errors with containerd runtime #140

Open andrey-gava opened 3 years ago

andrey-gava commented 3 years ago

Hello!

Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:59:43Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:51:19Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}

Container runtime - containerd Kubectl-debug version v0.2.0-rc and v0.1.1

I get this kind of errors in agentless=true and with daemonset agents deployed:

kubectl-debug --agentless -n dev oauth-dev-5c885dfd7f-98j2n
Agent Pod info: [Name:debug-agent-pod-46aa6a04-655a-11eb-a63d-00505696f1d5, Namespace:default, Image:aylei/debug-agent:latest, HostPort:10027, ContainerPort:10027]
Waiting for pod debug-agent-pod-46aa6a04-655a-11eb-a63d-00505696f1d5 to run...
Start deleting agent pod oauth-dev-5c885dfd7f-98j2n 
error execute remote, unable to upgrade connection: Failed to construct RuntimeManager.  Error- failed to dial "/run/containerd/containerd.sock"- context deadline exceeded
error: unable to upgrade connection: Failed to construct RuntimeManager.  Error- failed to dial "/run/containerd/containerd.sock"- context deadline exceeded
kubectl-debug --agentless --port-forward nginx-deployment-668f8b749b-b695l
Agent Pod info: [Name:debug-agent-pod-b8591a5a-655a-11eb-ab03-5254004d77d3, Namespace:default, Image:aylei/debug-agent:latest, HostPort:10027, ContainerPort:10027]
Waiting for pod debug-agent-pod-b8591a5a-655a-11eb-ab03-5254004d77d3 to run...
Forwarding from 127.0.0.1:10027 -> 10027
Forwarding from [::1]:10027 -> 10027
Handling connection for 10027
                             Start deleting agent pod nginx-deployment-668f8b749b-b695l 
error execute remote, Internal error occurred: error attaching to container: failed to mount /tmp/containerd-mount374763324: no such file or directory
error: Internal error occurred: error attaching to container: failed to mount /tmp/containerd-mount374763324: no such file or directory
lic17 commented 3 years ago

mount hostPath /var/lib/containerd to the agent pod can fix the err.

JamesTGrant commented 3 years ago

If you're using agentless (which is good!) then you'll need to rebuild (follow the build from source instructions in the README.md) the project with the following changes in pkg/plugin/cmd.go

Add varlibcontainerd to Volumes: []corev1.Volume section like this:

            {
                Name: "varlibcontainerd",
                VolumeSource: corev1.VolumeSource{
                    HostPath: &corev1.HostPathVolumeSource{
                        Path: "/var/lib/containerd",
                    },
                },
            },  

Add varlibcontainerd to VolumeMounts section like this:

                    {
                        Name:      "vardata",
                        MountPath: "/var/data",
                    },
                    {
                        Name:      "varlibcontainerd",
                        MountPath: "/var/lib/containerd",
                    },