nodeutil

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NewProviderFunc

type NewProviderFunc func(ProviderConfig) (Provider, node.NodeProvider, error)

NewProviderFunc is used from NewNodeFromClient to bootstrap a provider using the client/listers/etc created there. If a nil node provider is returned a default one will be used.

type Node

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

Node helps manage the startup/shutdown procedure for other controllers. It is intended as a convenience to reduce boiler plate code for starting up controllers.

Must be created with constructor `NewNode`.

func NewNode

func NewNode(name string, newProvider NewProviderFunc, opts ...NodeOpt) (*Node, error)

NewNode creates a new node using the provided client and name. This is intended for high-level/low boiler-plate usage. Use the constructors in the `node` package for lower level configuration.

Some basic values are set for node status, you'll almost certainly want to modify it.

If client is nil, this will construct a client using ClientsetFromEnv It is up to the caller to configure auth on the HTTP handler.

func (*Node) Done

func (n *Node) Done() <-chan struct{}

Done returns a channel that will be closed when the controller has exited.

func (*Node) Err

func (n *Node) Err() error

Err returns any error that occurred with the controller.

This always return nil before `<-Done()`.

func (*Node) NodeController

func (n *Node) NodeController() *node.NodeController

NodeController returns the configured node controller.

func (*Node) PodController

func (n *Node) PodController() *node.PodController

PodController returns the configured pod controller.

func (*Node) Ready

func (n *Node) Ready() <-chan struct{}

Ready returns a channel that will be closed after the controller is ready.

func (*Node) Run

func (n *Node) Run(ctx context.Context) (retErr error)

Run starts all the underlying controllers

func (*Node) WaitReady

func (n *Node) WaitReady(ctx context.Context, timeout time.Duration) error

WaitReady waits for the specified timeout for the controller to be ready.

The timeout is for convenience so the caller doesn't have to juggle an extra context.

type NodeConfig

type NodeConfig struct {
	// Set the runtime client to use
	Client client.Client

	// Set the cache to use
	Cache cache.Cache

	// Set the node spec to register with Kubernetes
	Node v1.Node

	// Specify the event recorder to use
	// If this is not provided, a default one will be used.
	EventRecorder record.EventRecorder

	// Set the number of workers to reconcile pods
	// The default value is derived from the number of cores available.
	NumWorkers int
}

NodeConfig is used to hold configuration items for a Node. It gets used in conjection with NodeOpt in NewNodeFromClient

type NodeOpt

type NodeOpt func(c *NodeConfig) error

NodeOpt is used as functional options when configuring a new node in NewNodeFromClient

func WithCache

func WithCache(cache cache.Cache) NodeOpt

WithCache return a NodeOpt that sets the cache to fetch local resources.

func WithClient

func WithClient(c client.Client) NodeOpt

WithClient return a NodeOpt that sets the client that will be used to create/manage the node.

type Provider

type Provider interface {
	node.PodLifecycleHandler
}

Provider contains the methods required to implement a virtual-kubelet provider.

Errors produced by these methods should implement an interface from github.com/virtual-kubelet/virtual-kubelet/errdefs package in order for the core logic to be able to understand the type of failure

type ProviderConfig

type ProviderConfig struct {
	// Hack to allow the provider to set things on the node
	// Since the provider is bootstrapped after the node object is configured
	// Primarily this is due to carry-over from the pre-1.0 interfaces that expect the provider instead of the direct *caller* to configure the node.
	Node *v1.Node
}

ProviderConfig holds objects created by NewNodeFromClient that a provider may need to bootstrap itself.

Jump to

Keyboard shortcuts

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