Documentation
¶
Overview ¶
Package capi provides builders for Cluster API resources. This package uses unstructured resources to avoid tight coupling to specific CAPI provider versions while maintaining type safety through well-defined builders.
Index ¶
- Constants
- func ComponentResourceMap(cr *butlerv1alpha1.ComponentResources) map[string]interface{}
- func GetMachineSpecs(tc *butlerv1alpha1.TenantCluster) (cpu int64, memory string, disk string)
- func ResolveControlPlaneResources(tc *butlerv1alpha1.TenantCluster, butlerConfig *butlerv1alpha1.ButlerConfig) *butlerv1alpha1.ControlPlaneResourcesSpec
- type Builder
- func (b *Builder) Build() (*ResourceSet, error)
- func (b *Builder) GetOwnerReference() metav1.OwnerReference
- func (b *Builder) WithButlerConfig(bc *butlerv1alpha1.ButlerConfig) *Builder
- func (b *Builder) WithIngressIP(ip string) *Builder
- func (b *Builder) WithNutanixCredentials(username, password, caBundle string) *Builder
- type NutanixCredentials
- type ResourceSet
Constants ¶
const ( ClusterAPIGroup = "cluster.x-k8s.io" ClusterAPIVersion = "v1beta1" InfrastructureAPIGroup = "infrastructure.cluster.x-k8s.io" InfrastructureAPIVersion = "v1alpha1" ControlPlaneAPIGroup = "controlplane.cluster.x-k8s.io" ControlPlaneAPIVersion = "v1alpha1" BootstrapAPIGroup = "bootstrap.cluster.x-k8s.io" BootstrapAPIVersion = "v1beta1" )
API Group/Version constants for CAPI resources.
const ( DefaultWorkerCPU = 4 DefaultWorkerMemoryMB = 8192 // 8Gi in MB DefaultWorkerDiskGB = 40 )
Default values for machine specs when not specified in TenantCluster
Variables ¶
This section is empty.
Functions ¶
func ComponentResourceMap ¶ added in v0.10.0
func ComponentResourceMap(cr *butlerv1alpha1.ComponentResources) map[string]interface{}
ComponentResourceMap converts a ComponentResources to an unstructured map matching the StewardControlPlane's ControlPlaneComponent shape.
func GetMachineSpecs ¶ added in v0.10.0
func GetMachineSpecs(tc *butlerv1alpha1.TenantCluster) (cpu int64, memory string, disk string)
GetMachineSpecs extracts CPU, Memory, and Disk from TenantCluster spec with defaults.
func ResolveControlPlaneResources ¶ added in v0.10.0
func ResolveControlPlaneResources(tc *butlerv1alpha1.TenantCluster, butlerConfig *butlerv1alpha1.ButlerConfig) *butlerv1alpha1.ControlPlaneResourcesSpec
ResolveControlPlaneResources merges ButlerConfig defaults with TenantCluster overrides. Returns nil if no resources are configured (BestEffort QoS).
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs CAPI resources for a TenantCluster.
func NewBuilder ¶
func NewBuilder(tc *butlerv1alpha1.TenantCluster, pc *butlerv1alpha1.ProviderConfig, namespace string) *Builder
NewBuilder creates a new CAPI resource builder.
func (*Builder) Build ¶
func (b *Builder) Build() (*ResourceSet, error)
Build constructs all CAPI resources for the tenant cluster.
func (*Builder) GetOwnerReference ¶
func (b *Builder) GetOwnerReference() metav1.OwnerReference
GetOwnerReference returns an OwnerReference for the TenantCluster.
func (*Builder) WithButlerConfig ¶
func (b *Builder) WithButlerConfig(bc *butlerv1alpha1.ButlerConfig) *Builder
WithButlerConfig sets the ButlerConfig for platform-level settings. This enables reading ControlPlaneExposure for tcp-proxy auto-enablement.
func (*Builder) WithIngressIP ¶
WithIngressIP sets the external Ingress IP for TLS passthrough. This is used for Ingress/Gateway modes to configure worker /etc/hosts.
func (*Builder) WithNutanixCredentials ¶
WithNutanixCredentials sets the Nutanix credentials for CAPX secret generation. Must be called before Build() when using Nutanix provider.
type NutanixCredentials ¶
type NutanixCredentials struct {
Username string
Password string
CABundle string // PEM-encoded CA chain for Prism Central TLS verification
}
NutanixCredentials holds Nutanix Prism Central credentials.
type ResourceSet ¶
type ResourceSet struct {
Cluster *unstructured.Unstructured
InfrastructureCluster *unstructured.Unstructured
ControlPlane *unstructured.Unstructured
MachineDeployment *unstructured.Unstructured
MachineTemplate *unstructured.Unstructured
BootstrapConfigTemplate *unstructured.Unstructured
CredentialSecret *unstructured.Unstructured
}
ResourceSet contains all CAPI resources needed for a tenant cluster.
func (*ResourceSet) AllResources ¶
func (rs *ResourceSet) AllResources() []*unstructured.Unstructured
AllResources returns all resources as a slice for iteration. Order matters: credential secret must exist before NutanixCluster references it.
func (*ResourceSet) ResourcesWithoutMachineDeployment ¶ added in v0.16.1
func (rs *ResourceSet) ResourcesWithoutMachineDeployment() []*unstructured.Unstructured
ResourcesWithoutMachineDeployment returns all resources except the MachineDeployment. Used for Talos clusters where the MachineDeployment must be deferred until the bootstrap secret exists — CAPX treats a missing dataSecretName target as a terminal CreateError on the NutanixMachine, which is not retryable.
func (*ResourceSet) SetOwnerReferences ¶
func (rs *ResourceSet) SetOwnerReferences(ref metav1.OwnerReference)
SetOwnerReferences sets owner references on all resources in the set.