Documentation ¶
Index ¶
- Constants
- Variables
- func CheckLxcfsMount() error
- func Display(w io.Writer, statuses []StatusInfo, start time.Time)
- func GetIPCNamespace(pid int64) string
- func GetNetworkNamespace(pid int64) string
- func GetPIDNamespace(pid int64) string
- func GetUserNamespace(pid int64) string
- func HandleResizing(resize <-chan remotecommand.TerminalSize, ...)
- type Config
- type ContainerInfo
- type ContainerRuntime
- type ContainerRuntimeScheme
- type ContainerdContainerRuntime
- func (c *ContainerdContainerRuntime) ContainerInfo(ctx context.Context, cfg RunConfig) (ContainerInfo, error)
- func (c *ContainerdContainerRuntime) PullImage(ctx context.Context, image string, skipTLS bool, authStr string, cfg RunConfig) error
- func (c *ContainerdContainerRuntime) RunDebugContainer(cfg RunConfig) error
- type DebugAttacher
- type DockerContainerRuntime
- func (c *DockerContainerRuntime) AttachToContainer(cfg RunConfig, container string) error
- func (c *DockerContainerRuntime) CleanContainer(cfg RunConfig, id string)
- func (c *DockerContainerRuntime) ContainerInfo(ctx context.Context, cfg RunConfig) (ContainerInfo, error)
- func (c *DockerContainerRuntime) CreateContainer(cfg RunConfig) (*container.ContainerCreateCreatedBody, error)
- func (c *DockerContainerRuntime) PullImage(ctx context.Context, image string, skipTLS bool, authStr string, cfg RunConfig) error
- func (c *DockerContainerRuntime) RmContainer(cfg RunConfig, id string, force bool) error
- func (c *DockerContainerRuntime) RunDebugContainer(cfg RunConfig) error
- func (c *DockerContainerRuntime) StartContainer(cfg RunConfig, id string) error
- type RunConfig
- type RuntimeManager
- type Server
- type StatusInfo
Constants ¶
const ( MemFile string = "/proc/meminfo" CpuFile string = "/proc/cpuinfo" UpTimeFile string = "/proc/uptime" SwapsFile string = "/proc/swaps" StatFile string = "/proc/stat" DiskStatsFile string = "/proc/diskstats" LoadavgFile string = "/proc/loadavg" )
List of LXC filesystem files
const ( DockerScheme ContainerRuntimeScheme = "docker" ContainerdScheme ContainerRuntimeScheme = "containerd" KubectlDebugNS string = "kctldbg" K8NS string = "k8s.io" )
Variables ¶
var ( // IsLxcfsEnabled means whether to enable lxcfs LxcfsEnabled bool // LxcfsRootDir LxcfsRootDir = "/var/lib/lxc" // LxcfsHomeDir means /var/lib/lxc/lxcfs LxcfsHomeDir = "/var/lib/lxc/lxcfs" // LxcfsFiles is a list of LXC files LxcfsProcFiles = []string{MemFile, CpuFile, UpTimeFile, SwapsFile, StatFile, DiskStatsFile, LoadavgFile} )
var DebugAttacherImplementsAttacher kubeletremote.Attacher = (*DebugAttacher)(nil)
var ( DefaultConfig = Config{ DockerEndpoint: "unix:///var/run/docker.sock", ContainerdEndpoint: "/run/containerd/containerd.sock", RuntimeTimeout: 30 * time.Second, StreamIdleTimeout: 10 * time.Minute, StreamCreationTimeout: 15 * time.Second, ListenAddress: "0.0.0.0:10027", AuditFifo: "/var/data/kubectl-debug-audit-fifo/KCTLDBG-CONTAINER-ID", AuditShim: []string{"/usr/bin/strace", "-o", "KCTLDBG-FIFO", "-f", "-e", "trace=/exec"}, } )
var PushTracker = docker.NewInMemoryTracker()
Functions ¶
func CheckLxcfsMount ¶
func CheckLxcfsMount() error
CheckLxcfsMount check if the the mount point of lxcfs exists
func GetIPCNamespace ¶
func GetNetworkNamespace ¶
func GetPIDNamespace ¶
func GetUserNamespace ¶
func HandleResizing ¶
func HandleResizing(resize <-chan remotecommand.TerminalSize, resizeFunc func(size remotecommand.TerminalSize))
handleResizing spawns a goroutine that processes the resize channel, calling resizeFunc for each remotecommand.TerminalSize received from the channel. The resize channel must be closed elsewhere to stop the goroutine.
Types ¶
type Config ¶
type Config struct { DockerEndpoint string `yaml:"docker_endpoint,omitempty"` ContainerdEndpoint string `yaml:"containerd_endpoint,omitempty"` RuntimeTimeout time.Duration `yaml:"runtime_timeout,omitempty"` StreamIdleTimeout time.Duration `yaml:"stream_idle_timeout,omitempty"` StreamCreationTimeout time.Duration `yaml:"stream_creation_timeout,omitempty"` ListenAddress string `yaml:"listen_address,omitempty"` Verbosity int `yaml:"verbosity,omitempty"` Audit bool `yaml:"audit,omitempty"` AuditFifo string `yaml:"audit_fifo,omitempty"` AuditShim []string `yaml:"audit_shim,omitempty"` }
type ContainerInfo ¶
type ContainerRuntime ¶
type ContainerRuntime interface { PullImage(ctx context.Context, image string, skipTLS bool, authStr string, cfg RunConfig) error ContainerInfo(ctx context.Context, cfg RunConfig) (ContainerInfo, error) RunDebugContainer(cfg RunConfig) error }
var ContainerdContainerRuntimeImplementsContainerRuntime ContainerRuntime = (*ContainerdContainerRuntime)(nil)
var DockerContainerRuntimeImplementsContainerRuntime ContainerRuntime = (*DockerContainerRuntime)(nil)
type ContainerRuntimeScheme ¶
type ContainerRuntimeScheme string
type ContainerdContainerRuntime ¶
type ContainerdContainerRuntime struct {
// contains filtered or unexported fields
}
func (*ContainerdContainerRuntime) ContainerInfo ¶
func (c *ContainerdContainerRuntime) ContainerInfo( ctx context.Context, cfg RunConfig) (ContainerInfo, error)
func (*ContainerdContainerRuntime) RunDebugContainer ¶
func (c *ContainerdContainerRuntime) RunDebugContainer(cfg RunConfig) error
type DebugAttacher ¶
type DebugAttacher struct {
// contains filtered or unexported fields
}
DebugAttacher implements Attacher we use this struct in order to inject debug info (image, command) in the debug procedure
func (*DebugAttacher) AttachContainer ¶
func (a *DebugAttacher) AttachContainer(name string, uid kubetype.UID, container string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize) error
Implement kubeletremote.Attacher
func (*DebugAttacher) DebugContainer ¶
func (m *DebugAttacher) DebugContainer(cfg RunConfig) error
DebugContainer executes the main debug flow
func (*DebugAttacher) SetContainerLxcfs ¶
func (m *DebugAttacher) SetContainerLxcfs(cfg RunConfig) error
type DockerContainerRuntime ¶
type DockerContainerRuntime struct {
// contains filtered or unexported fields
}
func (*DockerContainerRuntime) AttachToContainer ¶
func (c *DockerContainerRuntime) AttachToContainer(cfg RunConfig, container string) error
AttachToContainer do `docker attach`. Blocks until container I/O complete
func (*DockerContainerRuntime) CleanContainer ¶
func (c *DockerContainerRuntime) CleanContainer(cfg RunConfig, id string)
func (*DockerContainerRuntime) ContainerInfo ¶
func (c *DockerContainerRuntime) ContainerInfo(ctx context.Context, cfg RunConfig) (ContainerInfo, error)
func (*DockerContainerRuntime) CreateContainer ¶
func (c *DockerContainerRuntime) CreateContainer(cfg RunConfig) (*container.ContainerCreateCreatedBody, error)
func (*DockerContainerRuntime) RmContainer ¶
func (c *DockerContainerRuntime) RmContainer(cfg RunConfig, id string, force bool) error
func (*DockerContainerRuntime) RunDebugContainer ¶
func (c *DockerContainerRuntime) RunDebugContainer(cfg RunConfig) error
func (*DockerContainerRuntime) StartContainer ¶
func (c *DockerContainerRuntime) StartContainer(cfg RunConfig, id string) error
Run a new container, this container will join the network, mount, and pid namespace of the given container
type RuntimeManager ¶
type RuntimeManager struct {
// contains filtered or unexported fields
}
RuntimeManager is responsible for docker operation
func NewRuntimeManager ¶
func (*RuntimeManager) GetAttacher ¶
func (m *RuntimeManager) GetAttacher(image, authStr string, lxcfsEnabled, registrySkipTLS bool, command []string, context context.Context, cancel context.CancelFunc) kubeletremote.Attacher
GetAttacher returns an implementation of Attacher
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ServeDebug ¶
func (s *Server) ServeDebug(w http.ResponseWriter, req *http.Request)
ServeDebug serves the debug request. first, it will upgrade the connection to SPDY. then, server will try to create the debug container, and sent creating progress to user via SPDY. after the debug container running, server attach to the debug container and pipe the streams to user. once connection closed, server killed the debug container and release related resources if any error occurs above, an error status were written to the user's stderr.