Documentation
¶
Overview ¶
Package kube is a backend implementation that uses the Tinkerbell CRDs to get DHCP data.
Index ¶
- Constants
- Variables
- func GetIPs(h *v1alpha1.Hardware) []string
- func GetMACs(h *v1alpha1.Hardware) []string
- func HardwareNameFunc(obj client.Object) []string
- func IPAddrs(obj client.Object) []string
- func MACAddrs(obj client.Object) []string
- func MachineNameFunc(obj client.Object) []string
- func NewFileRestConfig(kubeconfigPath, namespace string) (*rest.Config, error)
- func WorkflowByNonTerminalStateFunc(obj client.Object) []string
- type Backend
- func (b *Backend) GetByIP(ctx context.Context, ip net.IP) (*data.DHCP, *data.Netboot, error)
- func (b *Backend) GetByMac(ctx context.Context, mac net.HardwareAddr) (*data.DHCP, *data.Netboot, error)
- func (b *Backend) GetEC2Instance(ctx context.Context, ip string) (data.Ec2Instance, error)
- func (b *Backend) GetHackInstance(ctx context.Context, ip string) (data.HackInstance, error)
- func (b *Backend) Read(ctx context.Context, workflowID, namespace string) (*v1alpha1.Workflow, error)
- func (b *Backend) ReadAll(ctx context.Context, workerID string) ([]v1alpha1.Workflow, error)
- func (b *Backend) ReadBMCMachine(ctx context.Context, name string) (*data.BMCMachine, error)
- func (b *Backend) Start(ctx context.Context) error
- func (b *Backend) WaitForAPIServer(ctx context.Context, log logr.Logger, maxWaitTime time.Duration, ...) error
- func (b *Backend) Write(ctx context.Context, wf *v1alpha1.Workflow) error
- type Index
- type IndexType
Constants ¶
const HardwareNameIndex = ".metadata.name"
NameIndex is an index used with a controller-runtime client to lookup objects by name.
const IPAddrIndex = ".Spec.Interfaces.DHCP.IP"
IPAddrIndex is an index used with a controller-runtime client to lookup hardware by IP.
const MACAddrIndex = ".Spec.Interfaces.MAC"
MACAddrIndex is an index used with a controller-runtime client to lookup hardware by MAC.
const MachineNameIndex = ".metadata.name"
const WorkflowByNonTerminalState = ".status.state.nonTerminalWorker"
WorkflowByNonTerminalState is the index name for retrieving workflows in a non-terminal state.
Variables ¶
var ErrInstanceNotFound = errors.New("instance not found")
ErrInstanceNotFound indicates an instance could not be found for the given identifier.
var Indexes = map[IndexType]Index{ IndexTypeMACAddr: { Obj: &v1alpha1.Hardware{}, Field: MACAddrIndex, ExtractValue: MACAddrs, }, IndexTypeIPAddr: { Obj: &v1alpha1.Hardware{}, Field: IPAddrIndex, ExtractValue: IPAddrs, }, IndexTypeWorkflowByNonTerminalState: { Obj: &v1alpha1.Workflow{}, Field: WorkflowByNonTerminalState, ExtractValue: WorkflowByNonTerminalStateFunc, }, IndexTypeHardwareName: { Obj: &v1alpha1.Hardware{}, Field: HardwareNameIndex, ExtractValue: HardwareNameFunc, }, IndexTypeMachineName: { Obj: &bmc.Machine{}, Field: MachineNameIndex, ExtractValue: MachineNameFunc, }, }
Indexes that are currently known.
Functions ¶
func HardwareNameFunc ¶
func MachineNameFunc ¶
func NewFileRestConfig ¶
func WorkflowByNonTerminalStateFunc ¶
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 ¶
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 ¶
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 ¶
GetEC2InstanceByIP satisfies ec2.Client.
func (*Backend) GetHackInstance ¶
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) ReadBMCMachine ¶
GetByMac implements the handler.BackendReader interface and returns DHCP and netboot data based on a mac address.
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" )