k8s

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 31 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ActivitySourceExec        = "exec"
	ActivitySourceLogs        = "logs"
	ActivitySourcePortForward = "port-forward"
)

Activity sources the backend accepts for a heartbeat.

View Source
const ActivityHeartbeatInterval = 2 * time.Minute

ActivityHeartbeatInterval is how often a long-running session tells the backend the environment is still in use, so it is not stopped mid-session for having no recent visit. It is short so that one failed report can't end a session under a short timeout. The backend records one audit event per five minutes however often it hears from a session.

Variables

This section is empty.

Functions

func StartActivityHeartbeat added in v1.11.0

func StartActivityHeartbeat(ctx context.Context, c client.Client, envID, source string, interval time.Duration) (stop func())

StartActivityHeartbeat reports activity on an environment every interval until ctx is done, stop is called or activityMaxSession passes. The first report goes out after one interval: fetching the kubeconfig already counts as the start of the session.

A failed report must never end the session. It is logged, and repeated failures warn the user once. A report can't be cancelled, so stop waits for one in flight only briefly: the session is over by then, and it must not be held up by a stalled API.

func StartInputHeartbeat added in v1.11.0

func StartInputHeartbeat(ctx context.Context, c client.Client, envID, source string, interval time.Duration, input *InputActivity) (stop func())

StartInputHeartbeat is StartActivityHeartbeat for a session that only counts as activity while it has input: it skips an interval that had none.

Types

type Client added in v1.7.0

type Client struct {
	Path string
}

Client points at the environment's kubeconfig saved in ~/.shipyard, for tools such as telepresence that need a file rather than a parsed config.

func NewConfig added in v1.7.0

func NewConfig(c client.Client, envid string) (*Client, error)

NewConfig saves the environment's kubeconfig to the shared ~/.shipyard/kubeconfig and returns its path. Only telepresence uses it; logs, exec and port-forward keep the config in memory (see New).

type ContainerState added in v1.10.0

type ContainerState struct {
	Pod       string
	Container string
	// Init is set when Container is an init container
	Init         bool
	Ready        bool
	RestartCount int32
	// Reason and ExitCode describe the last time the container stopped, if it has
	Reason   string
	ExitCode *int32
}

ContainerState describes a service container's restarts and how it last stopped.

type ExecOutput added in v1.9.0

type ExecOutput struct {
	Stdout    string
	Stderr    string
	ExitCode  int
	Truncated bool
}

ExecOutput is what a non-interactive command wrote before it finished.

type InputActivity added in v1.11.0

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

InputActivity records whether a session has had input since the last report. An exec session counts as activity only while someone is using it, as in the web terminal, so a forgotten shell does not keep an environment running.

func (*InputActivity) Reader added in v1.11.0

func (a *InputActivity) Reader(r io.Reader) io.Reader

Reader returns r, noting each read that returns data.

type Service

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

func New

func New(c client.Client, id string, svc *types.Service) (*Service, error)

func (*Service) Exec

func (c *Service) Exec(args []string, input *InputActivity) error

func (*Service) ExecCapture added in v1.9.0

func (c *Service) ExecCapture(ctx context.Context, args []string, maxBytes int) (ExecOutput, error)

ExecCapture runs a command in the service's pod and returns what it wrote.

This is Exec without the terminal: no stdin is attached and no TTY is requested, so it fits a caller that has one request and wants one response, such as the MCP server. Dropping the TTY also keeps stdout and stderr on separate streams, which a TTY merges.

A command that exits non-zero is not an error here: its output and exit code are the answer. An error means the exec never ran or the stream broke.

maxBytes caps each stream; zero or less means no cap. Cap what you hand to a model: `cat` on a large file otherwise fills its context with one tool result.

func (*Service) GetLogsAsString added in v1.8.0

func (c *Service) GetLogsAsString(follow bool, tail int64) (string, error)

GetLogsAsString returns logs as a string instead of printing them This is used by the MCP logs service to capture log output

func (*Service) GetPreviousLogsAsString added in v1.10.0

func (c *Service) GetPreviousLogsAsString(tail int64) (string, error)

GetPreviousLogsAsString returns the logs of the container's previous run, the one that crashed.

func (*Service) Logs

func (c *Service) Logs(follow bool, tail int64) error

func (*Service) PortForward

func (c *Service) PortForward(ports []string) error

func (*Service) UseCrashedPod added in v1.10.0

func (c *Service) UseCrashedPod() ContainerState

UseCrashedPod switches this Service (logs, exec and port-forward alike) to the pod and container most likely to explain a crash, which may be an init container or a sidecar, and returns that container's state. Use a fresh Service for anything else.

Jump to

Keyboard shortcuts

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