kubernetes

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceKindAppsV1Deployment  = "apps/v1/deployment"
	ResourceKindAppsV1DaemonSet   = "apps/v1/daemonset"
	ResourceKindAppsV1ReplicaSet  = "apps/v1/replicaset"
	ResourceKindAppsV1StatefulSet = "apps/v1/statefulset"
	ResourceKindBatchV1CronJob    = "batch/v1/cronjob"
	ResourceKindBatchV1Job        = "batch/v1/job"
	ResourceKindCoreV1Node        = "core/v1/node"
	ResourceKindCoreV1Namespace   = "core/v1/namespace"
	ResourceKindCoreV1Pod         = "core/v1/pod"
	ResourceKindCoreV1Container   = "core/v1/container"
	ResourceKindUnknown           = "unknown"
)

Variables

This section is empty.

Functions

func Debounce added in v0.21.0

func Debounce[T any](ch <-chan T, interval time.Duration) <-chan T

Debounce debounces messages sent to ch, returning at most one message per interval. The latest message sent to ch during a debounced time window, if any, will be sent the next window.

func TagName

func TagName(kind ResourceKind) string

TagName returns the human-readable name of a tag representing the resource. Panics if ResourceKind.IsSupported returns false.

Types

type InformerGrapher

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

InformerGrapher is a Kubernetes "informer" that reacts on changes made to resources, graphing them continuously.

func NewInformerGrapher

func NewInformerGrapher(clientset *kubernetes.Clientset, includeOldReplicaSets bool, debounceInterval time.Duration) (*InformerGrapher, error)

NewInformerGrapher returns a new InformerGrapher.

  • includeOldReplicaSets can be set to true to include all replica sets, no matter their age

func (*InformerGrapher) Graph

Graph implements platform.Platform.

func (*InformerGrapher) Graphs

func (g *InformerGrapher) Graphs() <-chan platform.Graph

Graphs returns a channel which will receive all graphs produced by the grapher asynchronously. The returned channel is shared among all consumers.

func (*InformerGrapher) OnAdd

func (g *InformerGrapher) OnAdd(object any, isInitialList bool)

OnAdd implements cache.ResourceEventHandler.

func (*InformerGrapher) OnDelete

func (g *InformerGrapher) OnDelete(object any)

OnDelete implements cache.ResourceEventHandler.

func (*InformerGrapher) OnUpdate

func (g *InformerGrapher) OnUpdate(oldObject any, newObject any)

OnUpdate implements cache.ResourceEventHandler.

func (*InformerGrapher) Start

func (g *InformerGrapher) Start()

Starts graphing continuously.

func (*InformerGrapher) Stop

func (g *InformerGrapher) Stop()

Stop stops the grapher and cleans up resources. A stopped grapher cannot be started again.

type Options

type Options struct {
	// IncludeOldReplicaSets will include all replica sets, no matter their age.
	// Defaults to false.
	IncludeOldReplicaSets bool
	// DebounceInterval is an interval controlling the minimum duration between
	// graphs.
	// Defaults to one minute.
	DebounceInterval time.Duration
}

type Platform

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

Platform implements graphing for the Kubernetes platform.

func NewPlatform

func NewPlatform(config *rest.Config, options *Options) (*Platform, error)

NewPlatform initializes a new Platform.

  • config hold information about how to connect to the Kubernetes APIs.

func (*Platform) Graph

func (p *Platform) Graph(ctx context.Context) (platform.Graph, error)

Graph implements platform.Platform.

func (*Platform) GraphContinuously added in v0.18.0

func (p *Platform) GraphContinuously(ctx context.Context) (<-chan platform.Graph, error)

type Resource

type Resource interface {
	platform.Node
	// Kind returns the type of resource.
	Kind() ResourceKind
	// Name returns the name of the resource.
	Name() string
	// String returns a textual representation of the resource.
	String() string
}

Resource is a Kubernetes resource found on the platform.

type ResourceKind

type ResourceKind string

ResourceKind defines the types of resources exposed by the platform.

func (ResourceKind) IsSupported added in v0.15.0

func (r ResourceKind) IsSupported() bool

IsSupported returns whether or not the resource is supported. Filters out custom resource definitions.

Jump to

Keyboard shortcuts

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