kube

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPVCManifest

func BuildPVCManifest(namespace, name, size, storageClass string, labels map[string]string, annotations map[string]string) ([]byte, error)

func BuildPodManifest

func BuildPodManifest(namespace, name string, labels map[string]string, annotations map[string]string, podSpec corev1.PodSpec) ([]byte, error)

func InjectPreStopForTarget added in v0.6.0

func InjectPreStopForTarget(spec *corev1.PodSpec, preStop string, targetContainer string)

func PreparePodSpec

func PreparePodSpec(podSpec corev1.PodSpec, volumes []corev1.Volume, workspaceMountPath, sidecarImage string, sidecarResources corev1.ResourceRequirements, tmux bool, preStop string) (corev1.PodSpec, error)

func PreparePodSpecForTarget added in v0.3.0

func PreparePodSpecForTarget(podSpec corev1.PodSpec, volumes []corev1.Volume, workspaceMountPath, sidecarImage string, sidecarResources corev1.ResourceRequirements, tmux bool, preStop string, targetContainer string) (corev1.PodSpec, error)

Types

type Client

type Client struct {
	Context string
	// contains filtered or unexported fields
}

func (*Client) AnnotatePod added in v0.2.0

func (c *Client) AnnotatePod(ctx context.Context, namespace, pod, key, value string) error

func (*Client) Apply

func (c *Client) Apply(ctx context.Context, namespace string, manifest []byte) error

func (*Client) CopyDirFromPod added in v0.7.0

func (c *Client) CopyDirFromPod(ctx context.Context, namespace, pod, container, remoteDir, localDir string) error

CopyDirFromPod streams a remote directory as a tar archive and extracts it locally.

func (*Client) CopyDirFromPodWithProgress added in v0.7.3

func (c *Client) CopyDirFromPodWithProgress(ctx context.Context, namespace, pod, container, remoteDir, localDir string, prog CopyProgress) error

CopyDirFromPodWithProgress streams a remote directory as a tar archive and extracts it locally. prog.OnBytes counts post-decompression bytes (the amount actually extracted into the local destination).

func (*Client) CopyDirToPod added in v0.7.0

func (c *Client) CopyDirToPod(ctx context.Context, namespace, pod, container, localDir, remoteDir string) error

CopyDirToPod archives a local directory and extracts it into remoteDir on the pod.

func (*Client) CopyDirToPodWithProgress added in v0.7.3

func (c *Client) CopyDirToPodWithProgress(ctx context.Context, namespace, pod, container, localDir, remoteDir string, prog CopyProgress) error

CopyDirToPodWithProgress archives a local directory and extracts it into remoteDir on the pod. prog.OnBytes counts uncompressed tar bytes sent; prog.OnFile fires once per regular file packed into the archive.

func (*Client) CopyFromPod

func (c *Client) CopyFromPod(ctx context.Context, namespace, podName, remotePath, localPath string) error

func (*Client) CopyFromPodInContainer added in v0.7.0

func (c *Client) CopyFromPodInContainer(ctx context.Context, namespace, podName, container, remotePath, localPath string) error

func (*Client) CopyFromPodInContainerWithProgress added in v0.7.3

func (c *Client) CopyFromPodInContainerWithProgress(ctx context.Context, namespace, podName, container, remotePath, localPath string, prog CopyProgress) error

CopyFromPodInContainerWithProgress streams a single remote file to localPath. Bytes reported via prog.OnBytes are post-decompression (i.e., the actual file size received locally), not wire bytes.

func (*Client) CopyToPod

func (c *Client) CopyToPod(ctx context.Context, namespace, localPath, podName, remotePath string) error

func (*Client) CopyToPodInContainer added in v0.3.0

func (c *Client) CopyToPodInContainer(ctx context.Context, namespace, localPath, podName, container, remotePath string) error

func (*Client) CopyToPodInContainerWithProgress added in v0.7.3

func (c *Client) CopyToPodInContainerWithProgress(ctx context.Context, namespace, localPath, podName, container, remotePath string, prog CopyProgress) error

CopyToPodInContainerWithProgress copies a single local file to remotePath in the given pod/container. It optionally reports progress via prog.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, namespace string, kind string, name string, ignoreNotFound bool) error

func (*Client) DeleteByRef added in v0.3.0

func (c *Client) DeleteByRef(ctx context.Context, namespace string, apiVersion string, kind string, name string, ignoreNotFound bool) error

func (*Client) DescribePod

func (c *Client) DescribePod(ctx context.Context, namespace, pod string) (string, error)

func (*Client) ExecInteractive

func (c *Client) ExecInteractive(ctx context.Context, namespace, pod string, tty bool, command []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error

func (*Client) ExecInteractiveInContainer added in v0.7.0

func (c *Client) ExecInteractiveInContainer(ctx context.Context, namespace, pod, container string, tty bool, command []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error

func (*Client) ExecSh

func (c *Client) ExecSh(ctx context.Context, namespace, pod string, script string) ([]byte, error)

func (*Client) ExecShInContainer

func (c *Client) ExecShInContainer(ctx context.Context, namespace, pod, container, script string) ([]byte, error)

func (*Client) ExtractTarToPod

func (c *Client) ExtractTarToPod(ctx context.Context, namespace, podName, remoteDir string, tarStream io.Reader) error

func (*Client) GetContainerRestartInfo added in v0.7.0

func (c *Client) GetContainerRestartInfo(ctx context.Context, namespace, pod, container string) (*ContainerRestartInfo, error)

GetContainerRestartInfo returns restart information for a specific container in a pod. Returns nil if the container is not found.

func (*Client) GetPodAnnotation added in v0.2.0

func (c *Client) GetPodAnnotation(ctx context.Context, namespace, pod, key string) (string, error)

func (*Client) GetPodSummary

func (c *Client) GetPodSummary(ctx context.Context, namespace, name string) (*PodSummary, error)

func (*Client) GetResourceAnnotation added in v0.4.2

func (c *Client) GetResourceAnnotation(ctx context.Context, namespace, apiVersion, kind, name, key string) (string, bool, error)

func (*Client) IsRemoteDir added in v0.7.0

func (c *Client) IsRemoteDir(ctx context.Context, namespace, pod, container, remotePath string) (bool, error)

IsRemoteDir probes whether remotePath is a directory on the pod.

func (*Client) ListPods

func (c *Client) ListPods(ctx context.Context, namespace string, allNamespaces bool, labelSelector string) ([]PodSummary, error)

func (*Client) ListResources added in v0.7.3

func (c *Client) ListResources(ctx context.Context, namespace string, allNamespaces bool, apiVersion string, kind string, labelSelector string) ([]ResourceSummary, error)

func (*Client) PersistentVolumeClaimExists added in v0.2.6

func (c *Client) PersistentVolumeClaimExists(ctx context.Context, namespace, name string) (bool, error)

func (*Client) PodContainerNames added in v0.3.0

func (c *Client) PodContainerNames(ctx context.Context, namespace, pod string) ([]string, error)

func (*Client) PortForward

func (c *Client) PortForward(ctx context.Context, namespace, pod string, forwards []string, stdout io.Writer, stderr io.Writer) error

func (*Client) ResourceExists added in v0.3.0

func (c *Client) ResourceExists(ctx context.Context, namespace string, apiVersion string, kind string, name string) (bool, error)

func (*Client) StreamFromPod

func (c *Client) StreamFromPod(ctx context.Context, namespace, podName, script string, stdout io.Writer) error

func (*Client) StreamPodLogs added in v0.3.0

func (c *Client) StreamPodLogs(ctx context.Context, namespace, pod string, opts LogStreamOptions, stdout io.Writer) error

func (*Client) StreamShInContainer added in v0.2.11

func (c *Client) StreamShInContainer(ctx context.Context, namespace, pod, container, script string, stdout, stderr io.Writer) error

func (*Client) TouchPodActivity

func (c *Client) TouchPodActivity(ctx context.Context, namespace, pod string) error

func (*Client) WaitReady

func (c *Client) WaitReady(ctx context.Context, namespace, pod string, timeout time.Duration) error

func (*Client) WaitReadyWithProgress

func (c *Client) WaitReadyWithProgress(ctx context.Context, namespace, pod string, timeout time.Duration, onProgress func(PodReadinessProgress)) error

func (*Client) WatchPodEvents added in v0.3.1

func (c *Client) WatchPodEvents(ctx context.Context, namespace, pod string, onEvent func(reason, message string))

WatchPodEvents watches Kubernetes events for the given pod and calls onEvent for each relevant event. It blocks until the context is cancelled. Only events with reasons in the allowlist are forwarded.

type ContainerRestartInfo added in v0.7.0

type ContainerRestartInfo struct {
	RestartCount   int32
	LastExitCode   int32
	LastReason     string // e.g. "OOMKilled", "Error"
	LastMessage    string
	CurrentWaiting string // e.g. "CrashLoopBackOff"
}

ContainerRestartInfo holds restart details for a single container.

type CopyProgress added in v0.7.3

type CopyProgress struct {
	// OnBytes is invoked with the number of bytes transferred since the last
	// call. For uploads this counts bytes read from the local source; for
	// downloads it counts post-decompression bytes the local side receives.
	OnBytes func(int64)
	// OnFile is invoked once per regular file packed into a directory upload
	// archive. It is not invoked for downloads or single-file copies.
	OnFile func()
}

CopyProgress carries optional callbacks invoked as data flows through a Copy* operation. All fields are nil-safe.

type LogStreamOptions added in v0.3.0

type LogStreamOptions struct {
	Container string
	Follow    bool
	Previous  bool
	TailLines *int64
	Since     time.Duration
}

type PodReadinessProgress

type PodReadinessProgress struct {
	Phase           corev1.PodPhase
	ReadyContainers int
	TotalContainers int
	Reason          string
}

type PodSummary

type PodSummary struct {
	Namespace   string
	Name        string
	Phase       string
	Deleting    bool
	CreatedAt   time.Time
	Labels      map[string]string
	Annotations map[string]string
	Ready       string
	Restarts    int32
	Reason      string
	PodIP       string
}

type ResourceSummary added in v0.7.3

type ResourceSummary struct {
	Namespace   string
	Name        string
	Kind        string
	APIVersion  string
	CreatedAt   time.Time
	Labels      map[string]string
	Annotations map[string]string
}

Jump to

Keyboard shortcuts

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