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) ApplyHardwareInBandAttributes(ctx context.Context, name, namespace string, attrs *v1alpha1.Attributes) error
- 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) 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) RenderedHardware(_ context.Context, hw *tinkerbell.Hardware) (*tinkerbell.Hardware, error)
- func (b *Backend) RenderedReader() *RenderedReader
- func (b *Backend) ResolveReferences(ctx context.Context, hw *tinkerbell.Hardware) (map[string]any, 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
- func (b *Backend) Watches(namespace string) bool
- type Index
- type IndexType
- type RenderedReader
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
// Namespaces are the namespaces the kubernetes client watches, one watch per
// namespace and type. Empty means all namespaces.
// Only the cache enforces them, so reads that bypass the cache must check them
// themselves, with Watches.
Namespaces []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
// HardwareReferenceAllowListRules and HardwareReferenceDenyListRules are the Quamina rules
// ResolveReferences applies. An empty deny list denies every reference.
HardwareReferenceAllowListRules []string
HardwareReferenceDenyListRules []string
// Rendering serves Hardware with the templates in its spec rendered.
Rendering bool
// Logger receives background rendering errors. Optional.
Logger logr.Logger
// 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) ApplyHardwareInBandAttributes ¶ added in v0.26.0
func (b *Backend) ApplyHardwareInBandAttributes(ctx context.Context, name, namespace string, attrs *v1alpha1.Attributes) error
ApplyHardwareInBandAttributes issues a Server-Side Apply patch for status.attributes.inBand, scoped to only that path so it never conflicts with Rufio's writes to the sibling status.attributes.outOfBand subtree.
func (*Backend) CreateHardware ¶ added in v0.19.0
func (*Backend) CreateWorkflow ¶ added in v0.18.0
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.
func (*Backend) ReadWorkflow ¶ added in v0.23.0
func (b *Backend) ReadWorkflow(ctx context.Context, name, namespace string) (*v1alpha1.Workflow, error)
ReadWorkflow returns the Workflow as currently stored by the API server, not as cached, so the result is never stale. A Workflow outside b.Namespaces is reported as not found.
func (*Backend) RenderedHardware ¶ added in v0.26.0
func (b *Backend) RenderedHardware(_ context.Context, hw *tinkerbell.Hardware) (*tinkerbell.Hardware, error)
RenderedHardware returns the rendering of hw to serve. Without rendering, it returns hw. A Hardware with no rendering to serve is not found.
func (*Backend) RenderedReader ¶ added in v0.26.0
func (b *Backend) RenderedReader() *RenderedReader
RenderedReader returns a reader of rendered Hardware.
func (*Backend) ResolveReferences ¶ added in v0.26.0
func (b *Backend) ResolveReferences(ctx context.Context, hw *tinkerbell.Hardware) (map[string]any, error)
ResolveReferences returns the objects hw's spec.references point to, keyed by reference name. When b.Namespaces is set, a reference outside them is reported in the error without being read. Otherwise a reference is read only if the allow list matches it or the deny list does not; with no deny list configured, an implicit deny-all rule is used and can still be overridden by an allow-list match. Denied and unreadable references are omitted from the map and reported in the error; other references are still returned.
func (*Backend) Start ¶
Start starts the client-side cache and, with rendering, background rendering.
func (*Backend) UpdateHardware ¶ added in v0.23.0
func (*Backend) UpdateWorkflow ¶ added in v0.23.0
type RenderedReader ¶ added in v0.26.0
type RenderedReader struct {
// contains filtered or unexported fields
}
RenderedReader serves rendered Hardware. It only reads, so rendered Hardware cannot be written back over its templates.
func (*RenderedReader) FilterHardware ¶ added in v0.26.0
func (r *RenderedReader) FilterHardware(ctx context.Context, opts data.HardwareFilter) (*tinkerbell.Hardware, error)
FilterHardware is Backend.FilterHardware, returning the rendered Hardware.