Documentation
¶
Index ¶
- Constants
- func ContainerNameToRef(pod *corev1.Pod) map[string]*corev1.Container
- func GetContainerStatusByName(pod *corev1.Pod, containerName string) *corev1.ContainerStatus
- func GetSize(fd uintptr) *remotecommand.TerminalSize
- func IsTerminal(i interface{}) bool
- func SetKubernetesDefaults(config *rest.Config) error
- func WaitForContainer(ctx context.Context, client corev1client.PodsGetter, ...) (*corev1.Pod, error)
- type CleanOptions
- type Cleaner
- type Connector
- func (connector *Connector) Connect() error
- func (connector *Connector) ContainerToConnect() (*corev1.Container, error)
- func (connector *Connector) DoConnect(method string, url *url.URL, terminalSizeQueue remotecommand.TerminalSizeQueue) error
- func (connector *Connector) GetDefaultAttachFunc(containerToAttach *corev1.Container, sizeQueue remotecommand.TerminalSizeQueue) func() error
- func (connector *Connector) GetDefaultExecFunc(containerToAttach *corev1.Container, sizeQueue remotecommand.TerminalSizeQueue) func() error
- func (connector *Connector) SetTTY() TTY
- type Debugger
- func (debugger *Debugger) CompleteAndVerifyOptions(cmd *cobra.Command, args []string, imager ImagesManagement) error
- func (debugger *Debugger) DebugNode(ctx context.Context) (*corev1.Pod, error)
- func (debugger *Debugger) DebugPod(ctx context.Context) (*corev1.Pod, error)
- func (debugger *Debugger) Run() (string, error)
- type DebuggerOptions
- type Handler
- type ImagesManagement
- type ImagesManager
- type SafeFunc
- type TTY
Constants ¶
const ( NodeDebugPrefix = "node-debugger" PodDebugPrefix = "pod-debugger" TypeDebugNode = "node" TypeDebugPod = "pod" FSDebugID = "." )
const DefaultSealerRegistryURL = "registry.cn-qingdao.aliyuncs.com/sealer-apps/"
const SealerDebugMotd = `` /* 1495-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func ContainerNameToRef ¶
ContainerNameToRef returns the container names in pod.
func GetContainerStatusByName ¶
func GetContainerStatusByName(pod *corev1.Pod, containerName string) *corev1.ContainerStatus
GetContainerStatusByName returns the container status by the containerName.
func GetSize ¶
func GetSize(fd uintptr) *remotecommand.TerminalSize
GetSize returns the current size of the terminal associated with fd.
func IsTerminal ¶
func IsTerminal(i interface{}) bool
IsTerminal returns whether the passed object is a terminal or not
func SetKubernetesDefaults ¶
SetKubernetesDefaults sets default values on the provided client config for accessing the Kubernetes API or returns an error if any of the defaults are impossible or invalid.
func WaitForContainer ¶
func WaitForContainer(ctx context.Context, client corev1client.PodsGetter, namespace, podName, containerName string) (*corev1.Pod, error)
WaitForContainer watches the given pod until the container is running or terminated.
Types ¶
type CleanOptions ¶
CleanOptions holds the options for an invocation of debug clean.
func NewDebugCleanOptions ¶
func NewDebugCleanOptions() *CleanOptions
type Cleaner ¶
type Cleaner struct { *CleanOptions AdminKubeConfigPath string genericclioptions.IOStreams // contains filtered or unexported fields }
Cleaner cleans the debug containers and pods.
func NewDebugCleaner ¶
func NewDebugCleaner() *Cleaner
func (*Cleaner) CompleteAndVerifyOptions ¶
CompleteAndVerifyOptions completes and verifies DebugCleanOptions.
func (*Cleaner) ExitEphemeralContainer ¶
func (cleaner *Cleaner) ExitEphemeralContainer(config *restclient.Config) error
ExitEphemeralContainer exits the ephemeral containers and the ephemeral container's status will become terminated.
func (*Cleaner) RemovePod ¶
func (cleaner *Cleaner) RemovePod(ctx context.Context, kubeClientCorev1 corev1client.CoreV1Interface) error
RemovePod removes the debug pods.
type Connector ¶
type Connector struct { NameSpace string ContainerName string Command []string Stdin bool TTY bool genericclioptions.IOStreams Motd string Pod *corev1.Pod Config *restclient.Config }
Connector holds the options to connect a running container.
func (*Connector) ContainerToConnect ¶
ContainerToConnect checks if there is a container to attach, and if exists returns the container object to attach.
func (*Connector) DoConnect ¶
func (connector *Connector) DoConnect(method string, url *url.URL, terminalSizeQueue remotecommand.TerminalSizeQueue) error
DoConnect executes attach to a running container with url.
func (*Connector) GetDefaultAttachFunc ¶
func (connector *Connector) GetDefaultAttachFunc(containerToAttach *corev1.Container, sizeQueue remotecommand.TerminalSizeQueue) func() error
GetDefaultAttachFunc returns the default attach function.
func (*Connector) GetDefaultExecFunc ¶
func (connector *Connector) GetDefaultExecFunc(containerToAttach *corev1.Container, sizeQueue remotecommand.TerminalSizeQueue) func() error
GetDefaultExecFunc returns the default exec function.
type Debugger ¶
type Debugger struct { *DebuggerOptions Motd string genericclioptions.IOStreams // contains filtered or unexported fields }
func NewDebugger ¶
func NewDebugger(options *DebuggerOptions) *Debugger
func (*Debugger) CompleteAndVerifyOptions ¶
func (debugger *Debugger) CompleteAndVerifyOptions(cmd *cobra.Command, args []string, imager ImagesManagement) error
CompleteAndVerifyOptions completes and verifies DebugOptions.
type DebuggerOptions ¶
type DebuggerOptions struct { Type string // debug pod or node TargetName string // pod/node name to be debugged Image string // debug container/pod image name Env []corev1.EnvVar Interactive bool // -i TTY bool // -t Command []string // after -- CheckList []string // check network、volume etc DebugContainerName string // debug container name Namespace string // kubernetes namespace PullPolicy string AdminKubeConfigPath string // Type is container TargetContainer string // target container to share the namespace }
DebuggerOptions holds the options for an invocation of debug.
func NewDebugOptions ¶
func NewDebugOptions() *DebuggerOptions
NewDebugOptions returns a DebugOptions initialized with default values.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler guarantees execution of notifications after a critical section (the function passed to a Run method), even in the presence of process termination. It guarantees exactly once invocation of the provided notify functions.
func Chain ¶
Chain creates a new handler that invokes all notify functions when the critical section exits and then invokes the optional handler's notifications. This allows critical sections to be nested without losing exactly once invocations. Notify functions can invoke any cleanup needed but should not exit (which is the responsibility of the parent handler).
func New ¶
New creates a new handler that guarantees all notify functions are run after the critical section exits (or is interrupted by the OS), then invokes the final handler. If no final handler is specified, the default final is `os.Exit(1)`. A handler can only be used for one critical section.
func (*Handler) Close ¶
func (h *Handler) Close()
Close executes all the notification handlers if they have not yet been executed.
type ImagesManagement ¶
type ImagesManager ¶
type ImagesManager struct { RegistryURL string DefaultImagesMap map[string]string // "RichToolsOnUbuntu": "debug:ubuntu" DefaultImageKey string // "RichToolsOnUbuntu" DefaultImage string // RegistryURL + DefaultImagesMap[DefaultImageName] }
ImagesManager holds the default images information.
func NewDebugImagesManager ¶
func NewDebugImagesManager() *ImagesManager
func (*ImagesManager) GetDefaultImage ¶
func (manager *ImagesManager) GetDefaultImage() (string, error)
GetDefaultImage return the default image provide by debug.
func (*ImagesManager) ShowDefaultImages ¶
func (manager *ImagesManager) ShowDefaultImages() error
ShowDefaultImages shows default images provided by debug.
type TTY ¶
type TTY struct { // In is a reader representing stdin. It is a required field. In io.Reader // Out is a writer representing stdout. It must be set to support terminal resizing. It is an // optional field. Out io.Writer // Raw is true if the terminal should be set raw. Raw bool // TryDev indicates the TTY should try to open /dev/tty if the provided input // is not a file descriptor. TryDev bool // Parent is an optional interrupt handler provided to this function - if provided // it will be invoked after the terminal state is restored. If it is not provided, // a signal received during the TTY will result in os.Exit(0) being invoked. Parent *Handler // contains filtered or unexported fields }
TTY helps invoke a function and preserve the state of the terminal, even if the process is terminated during execution. It also provides support for terminal resizing for remote command attachment.
func (TTY) GetSize ¶
func (t TTY) GetSize() *remotecommand.TerminalSize
GetSize returns the current size of the user's terminal. If it isn't a terminal, nil is returned.
func (TTY) IsTerminalIn ¶
IsTerminalIn returns true if t.In is a terminal. Does not check /dev/tty even if TryDev is set.
func (TTY) IsTerminalOut ¶
IsTerminalOut returns true if t.Out is a terminal. Does not check /dev/tty even if TryDev is set.
func (*TTY) MonitorSize ¶
func (t *TTY) MonitorSize(initialSizes ...*remotecommand.TerminalSize) remotecommand.TerminalSizeQueue
MonitorSize monitors the terminal's size. It returns a TerminalSizeQueue primed with initialSizes, or nil if there's no TTY present.
func (TTY) Safe ¶
Safe invokes the provided function and will attempt to ensure that when the function returns (or a termination signal is sent) that the terminal state is reset to the condition it was in prior to the function being invoked. If Raw is true the terminal will be put into raw mode prior to calling the function.