kube

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: Apache-2.0 Imports: 30 Imported by: 2

Documentation

Overview

Package kube is a backend implementation that uses the Tinkerbell CRDs to get DHCP data.

Index

Constants

View Source
const HardwareNameIndex = ".metadata.name"

NameIndex is an index used with a controller-runtime client to lookup objects by name.

View Source
const IPAddrIndex = ".Spec.Interfaces.DHCP.IP"

IPAddrIndex is an index used with a controller-runtime client to lookup hardware by IP.

View Source
const MACAddrIndex = ".Spec.Interfaces.MAC"

MACAddrIndex is an index used with a controller-runtime client to lookup hardware by MAC.

View Source
const MachineNameIndex = ".metadata.name"
View Source
const WorkflowByNonTerminalState = ".status.state.nonTerminalWorker"

WorkflowByNonTerminalState is the index name for retrieving workflows in a non-terminal state.

Variables

View Source
var ErrInstanceNotFound = errors.New("instance not found")

ErrInstanceNotFound indicates an instance could not be found for the given identifier.

Indexes that are currently known.

Functions

func GetIPs

func GetIPs(h *v1alpha1.Hardware) []string

GetIPs retrieves all IP addresses.

func GetMACs

func GetMACs(h *v1alpha1.Hardware) []string

GetMACs retrieves all MACs associated with h.

func HardwareNameFunc

func HardwareNameFunc(obj client.Object) []string

func IPAddrs

func IPAddrs(obj client.Object) []string

IPAddrs returns a list of IP addresses for a Hardware object.

func MACAddrs

func MACAddrs(obj client.Object) []string

MACAddrs returns a list of MAC addresses for a Hardware object.

func MachineNameFunc

func MachineNameFunc(obj client.Object) []string

func NewFileRestConfig

func NewFileRestConfig(kubeconfigPath, namespace string) (*rest.Config, error)

func WorkflowByNonTerminalStateFunc

func WorkflowByNonTerminalStateFunc(obj client.Object) []string

WorkflowByNonTerminalStateFunc inspects obj - which must be a Workflow - for a Pending or Running state. If in either Pending or Running it returns a list of worker addresses.

Types

type Backend

type Backend struct {

	// ConfigFilePath is the path to a kubernetes config file (kubeconfig).
	ConfigFilePath string
	// APIURL is the Kubernetes API URL.
	APIURL string
	// Namespace is an override for the Namespace the kubernetes client will watch.
	// The default is the Namespace the pod is running in.
	Namespace string
	// ClientConfig is a Kubernetes client config. If specified, it will be used instead of
	// constructing a client using the other configuration in this object. Optional.
	ClientConfig *rest.Config
	// Indexes to register
	Indexes map[IndexType]Index
	// contains filtered or unexported fields
}

Backend is a backend implementation that uses the Tinkerbell CRDs to get DHCP data.

func NewBackend

func NewBackend(cfg Backend, opts ...cluster.Option) (*Backend, error)

NewBackend returns a controller-runtime cluster.Cluster with the Tinkerbell runtime scheme registered, and indexers for: * Hardware by MAC address * Hardware by IP address

Callers must instantiate the client-side cache by calling Start() before use.

func (*Backend) GetByIP

func (b *Backend) GetByIP(ctx context.Context, ip net.IP) (*data.DHCP, *data.Netboot, error)

GetByIP implements the handler.BackendReader interface and returns DHCP and netboot data based on an IP address.

func (*Backend) GetByMac

func (b *Backend) GetByMac(ctx context.Context, mac net.HardwareAddr) (*data.DHCP, *data.Netboot, error)

GetByMac implements the handler.BackendReader interface and returns DHCP and netboot data based on a mac address.

func (*Backend) GetEC2Instance

func (b *Backend) GetEC2Instance(ctx context.Context, ip string) (data.Ec2Instance, error)

GetEC2InstanceByIP satisfies ec2.Client.

func (*Backend) GetHackInstance

func (b *Backend) GetHackInstance(ctx context.Context, ip string) (data.HackInstance, error)

GetHackInstance returns a hack.Instance by calling the getByIP method and converting the result. This is a method that the Tootles service uses.

func (*Backend) Read

func (b *Backend) Read(ctx context.Context, workflowID, namespace string) (*v1alpha1.Workflow, error)

func (*Backend) ReadAll

func (b *Backend) ReadAll(ctx context.Context, workerID string) ([]v1alpha1.Workflow, error)

func (*Backend) ReadBMCMachine

func (b *Backend) ReadBMCMachine(ctx context.Context, name string) (*data.BMCMachine, error)

GetByMac implements the handler.BackendReader interface and returns DHCP and netboot data based on a mac address.

func (*Backend) Start

func (b *Backend) Start(ctx context.Context) error

Start starts the client-side cache.

func (*Backend) WaitForAPIServer

func (b *Backend) WaitForAPIServer(ctx context.Context, log logr.Logger, maxWaitTime time.Duration, pollInterval time.Duration, client rest.Interface) error

waitForAPIServer waits for the Kubernetes API server to become healthy.

func (*Backend) Write

func (b *Backend) Write(ctx context.Context, wf *v1alpha1.Workflow) error

type Index

type Index struct {
	Obj          client.Object
	Field        string
	ExtractValue client.IndexerFunc
}

type IndexType

type IndexType string
const (
	IndexTypeMACAddr                    IndexType = MACAddrIndex
	IndexTypeIPAddr                     IndexType = IPAddrIndex
	IndexTypeWorkflowByNonTerminalState IndexType = WorkflowByNonTerminalState
	IndexTypeHardwareName               IndexType = "hardware.metadata.name"
	IndexTypeMachineName                IndexType = "machine.metadata.name"
)

Jump to

Keyboard shortcuts

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