Documentation
¶
Overview ¶
Package cluster provides interfaces and implementations for managing local Kubernetes clusters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClusterNotRunning is returned when an operation requires a running cluster. ErrClusterNotRunning = errors.New("cluster is not running") // ErrClusterAlreadyRunning is returned when attempting to start an already running cluster. ErrClusterAlreadyRunning = errors.New("cluster is already running") // ErrConfigMismatch is returned when the running cluster configuration doesn't match the requested configuration. ErrConfigMismatch = errors.New("cluster configuration mismatch") // ErrDriverNotFound is returned when the specified cluster driver is not available. ErrDriverNotFound = errors.New("cluster driver not found") // ErrClusterNotReady is returned when the cluster is running but not ready for workloads. ErrClusterNotReady = errors.New("cluster is not ready") // ErrMissingDriverConfig is returned when driver-specific configuration is missing. ErrMissingDriverConfig = errors.New("driver configuration is missing") )
Functions ¶
func ListDrivers ¶
func ListDrivers() []string
ListDrivers returns a list of all registered driver names.
func RegisterDriver ¶
func RegisterDriver(name string, factory DriverFactory)
RegisterDriver registers a driver factory function with the given name. This is typically called from a driver package's init() function. Panics if a driver with the same name is already registered.
Types ¶
type DriverFactory ¶
DriverFactory is a function that creates a new cluster manager instance.
type Manager ¶
type Manager interface {
// Start starts the cluster with the given configuration.
// If the cluster is already running with matching configuration, this is a no-op.
// If the cluster is running with different configuration, it returns an error.
Start(ctx context.Context, cfg types.ClusterConfig) error
// Stop stops the running cluster gracefully.
// If the cluster is not running, this is a no-op.
Stop(ctx context.Context) error
// Destroy completely removes the cluster and all its data.
// This is a destructive operation that cannot be undone.
// If the cluster is not found, this is a no-op.
Destroy(ctx context.Context) error
// Status returns the current status of the cluster.
// Returns an error if unable to determine cluster state.
Status(ctx context.Context) (*Status, error)
}
Manager defines the interface for managing local Kubernetes clusters. Implementations are responsible for starting, stopping, and monitoring cluster lifecycle using specific backend drivers (e.g., Colima, k3d, minikube).
type State ¶
type State string
State represents the current state of a cluster.
const ( // StateStopped indicates the cluster is not running. StateStopped State = "stopped" // StateStarting indicates the cluster is starting but not yet ready. StateStarting State = "starting" // StateNotReady indicates the cluster is running but not ready to accept workloads. StateNotReady State = "not-ready" // StateReady indicates the cluster is running and ready to accept workloads. StateReady State = "ready" )
type Status ¶
type Status struct {
// State is the current state of the cluster.
State State
// Driver is the name of the cluster driver (e.g., "colima", "k3d").
Driver string
// KubernetesVersion is the version of Kubernetes running in the cluster.
KubernetesVersion string
// IPAddress is the IP address of the cluster (empty if unavailable).
IPAddress string
// KubeContext is the name of the kubeconfig context for this cluster.
KubeContext string
}
Status represents the current state of a cluster.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package auto provides an auto-detecting cluster driver that selects the appropriate driver based on the current operating system.
|
Package auto provides an auto-detecting cluster driver that selects the appropriate driver based on the current operating system. |
|
Package colima provides a cluster.Manager implementation using Colima.
|
Package colima provides a cluster.Manager implementation using Colima. |
|
Package k3d provides a cluster.Manager implementation using k3d.
|
Package k3d provides a cluster.Manager implementation using k3d. |
|
Package mock provides a mock cluster driver implementation for testing.
|
Package mock provides a mock cluster driver implementation for testing. |