nodeutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientsetFromEnv

func ClientsetFromEnv(kubeConfigPath string) (*kubernetes.Clientset, error)

ClientsetFromEnv returns a kuberentes client set from: 1. the passed in kubeconfig path 2. If the kubeconfig path is empty or non-existent, then the in-cluster config is used.

func NodeLeaseV1Client

func NodeLeaseV1Client(client kubernetes.Interface) coordclientset.LeaseInterface

NodeLeaseV1Client creates a V1 Lease client for use with node leases from the passed in client.

Use this with node.WithNodeEnableLeaseV1Beta1 when creating a node controller.

Types

type NewProviderFunc

type NewProviderFunc func(ProviderConfig) (Provider, virtual_kubelet.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() *virtual_kubelet.NodeController

NodeController returns the configured node controller.

func (*Node) PodController

func (n *Node) PodController() *virtual_kubelet.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 client to use, otherwise a client will be created from ClientsetFromEnv
	Client kubernetes.Interface

	// Set the PodLister to use
	PodLister lister.PodLister

	// Set the PodInformer to use
	PodInformer informer.PodInformer

	// Set the node spec to register with Kubernetes
	NodeSpec 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

	// Set the error handler for node status update failures
	NodeStatusUpdateErrorHandler virtual_kubelet.ErrorHandler
}

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 WithClient

func WithClient(c kubernetes.Interface) NodeOpt

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

func WithPodInformer

func WithPodInformer(pi informer.PodInformer) NodeOpt

WithPodInformer return a NodeOpt that sets the pod informer that will be used to create/manage the pod.

func WithPodLister

func WithPodLister(pl lister.PodLister) NodeOpt

WithPodLister return a NodeOpt that sets the pod lister that will be used to create/manage the pod.

type Provider

type Provider interface {
	virtual_kubelet.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