pods

package
v0.0.0-...-45f8ed2 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package pods provides pod status for a namespace using kubectl. It supports both a snapshot as well as a continuous stream.

Index

Constants

View Source
const (
	PodPending   = corev1.PodPending   // Accepted but not all containers have started.
	PodRunning   = corev1.PodRunning   // All containers have started and at least one is running.
	PodSucceeded = corev1.PodSucceeded // All containers terminated without error.
	PodFailed    = corev1.PodFailed    // All containers terminated with at least one error.
)

Values for Phase. These constants are copied from k8s.io/api/core/v1 as a convenience.

Variables

This section is empty.

Functions

func WatchPodStatus

func WatchPodStatus(ctx context.Context, client kubernetes.Interface, namespace string) (chan *PodStatus, func(), error)

WatchPodStatus returns a channel on which the status of the pods in the supplied namespace are written.

Types

type ContainerStatus

type ContainerStatus struct {
	Name    string
	Image   string // path of requested image
	Ready   bool   // true if ready
	Reason  string // if not empty, the reason it isn't ready
	Message string // human readable reason
	Raw     *corev1.ContainerStatus
}

A ContainerStatus contains the status of a single container in the pod.

func (*ContainerStatus) Equal

func (c *ContainerStatus) Equal(oc *ContainerStatus) bool

func (*ContainerStatus) String

func (c *ContainerStatus) String() string

type PodStatus

type PodStatus struct {
	Name           string // name of pod
	UID            types.UID
	Namespace      string
	Phase          corev1.PodPhase // current phase
	Ready          bool            // true if all containers are ready
	Containers     []ContainerStatus
	InitContainers []ContainerStatus
	Pod            corev1.Pod // copy of the raw pod
}

A PodStatus represents the status of a single Pod.

func GetPodStatus

func GetPodStatus(ctx context.Context, client kubernetes.Interface, namespace string) ([]*PodStatus, error)

GetPodStatus returns the status of the pods found in the supplied namespace.

func PodToStatus

func PodToStatus(pod *corev1.Pod) *PodStatus

PodToStatus returns a pointer to a new PodStatus for pod.

func (*PodStatus) Equal

func (p *PodStatus) Equal(q *PodStatus) bool

func (*PodStatus) String

func (p *PodStatus) String() string

type Watcher

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

A Watcher watches pod and container updates.

func NewWatcher

func NewWatcher(ctx context.Context, client kubernetes.Interface, cancel func()) (*Watcher, error)

NewWatcher returns a Watcher on the provided client or an error. The cancel function is called when the Watcher determines a container has permanently failed. The Watcher will exit if the context provided is canceled, an error is encountered, or Cleanup is called.

func (*Watcher) Cleanup

func (w *Watcher) Cleanup(err error) error

Cleanup should be called when the Watcher is no longer needed. If the Watcher encountered an error the provided err is logged and the Watcher error is returned, otherwise err is returned.

func (*Watcher) SetProgress

func (w *Watcher) SetProgress(value bool)

SetProgress determins if progress output should be displayed while watching.

Jump to

Keyboard shortcuts

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