Documentation
¶
Index ¶
- Constants
- func NewProvider(i spi.SessionProviderInterface) driver.Driver
- type Provider
- func (p *Provider) CreateMachine(ctx context.Context, req *driver.CreateMachineRequest) (*driver.CreateMachineResponse, error)
- func (p *Provider) DeleteMachine(ctx context.Context, req *driver.DeleteMachineRequest) (*driver.DeleteMachineResponse, error)
- func (p *Provider) GenerateMachineClassForMigration(_ context.Context, req *driver.GenerateMachineClassForMigrationRequest) (*driver.GenerateMachineClassForMigrationResponse, error)
- func (p *Provider) GetMachineStatus(ctx context.Context, req *driver.GetMachineStatusRequest) (*driver.GetMachineStatusResponse, error)
- func (p *Provider) GetVolumeIDs(_ context.Context, req *driver.GetVolumeIDsRequest) (*driver.GetVolumeIDsResponse, error)
- func (p *Provider) InitializeMachine(context.Context, *driver.InitializeMachineRequest) (*driver.InitializeMachineResponse, error)
- func (p *Provider) ListMachines(ctx context.Context, req *driver.ListMachinesRequest) (*driver.ListMachinesResponse, error)
- func (p *Provider) WaitUntilServerDeleted(ctx context.Context, projectID, region, serverID string) error
- func (p *Provider) WaitUntilServerRunning(ctx context.Context, projectID, region, serverID string) error
Constants ¶
const ( StackitProviderName = "stackit" StackitMachineLabel = "kubernetes.io/machine" StackitMachineClassLabel = "kubernetes.io/machineclass" )
Variables ¶
This section is empty.
Functions ¶
func NewProvider ¶
func NewProvider(i spi.SessionProviderInterface) driver.Driver
NewProvider returns an empty provider object
Types ¶
type Provider ¶
type Provider struct {
SPI spi.SessionProviderInterface
// contains filtered or unexported fields
}
Provider is the struct that implements the driver interface It is used to implement the basic driver functionalities
Architecture: Single-tenant design - Each provider instance is deployed per Gardener shoot (cluster) - The STACKIT IaaS client is initialized lazily on first request using credentials from the Secret - All subsequent requests reuse the same client (SDK handles token refresh automatically) - Credential rotation requires pod restart (standard Kubernetes pattern)
func (*Provider) CreateMachine ¶
func (p *Provider) CreateMachine(ctx context.Context, req *driver.CreateMachineRequest) (*driver.CreateMachineResponse, error)
CreateMachine handles a machine creation request by creating a STACKIT server
This method creates a new server in STACKIT infrastructure based on the ProviderSpec configuration in the MachineClass. It assigns MCM-specific labels to the server for tracking and orphan VM detection.
Returns:
- ProviderID: Unique identifier in format "stackit://<projectId>/<serverId>"
- NodeName: Name that the VM will register with in Kubernetes (matches Machine name)
- Addresses: Internal IP addresses of the server's NICs (NodeInternalIP)
Error codes (see machine_error_codes.md for retry semantics):
- InvalidArgument (no retry): Invalid ProviderSpec fields or missing required values
- Internal (no retry): Malformed ProviderSpec JSON or failed to initialize STACKIT client
- Unavailable (retry): Transient API failure (create/get server, get NICs, patch NIC)
- ResourceExhausted (no retry): No capacity available (e.g. "no valid host was found")
- DeadlineExceeded (retry): Server did not reach ACTIVE state within the polling timeout
func (*Provider) DeleteMachine ¶
func (p *Provider) DeleteMachine(ctx context.Context, req *driver.DeleteMachineRequest) (*driver.DeleteMachineResponse, error)
DeleteMachine handles a machine deletion request by deleting the STACKIT server
This method deletes the server identified by the ProviderID from STACKIT infrastructure. It is idempotent - if the server is already deleted (404), it returns success.
Error codes:
- InvalidArgument: Missing or invalid ProviderID
- Internal: Failed to delete server or communicate with STACKIT API
func (*Provider) GenerateMachineClassForMigration ¶
func (p *Provider) GenerateMachineClassForMigration(_ context.Context, req *driver.GenerateMachineClassForMigrationRequest) (*driver.GenerateMachineClassForMigrationResponse, error)
GenerateMachineClassForMigration generates a MachineClass for migration purposes
This method is used to migrate from provider-specific MachineClass CRDs (e.g., AWSMachineClass) to the generic MachineClass format.
STACKIT provider does not have a legacy provider-specific MachineClass format, so this method is not needed and returns Unimplemented.
Returns:
- Unimplemented: No migration required for STACKIT provider
func (*Provider) GetMachineStatus ¶
func (p *Provider) GetMachineStatus(ctx context.Context, req *driver.GetMachineStatusRequest) (*driver.GetMachineStatusResponse, error)
GetMachineStatus retrieves the current status of a STACKIT server
This method queries STACKIT API to get the current state of the server identified by the Machine's ProviderID. If the ProviderID is empty (machine not created yet) or the server doesn't exist, it returns NotFound error.
Returns:
- ProviderID: The machine's ProviderID
- NodeName: Name that the VM registered with in Kubernetes
Error codes:
- NotFound: Machine has no ProviderID yet, or server not found in STACKIT
- InvalidArgument: Invalid ProviderID format
- Internal: Failed to get server status or communicate with STACKIT API
func (*Provider) GetVolumeIDs ¶
func (p *Provider) GetVolumeIDs(_ context.Context, req *driver.GetVolumeIDsRequest) (*driver.GetVolumeIDsResponse, error)
GetVolumeIDs extracts volume IDs from PersistentVolume specs
This method is used by MCM to get volume IDs for persistent volumes. Currently unimplemented for STACKIT provider - volumes are managed directly through the ProviderSpec (bootVolume and volumes fields).
Returns:
- Unimplemented: This functionality is not required for STACKIT provider
func (*Provider) InitializeMachine ¶
func (p *Provider) InitializeMachine(context.Context, *driver.InitializeMachineRequest) (*driver.InitializeMachineResponse, error)
InitializeMachine handles VM initialization for STACKIT VM's. Currently, un-implemented.
func (*Provider) ListMachines ¶
func (p *Provider) ListMachines(ctx context.Context, req *driver.ListMachinesRequest) (*driver.ListMachinesResponse, error)
ListMachines lists all STACKIT servers that belong to the specified MachineClass
This method retrieves all servers in the STACKIT project and filters them based on the "kubernetes.io/machineclass" label. This enables the MCM safety controller to detect and clean up orphan VMs that are not backed by Machine CRs.
Returns:
- MachineList: Map of ProviderID to MachineName for all servers matching the MachineClass
Error codes:
- Internal: Failed to list servers or communicate with STACKIT API