controllers

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: Apache-2.0 Imports: 38 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)

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
}

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

type Lifecycle

type Lifecycle []*LifecycleStage

func NewLifecycle

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

func (Lifecycle) Match

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

type LifecycleStage

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

func (*LifecycleStage) Delay

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

func (*LifecycleStage) Name

func (s *LifecycleStage) Name() string

func (*LifecycleStage) Next

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

func (*NodeController) Has

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

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

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
	ManageNodesWithAnnotationSelector     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 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) error

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
	NodeHasFunc                           func(nodeName string) 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