Documentation
¶
Overview ¶
Package kube is a backend implementation that uses the Tinkerbell CRDs to get DHCP data.
Index ¶
- Constants
- Variables
- func GetIPs(h *tinkerbell.Hardware) []string
- func GetMACs(h *tinkerbell.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 WorkflowByAgentIDFunc(obj client.Object) []string
- type Backend
- func (b *Backend) CreateWorkflow(ctx context.Context, wf *v1alpha1.Workflow) error
- func (b *Backend) DynamicRead(ctx context.Context, gvr schema.GroupVersionResource, name, namespace string) (map[string]interface{}, error)
- 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, agentID string) ([]v1alpha1.Workflow, error)
- func (b *Backend) ReadBMCMachine(ctx context.Context, name string) (*data.BMCMachine, error)
- func (b *Backend) ReadWorkflowRuleSets(ctx context.Context) ([]v1alpha1.WorkflowRuleSet, error)
- func (b *Backend) Start(ctx context.Context) error
- func (b *Backend) Update(ctx context.Context, wf *v1alpha1.Workflow) error
- func (b *Backend) WaitForAPIServer(ctx context.Context, log logr.Logger, maxWaitTime time.Duration, ...) 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 WorkflowByAgentID = ".status.agentID"
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: &tinkerbell.Hardware{}, Field: MACAddrIndex, ExtractValue: MACAddrs, }, IndexTypeIPAddr: { Obj: &tinkerbell.Hardware{}, Field: IPAddrIndex, ExtractValue: IPAddrs, }, IndexTypeHardwareName: { Obj: &tinkerbell.Hardware{}, Field: HardwareNameIndex, ExtractValue: HardwareNameFunc, }, IndexTypeMachineName: { Obj: &bmc.Machine{}, Field: MachineNameIndex, ExtractValue: MachineNameFunc, }, IndexTypeWorkflowAgentID: { Obj: &tinkerbell.Workflow{}, Field: WorkflowByAgentID, ExtractValue: WorkflowByAgentIDFunc, }, }
Indexes that are currently known.
Functions ¶
func GetMACs ¶
func GetMACs(h *tinkerbell.Hardware) []string
GetMACs retrieves all MACs associated with h.
func HardwareNameFunc ¶
func MachineNameFunc ¶
func NewFileRestConfig ¶
func WorkflowByAgentIDFunc ¶ added in v0.18.0
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
DynamicClient dynamic.Interface
// 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) CreateWorkflow ¶ added in v0.18.0
func (*Backend) DynamicRead ¶ added in v0.18.0
func (b *Backend) DynamicRead(ctx context.Context, gvr schema.GroupVersionResource, name, namespace string) (map[string]interface{}, error)
DynamicRead reads any Kubernetes resource, defined via gvr, name, and namespace, and returns the spec field as a map[string]interface{}. It uses the Kubernetes dynamic client to perform the read operation.
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 hwByIP method and converting the result. This is a method that the Tootles service uses.
func (*Backend) ReadBMCMachine ¶
ReadBMCMachine implements the handler.BackendReader interface and returns DHCP and netboot data based on a mac address.
func (*Backend) ReadWorkflowRuleSets ¶ added in v0.18.0
type IndexType ¶
type IndexType string
const ( IndexTypeMACAddr IndexType = MACAddrIndex IndexTypeIPAddr IndexType = IPAddrIndex IndexTypeHardwareName IndexType = "hardware.metadata.name" IndexTypeMachineName IndexType = "machine.metadata.name" IndexTypeWorkflowAgentID IndexType = WorkflowByAgentID )