controllers

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 43 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 NewStagesFromYaml

func NewStagesFromYaml(data []byte) ([]*internalversion.Stage, error)

NewStagesFromYaml returns stages from yaml data.

Types

type Config

type Config struct {
	EnableCNI                             bool
	ClientSet                             kubernetes.Interface
	ManageAllNodes                        bool
	ManageNodesWithAnnotationSelector     string
	ManageNodesWithLabelSelector          string
	DisregardStatusWithAnnotationSelector string
	DisregardStatusWithLabelSelector      string
	CIDR                                  string
	NodeIP                                string
	NodeName                              string
	NodePort                              int
	PodStages                             []*internalversion.Stage
	NodeStages                            []*internalversion.Stage
}

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) Start

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

Start starts the controller

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 (*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) DeleteNode

func (c *NodeController) DeleteNode(ctx context.Context, node *corev1.Node) error

DeleteNode deletes a node

func (*NodeController) FinalizersModify

func (c *NodeController) FinalizersModify(ctx context.Context, node *corev1.Node, finalizers *internalversion.StageFinalizers) (*corev1.Node, error)

FinalizersModify modify finalizers of node

func (*NodeController) Get added in v0.2.0

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

Get returns Has bool and corev1.Node if the node is existed

func (*NodeController) Has

func (c *NodeController) Has(nodeName string) bool

Has returns true if the node is existed

func (*NodeController) ListNodes

func (c *NodeController) ListNodes(ctx context.Context, ch chan<- *corev1.Node, opt metav1.ListOptions) error

ListNodes list nodes put into the channel

func (*NodeController) LockNode

func (c *NodeController) LockNode(ctx context.Context, node *corev1.Node) error

LockNode locks a given node

func (*NodeController) LockNodes

func (c *NodeController) LockNodes(ctx context.Context, nodes <-chan *corev1.Node)

LockNodes locks a nodes from the channel

func (*NodeController) Size

func (c *NodeController) Size() int

Size returns the number of nodes

func (*NodeController) Start

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

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

func (*NodeController) WatchNodes

func (c *NodeController) WatchNodes(ctx context.Context, ch chan<- *corev1.Node, opt metav1.ListOptions) error

WatchNodes watch nodes put into the channel

type NodeControllerConfig

type NodeControllerConfig struct {
	ClientSet                             kubernetes.Interface
	NodeSelectorFunc                      func(node *corev1.Node) bool
	LockPodsOnNodeFunc                    func(ctx context.Context, nodeName string) error
	DisregardStatusWithAnnotationSelector string
	DisregardStatusWithLabelSelector      string
	ManageNodesWithLabelSelector          string
	NodeIP                                string
	NodeName                              string
	NodePort                              int
	Stages                                []*internalversion.Stage
	LockNodeParallelism                   int
	FuncMap                               template.FuncMap
	Recorder                              record.EventRecorder
}

NodeControllerConfig is the configuration for the NodeController

type NodeInfo added in v0.2.0

type NodeInfo struct {
	HostIPs  []string
	PodCIDRs []string
}

NodeInfo is the collection of necessary node information

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) DeletePod

func (c *PodController) DeletePod(ctx context.Context, pod *corev1.Pod) error

DeletePod deletes a pod

func (*PodController) FinalizersModify

func (c *PodController) FinalizersModify(ctx context.Context, pod *corev1.Pod, finalizers *internalversion.StageFinalizers) (*corev1.Pod, error)

FinalizersModify modify the finalizers of the pod

func (*PodController) ListPods

func (c *PodController) ListPods(ctx context.Context, ch chan<- *corev1.Pod, opt metav1.ListOptions) error

ListPods list pods put into the channel

func (*PodController) LockPod

func (c *PodController) LockPod(ctx context.Context, pod *corev1.Pod) error

LockPod locks a given pod

func (*PodController) LockPods

func (c *PodController) LockPods(ctx context.Context, pods <-chan *corev1.Pod)

LockPods locks a pods from the channel

func (*PodController) LockPodsOnNode

func (c *PodController) LockPodsOnNode(ctx context.Context, nodeName string) error

LockPodsOnNode locks pods on the node

func (*PodController) Start

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

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

func (*PodController) WatchPods

func (c *PodController) WatchPods(ctx context.Context, lockChan chan<- *corev1.Pod, opt metav1.ListOptions) error

WatchPods watch pods put into the channel

type PodControllerConfig

type PodControllerConfig struct {
	EnableCNI                             bool
	ClientSet                             kubernetes.Interface
	DisregardStatusWithAnnotationSelector string
	DisregardStatusWithLabelSelector      string
	NodeIP                                string
	CIDR                                  string
	NodeGetFunc                           func(nodeName string) (*NodeInfo, bool)
	Stages                                []*internalversion.Stage
	LockPodParallelism                    int
	FuncMap                               template.FuncMap
	Recorder                              record.EventRecorder
}

PodControllerConfig is the configuration for the PodController

Jump to

Keyboard shortcuts

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