k8s

package
v0.3.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// EndOfTransmission end
	EndOfTransmission = "\u0004"
)

Variables

This section is empty.

Functions

func ValidatePod

func ValidatePod(pod *corev1.Pod, containerName string) (bool, error)

ValidatePod validate pod.

Types

type Client

type Client struct {
	kubernetes.Interface
	// contains filtered or unexported fields
}

Client wraps k8s client and namespace

func NewClient

func NewClient(kubeconfig string) (*Client, error)

NewClient creates a new client

func (*Client) CopyFileToPod

func (c *Client) CopyFileToPod(pod, container, namespace string, file io.Reader, dstPath string) error

CopyFileToPod copies client file to pod

func (*Client) Exec

func (c *Client) Exec(cmd []string, ptyHandler PtyHandler, namespace, podName, containerName string) error

Exec into a pod

func (*Client) GetPod

func (c *Client) GetPod(ctx context.Context, name, namespace string) (*corev1.Pod, error)

GetPod specified pod in specified namespace.

func (*Client) LogStreamLine

func (c *Client) LogStreamLine(ctx context.Context, name, namespace string, opts *corev1.PodLogOptions, writer io.Writer) error

LogStreamLine gets logs of specified pod in specified namespace and copy to writer.

func (*Client) Logs

func (c *Client) Logs(name, namespace string, opts *corev1.PodLogOptions) *rest.Request

Logs gets logs of specified pod in specified namespace.

type Logger

type Logger interface {
	io.WriteCloser
}

Logger is an interface for output pod log

type PtyHandler

type PtyHandler interface {
	remotecommand.TerminalSizeQueue
	Done()
	Tty() bool
	Stdin() io.Reader
	Stdout() io.Writer
	Stderr() io.Writer
}

PtyHandler is what remotecommand expects from a pty

type TerminalMessage

type TerminalMessage struct {
	Operation string `json:"operation"`
	Data      string `json:"data"`
	Rows      uint16 `json:"rows"`
	Cols      uint16 `json:"cols"`
}

TerminalMessage is the messaging protocol between ShellController and TerminalSession.

type WsLogger

type WsLogger struct {
	// contains filtered or unexported fields
}

WsLogger output container log to websocket

func NewWsLogger

func NewWsLogger(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*WsLogger, error)

NewWsLogger creates WsLogger

func (*WsLogger) Close

func (l *WsLogger) Close() error

Close ws connection

func (*WsLogger) Write

func (l *WsLogger) Write(p []byte) (n int, err error)

Write bytes

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL