Documentation
¶
Overview ¶
Package informer provides a shared informer manager for Kubernetes resources.
Index ¶
- Constants
- Variables
- func NewNodeInformer(informer cache.SharedIndexInformer, lister listerv1.NodeLister) *nodeInformer
- func NewPodInformer(informer cache.SharedIndexInformer, lister listerv1.PodLister, ...) *podInformer
- type Manager
- func (m *Manager) GetFactory() informers.SharedInformerFactory
- func (m *Manager) GetNodeInformer() NodeInformer
- func (m *Manager) GetNodeLister() listerv1.NodeLister
- func (m *Manager) GetPodLister() listerv1.PodLister
- func (m *Manager) GetVAIndexer() cache.Indexer
- func (m *Manager) GetVAInformer() cache.SharedIndexInformer
- func (m *Manager) GetVALister() listerstoragev1.VolumeAttachmentLister
- func (m *Manager) IsVAAvailable() bool
- func (m *Manager) Nodes() NodeInformer
- func (m *Manager) Pods() PodInformer
- func (m *Manager) Start(ctx context.Context) error
- func (m *Manager) Stop()
- type NodeInformer
- type Option
- func EnableNodeInformer() Option
- func EnablePodInformer() Option
- func WithCacheSyncTimeout(timeout time.Duration) Option
- func WithDefaultPodNodeNameIndexer() Option
- func WithDefaultVANodeNameIndexer() Option
- func WithNodeIndexers(indexers cache.Indexers) Option
- func WithPodIndexers(indexers cache.Indexers) Option
- func WithVAIndexers(indexers cache.Indexers) Option
- type PodInformer
- type Predicate
- type VAPermissionError
Constants ¶
const PodIndexerName = "spec.NodeName"
const VANodeNameIndexer = "spec.nodeName"
VANodeNameIndexer is the indexer key for looking up VolumeAttachments by node name.
Variables ¶
var ErrIndexerMissing = errors.New("missing indexer")
Functions ¶
func NewNodeInformer ¶ added in v0.62.0
func NewNodeInformer( informer cache.SharedIndexInformer, lister listerv1.NodeLister, ) *nodeInformer
func NewPodInformer ¶ added in v0.62.0
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages the global SharedInformerFactory and provides access to specific informers and listers.
func NewManager ¶
func NewManager( log logrus.FieldLogger, clientset kubernetes.Interface, resyncPeriod time.Duration, opts ...Option, ) *Manager
NewManager creates a new Manager with the given clientset and resync period.
func (*Manager) GetFactory ¶
func (m *Manager) GetFactory() informers.SharedInformerFactory
GetFactory returns the underlying SharedInformerFactory for advanced use cases.
func (*Manager) GetNodeInformer ¶
func (m *Manager) GetNodeInformer() NodeInformer
GetNodeInformer returns the node informer for watching node events.
func (*Manager) GetNodeLister ¶
func (m *Manager) GetNodeLister() listerv1.NodeLister
GetNodeLister returns the node lister for querying the node cache.
func (*Manager) GetPodLister ¶
GetPodLister returns the pod lister for querying the pod cache.
func (*Manager) GetVAIndexer ¶
GetVAIndexer returns the VolumeAttachment indexer for indexed lookups. Use with VANodeNameIndexer to look up VolumeAttachments by node name. Returns nil if the VA informer is not available or not synced.
func (*Manager) GetVAInformer ¶
func (m *Manager) GetVAInformer() cache.SharedIndexInformer
GetVAInformer returns the VolumeAttachment informer for watching VA events. Returns nil if the VA informer is not available or not synced.
func (*Manager) GetVALister ¶
func (m *Manager) GetVALister() listerstoragev1.VolumeAttachmentLister
GetVALister returns the VolumeAttachment lister for querying the VA cache. Returns nil if the VA informer is not available or not synced.
func (*Manager) IsVAAvailable ¶
IsVAAvailable indicates whether the VolumeAttachment informer is available.
func (*Manager) Nodes ¶ added in v0.62.0
func (m *Manager) Nodes() NodeInformer
Nodes returns the node informer for node domain operations. This is a convenience method that returns the same as GetNodeInformer().
func (*Manager) Pods ¶ added in v0.62.0
func (m *Manager) Pods() PodInformer
Pods returns the pod informer for pod domain operations.
type NodeInformer ¶ added in v0.62.0
type NodeInformer interface {
// Get retrieves a node by name from cache
Get(name string) (*corev1.Node, error)
// List returns all nodes from cache
List() ([]*corev1.Node, error)
// Wait watches for a node to meet a condition.
// Returns a channel that signals when condition is met or context is canceled.
// Used for event-driven waiting (e.g., wait for node to become ready).
Wait(ctx context.Context, name string, condition Predicate) chan error
}
NodeInformer provides domain operations for nodes. Lifecycle (start/stop/sync) is managed by Manager.
type Option ¶
type Option func(*Manager)
Option is a functional option for configuring the Manager.
func EnableNodeInformer ¶
func EnableNodeInformer() Option
func EnablePodInformer ¶
func EnablePodInformer() Option
func WithCacheSyncTimeout ¶
WithCacheSyncTimeout sets the timeout for waiting for informer caches to sync.
func WithDefaultPodNodeNameIndexer ¶ added in v0.62.0
func WithDefaultPodNodeNameIndexer() Option
func WithDefaultVANodeNameIndexer ¶
func WithDefaultVANodeNameIndexer() Option
WithDefaultVANodeNameIndexer adds the default spec.nodeName indexer for VolumeAttachments. This is commonly used to look up VolumeAttachments by node name.
func WithNodeIndexers ¶
WithNodeIndexers sets custom indexers for the node informer.
func WithPodIndexers ¶
WithPodIndexers sets custom indexers for the pod informer.
func WithVAIndexers ¶
WithVAIndexers sets custom indexers for the VolumeAttachment informer.
type PodInformer ¶ added in v0.62.0
type PodInformer interface {
// Get retrieves a pod by namespace and name from cache
Get(namespace, name string) (*corev1.Pod, error)
// List returns all pods from cache
List() ([]*corev1.Pod, error)
// ListByNode returns all pods running on a specific node
ListByNode(nodeName string) ([]*corev1.Pod, error)
// ListByNamespace returns all pods in a namespace
ListByNamespace(namespace string) ([]*corev1.Pod, error)
}
PodInformer provides domain operations for pods.
type VAPermissionError ¶
type VAPermissionError struct {
// MissingVerb is the verb that was denied (e.g., "get", "list", "watch").
MissingVerb string
}
VAPermissionError indicates that required RBAC permissions for VolumeAttachments are missing.
func (*VAPermissionError) Error ¶
func (e *VAPermissionError) Error() string