controllers

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Overview

Package controllers is the package that contains the core logic on pods and nodes simulation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Identity added in v0.3.0

func Identity() (string, error)

Identity returns a unique identifier for this controller

Types

type Config

type Config struct {
	Clock                                 clock.Clock
	EnableCNI                             bool
	DynamicClient                         dynamic.Interface
	RESTClient                            rest.Interface
	ImpersonatingDynamicClient            client.DynamicClientImpersonator
	RESTMapper                            meta.RESTMapper
	TypedClient                           kubernetes.Interface
	TypedKwokClient                       versioned.Interface
	ManageSingleNode                      string
	ManageAllNodes                        bool
	ManageNodesWithAnnotationSelector     string
	ManageNodesWithLabelSelector          string
	DisregardStatusWithAnnotationSelector string
	DisregardStatusWithLabelSelector      string
	CIDR                                  string
	NodeIP                                string
	NodeName                              string
	NodePort                              int
	LocalStages                           map[internalversion.StageResourceRef][]*internalversion.Stage
	PodPlayStageParallelism               uint
	NodePlayStageParallelism              uint
	NodeLeaseDurationSeconds              uint
	NodeLeaseParallelism                  uint
	ID                                    string
	EnableMetrics                         bool
	EnablePodCache                        bool
}

Config is the configuration for the controller

type Controller

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

Controller is a fake kubelet implementation that can be used to test

func NewController

func NewController(conf Config) (*Controller, error)

NewController creates a new fake kubelet controller

func (*Controller) GetNodeCache added in v0.4.0

func (c *Controller) GetNodeCache() informer.Getter[*corev1.Node]

GetNodeCache returns the node cache

func (*Controller) GetPodCache added in v0.4.0

func (c *Controller) GetPodCache() informer.Getter[*corev1.Pod]

GetPodCache returns the pod cache

func (*Controller) ListNodes added in v0.4.0

func (c *Controller) ListNodes() []string

ListNodes returns all nodes

func (*Controller) ListPods added in v0.4.0

func (c *Controller) ListPods(nodeName string) ([]log.ObjectRef, bool)

ListPods returns all pods on the given node

func (*Controller) Start

func (c *Controller) Start(ctx context.Context) error

Start starts the controller

func (*Controller) StartedContainersTotal added in v0.4.0

func (c *Controller) StartedContainersTotal(nodeName string) int64

StartedContainersTotal returns the total number of containers started

type Lifecycle

type Lifecycle []*LifecycleStage

Lifecycle is a list of lifecycle stage.

func NewLifecycle

func NewLifecycle(stages []*internalversion.Stage) (Lifecycle, error)

NewLifecycle returns a new Lifecycle.

func (Lifecycle) Match

func (s Lifecycle) Match(label, annotation labels.Set, data interface{}) (*LifecycleStage, error)

Match returns matched stage.

type LifecycleStage

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

LifecycleStage is a resource lifecycle stage manager

func NewLifecycleStage added in v0.4.0

func NewLifecycleStage(s *internalversion.Stage) (*LifecycleStage, error)

NewLifecycleStage returns a new LifecycleStage.

func (*LifecycleStage) Delay

func (s *LifecycleStage) Delay(ctx context.Context, v interface{}, now time.Time) (time.Duration, bool)

Delay returns the delay duration of the stage. It's not a constant value, it can be a random value.

func (*LifecycleStage) ImmediateNextStage added in v0.2.0

func (s *LifecycleStage) ImmediateNextStage() bool

ImmediateNextStage returns whether the stage is immediate next stage.

func (*LifecycleStage) Name

func (s *LifecycleStage) Name() string

Name returns the name of the stage

func (*LifecycleStage) Next

Next returns the next of the stage.

type NodeController

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

NodeController is a fake nodes implementation that can be used to test

func NewNodeController

func NewNodeController(conf NodeControllerConfig) (*NodeController, error)

NewNodeController creates a new fake nodes controller

func (*NodeController) Get added in v0.2.0

func (c *NodeController) Get(nodeName string) (*NodeInfo, bool)

Get returns Has bool and node info

func (*NodeController) List added in v0.4.0

func (c *NodeController) List() []string

List returns all name of nodes

func (*NodeController) ManageNode added in v0.5.0

func (c *NodeController) ManageNode(node *corev1.Node)

ManageNode manages a node

func (*NodeController) Start

func (c *NodeController) Start(ctx context.Context, events <-chan informer.Event[*corev1.Node]) error

Start starts the fake nodes controller if nodeSelectorFunc is not nil, it will use it to determine if the node should be managed

type NodeControllerConfig

type NodeControllerConfig struct {
	Clock                                 clock.Clock
	TypedClient                           kubernetes.Interface
	OnNodeManagedFunc                     func(nodeName string)
	OnNodeUnmanagedFunc                   func(nodeName string)
	DisregardStatusWithAnnotationSelector string
	DisregardStatusWithLabelSelector      string
	NodeIP                                string
	NodeName                              string
	NodePort                              int
	Lifecycle                             resources.Getter[Lifecycle]
	PlayStageParallelism                  uint
	FuncMap                               gotpl.FuncMap
	Recorder                              record.EventRecorder
	ReadOnlyFunc                          func(nodeName string) bool
	EnableMetrics                         bool
}

NodeControllerConfig is the configuration for the NodeController

type NodeInfo added in v0.2.0

type NodeInfo struct {
	StartedContainer atomic.Int64
}

NodeInfo is the collection of necessary node information

type NodeLeaseController added in v0.3.0

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

NodeLeaseController is responsible for creating and renewing a lease object

func NewNodeLeaseController added in v0.3.0

func NewNodeLeaseController(conf NodeLeaseControllerConfig) (*NodeLeaseController, error)

NewNodeLeaseController constructs and returns a NodeLeaseController

func (*NodeLeaseController) Held added in v0.3.0

func (c *NodeLeaseController) Held(name string) bool

Held returns true if the NodeLeaseController holds the lease

func (*NodeLeaseController) ReleaseHold added in v0.5.0

func (c *NodeLeaseController) ReleaseHold(name string)

ReleaseHold releases a lease for the NodeLeaseController

func (*NodeLeaseController) Start added in v0.3.0

func (c *NodeLeaseController) Start(ctx context.Context) error

Start starts the NodeLeaseController

func (*NodeLeaseController) TryHold added in v0.3.0

func (c *NodeLeaseController) TryHold(name string)

TryHold tries to hold a lease for the NodeLeaseController

type NodeLeaseControllerConfig added in v0.3.0

type NodeLeaseControllerConfig struct {
	Clock                clock.Clock
	HolderIdentity       string
	TypedClient          clientset.Interface
	LeaseDurationSeconds uint
	LeaseParallelism     uint
	GetLease             func(nodeName string) (*coordinationv1.Lease, bool)
	RenewInterval        time.Duration
	RenewIntervalJitter  float64
	MutateLeaseFunc      func(*coordinationv1.Lease) error
	OnNodeManagedFunc    func(nodeName string)
}

NodeLeaseControllerConfig is the configuration for NodeLeaseController

type PodController

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

PodController is a fake pods implementation that can be used to test

func NewPodController

func NewPodController(conf PodControllerConfig) (*PodController, error)

NewPodController creates a new fake pods controller

func (*PodController) Get added in v0.4.0

func (c *PodController) Get(namespace, name string) (*PodInfo, bool)

Get gets pod info

func (*PodController) List added in v0.4.0

func (c *PodController) List(nodeName string) ([]log.ObjectRef, bool)

List lists pod info

func (*PodController) Start

func (c *PodController) Start(ctx context.Context, events <-chan informer.Event[*corev1.Pod]) error

Start starts the fake pod controller It will modify the pods status to we want

type PodControllerConfig

type PodControllerConfig struct {
	Clock                                 clock.Clock
	EnableCNI                             bool
	TypedClient                           kubernetes.Interface
	NodeCacheGetter                       informer.Getter[*corev1.Node]
	DisregardStatusWithAnnotationSelector string
	DisregardStatusWithLabelSelector      string
	NodeIP                                string
	CIDR                                  string
	NodeGetFunc                           func(nodeName string) (*NodeInfo, bool)
	NodeHasMetric                         func(nodeName string) bool
	Lifecycle                             resources.Getter[Lifecycle]
	PlayStageParallelism                  uint
	FuncMap                               gotpl.FuncMap
	Recorder                              record.EventRecorder
	ReadOnlyFunc                          func(nodeName string) bool
	EnableMetrics                         bool
}

PodControllerConfig is the configuration for the PodController

type PodInfo added in v0.4.0

type PodInfo struct {
}

PodInfo is the collection of necessary pod information

type StageController added in v0.5.0

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

StageController is a fake resources implementation that can be used to test

func NewStageController added in v0.5.0

func NewStageController(conf StageControllerConfig) (*StageController, error)

NewStageController creates a new fake resources controller

func (*StageController) Start added in v0.5.0

Start starts the fake resource controller It will modify the resources status to we want

type StageControllerConfig added in v0.5.0

type StageControllerConfig struct {
	Clock                                 clock.Clock
	DynamicClient                         dynamic.Interface
	ImpersonatingDynamicClient            client.DynamicClientImpersonator
	Schema                                strategicpatch.LookupPatchMeta
	GVR                                   schema.GroupVersionResource
	DisregardStatusWithAnnotationSelector string
	DisregardStatusWithLabelSelector      string
	Lifecycle                             resources.Getter[Lifecycle]
	PlayStageParallelism                  uint
	FuncMap                               gotpl.FuncMap
	Recorder                              record.EventRecorder
}

StageControllerConfig is the configuration for the StageController

type StagesManager added in v0.5.0

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

StagesManager is a stages manager It is a dynamic getter for stages and start a stage controller

func NewStagesManager added in v0.5.0

func NewStagesManager(conf StagesManagerConfig) *StagesManager

NewStagesManager creates a stage controller manager

func (*StagesManager) Start added in v0.5.0

func (c *StagesManager) Start(ctx context.Context) error

Start starts the stages manager

type StagesManagerConfig added in v0.5.0

type StagesManagerConfig struct {
	StageGetter resources.DynamicGetter[[]*internalversion.Stage]
	StartFunc   func(ctx context.Context, ref internalversion.StageResourceRef, lifecycle resources.Getter[Lifecycle]) error
}

StagesManagerConfig is the configuration for a stages manager

Jump to

Keyboard shortcuts

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