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 HardwareAgentID(obj client.Object) []string
- func HardwareName(obj client.Object) []string
- func IPAddrs(obj client.Object) []string
- func InstanceID(obj client.Object) []string
- func MACAddrs(obj client.Object) []string
- func MachineName(obj client.Object) []string
- func NewFileRestConfig(kubeconfigPath, namespace string) (*rest.Config, error)
- func WorkflowAgentID(obj client.Object) []string
- type Backend
- func (b *Backend) CreateHardware(ctx context.Context, hw *v1alpha1.Hardware) error
- func (b *Backend) CreateWorkflow(ctx context.Context, w *v1alpha1.Workflow) error
- func (b *Backend) DynamicRead(ctx context.Context, gvr schema.GroupVersionResource, name, namespace string) (map[string]interface{}, error)
- func (b *Backend) FilterBMCMachine(ctx context.Context, opts data.HardwareFilter) (*data.BMCMachine, error)
- func (b *Backend) FilterHardware(ctx context.Context, opts data.HardwareFilter) (*v1alpha1.Hardware, error)
- func (b *Backend) ListHardware(ctx context.Context, opts data.HardwareFilter) ([]v1alpha1.Hardware, error)
- func (b *Backend) ListWorkflowRuleSets(ctx context.Context, opts data.WorkflowFilter) ([]v1alpha1.WorkflowRuleSet, error)
- func (b *Backend) ListWorkflows(ctx context.Context, opts data.WorkflowFilter) ([]v1alpha1.Workflow, error)
- func (b *Backend) ReadAuthSecret(ctx context.Context, name, namespace string) (string, string, error)
- func (b *Backend) ReadHardware(ctx context.Context, name, namespace string) (*v1alpha1.Hardware, error)
- func (b *Backend) ReadWorkflow(ctx context.Context, name, namespace string) (*v1alpha1.Workflow, error)
- func (b *Backend) Start(ctx context.Context) error
- func (b *Backend) UpdateHardware(ctx context.Context, hw *v1alpha1.Hardware, opts data.UpdateOptions) error
- func (b *Backend) UpdateWorkflow(ctx context.Context, wf *v1alpha1.Workflow, opts data.UpdateOptions) error
- func (b *Backend) WaitForAPIServer(ctx context.Context, log logr.Logger, maxWaitTime time.Duration, ...) error
- type Index
- type IndexType
Constants ¶
const ( IndexTypeMACAddr IndexType = MACAddrIndex IndexTypeIPAddr IndexType = IPAddrIndex IndexTypeHardwareName IndexType = "hardware.metadata.name" IndexTypeMachineName IndexType = "machine.metadata.name" IndexTypeWorkflowAgentID IndexType = WorkflowAgentIDIndex IndexTypeHardwareAgentID IndexType = HardwareAgentIDIndex IndexTypeInstanceID IndexType = InstanceIDIndex // MACAddrIndex is an index used with a controller-runtime client to lookup hardware by MAC. MACAddrIndex = ".Spec.Interfaces.MAC" // IPAddrIndex is an index used with a controller-runtime client to lookup hardware by IP. IPAddrIndex = ".Spec.Interfaces.DHCP.IP" // NameIndex is an index used with a controller-runtime client to lookup objects by name. NameIndex = ".metadata.name" // WorkflowAgentIDIndex is an index used with a controller-runtime client to lookup workflows by their status agent id. WorkflowAgentIDIndex = ".status.agentID" // HardwareAgentIDIndex is an index used with a controller-runtime client to lookup hardware by their spec agent id. HardwareAgentIDIndex = ".spec.agentID" // InstanceIDIndex is an index used with a controller-runtime client to lookup hardware by its metadata instance id. InstanceIDIndex = ".Spec.Metadata.Instance.ID" // #nosec G101 - This is a field path, not a credential )
Variables ¶
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: NameIndex, ExtractValue: HardwareName, }, IndexTypeMachineName: { Obj: &bmc.Machine{}, Field: NameIndex, ExtractValue: MachineName, }, IndexTypeWorkflowAgentID: { Obj: &tinkerbell.Workflow{}, Field: WorkflowAgentIDIndex, ExtractValue: WorkflowAgentID, }, IndexTypeHardwareAgentID: { Obj: &tinkerbell.Hardware{}, Field: HardwareAgentIDIndex, ExtractValue: HardwareAgentID, }, IndexTypeInstanceID: { Obj: &tinkerbell.Hardware{}, Field: InstanceIDIndex, ExtractValue: InstanceID, }, }
Indexes that are currently known.
Functions ¶
func GetMACs ¶
func GetMACs(h *tinkerbell.Hardware) []string
GetMACs retrieves all MACs associated with h.
func HardwareAgentID ¶ added in v0.23.0
HardwareAgentID extracts the agent ID from a Hardware's spec for field indexing.
func HardwareName ¶ added in v0.23.0
HardwareName extracts the name of a Hardware object for field indexing.
func InstanceID ¶ added in v0.23.0
InstanceID extracts the instance ID from a Hardware's metadata for field indexing.
func MachineName ¶ added in v0.23.0
MachineName extracts the name of a BMC Machine object for field indexing.
func NewFileRestConfig ¶
func WorkflowAgentID ¶ added in v0.23.0
WorkflowAgentID extracts the agent ID from a Workflow's status for field indexing.
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
// QPS is the maximum queries per second to the Kubernetes API server.
// If set to 0, defaults to 5. Negative values disable rate limiting.
QPS float32
// Burst is the maximum burst for throttle in the Kubernetes client.
// If set to 0, defaults to 10. Negative values disable burst limiting.
Burst int
// 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) CreateHardware ¶ added in v0.19.0
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.
This is most useful for look ups of References in Tinkerbell CRDs.
func (*Backend) FilterBMCMachine ¶ added in v0.23.0
func (b *Backend) FilterBMCMachine(ctx context.Context, opts data.HardwareFilter) (*data.BMCMachine, error)
FilterBMCMachine looks up a machine.bmc.tinkerbell.org object based on the bmcRef in the hardware object matching the given filter.
func (*Backend) FilterHardware ¶ added in v0.23.0
func (b *Backend) FilterHardware(ctx context.Context, opts data.HardwareFilter) (*v1alpha1.Hardware, error)
FilterHardware looks up a single Hardware object using selector-based list filtering. Exactly one result is expected; zero results returns a not-found error and multiple results returns a multiple-found error.
func (*Backend) ListHardware ¶ added in v0.23.0
func (*Backend) ListWorkflowRuleSets ¶ added in v0.23.0
func (b *Backend) ListWorkflowRuleSets(ctx context.Context, opts data.WorkflowFilter) ([]v1alpha1.WorkflowRuleSet, error)
func (*Backend) ListWorkflows ¶ added in v0.23.0
func (*Backend) ReadAuthSecret ¶ added in v0.23.0
func (b *Backend) ReadAuthSecret(ctx context.Context, name, namespace string) (string, string, error)
ReadAuthSecret looks up a Secret by name and namespace using a direct Get. It expects the Secret to contain "username" and "password" keys in its data.
func (*Backend) ReadHardware ¶ added in v0.19.0
func (b *Backend) ReadHardware(ctx context.Context, name, namespace string) (*v1alpha1.Hardware, error)
ReadHardware looks up a Hardware object by name and namespace using a direct Get.