provider

package
v5.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package provider defines infrastructure providers for running Kubernetes cluster nodes.

Providers handle infrastructure-level operations:

  • Creating and destroying nodes (Docker containers, cloud VMs, etc.)
  • Starting and stopping nodes
  • Managing provider-specific resources (networks, volumes, port mappings)

This package is separate from the provisioner package which handles distribution-specific operations (bootstrapping K8s, configuring etcd, etc.).

Currently supported providers:

  • Docker: Runs cluster nodes as Docker containers (for Kind, K3d, Talos)

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoNodes is returned when no nodes are found for a cluster.
	ErrNoNodes = errors.New("no nodes found for cluster")

	// ErrProviderUnavailable is returned when the provider is not available.
	ErrProviderUnavailable = errors.New("provider is not available")

	// ErrUnknownLabelScheme is returned when an unknown label scheme is specified.
	ErrUnknownLabelScheme = errors.New("unknown label scheme")
)

Common errors for provider operations.

Functions

This section is empty.

Types

type MockProvider

type MockProvider struct {
	mock.Mock
}

MockProvider is a mock implementation of the Provider interface for testing.

func NewMockProvider

func NewMockProvider() *MockProvider

NewMockProvider creates a new MockProvider instance.

func (*MockProvider) DeleteNodes

func (m *MockProvider) DeleteNodes(ctx context.Context, clusterName string) error

DeleteNodes mocks deleting nodes for a cluster.

func (*MockProvider) ListAllClusters

func (m *MockProvider) ListAllClusters(ctx context.Context) ([]string, error)

ListAllClusters mocks listing all clusters.

func (*MockProvider) ListNodes

func (m *MockProvider) ListNodes(ctx context.Context, clusterName string) ([]NodeInfo, error)

ListNodes mocks listing nodes for a cluster.

func (*MockProvider) NodesExist

func (m *MockProvider) NodesExist(ctx context.Context, clusterName string) (bool, error)

NodesExist mocks checking if nodes exist.

func (*MockProvider) StartNodes

func (m *MockProvider) StartNodes(ctx context.Context, clusterName string) error

StartNodes mocks starting nodes for a cluster.

func (*MockProvider) StopNodes

func (m *MockProvider) StopNodes(ctx context.Context, clusterName string) error

StopNodes mocks stopping nodes for a cluster.

type NodeInfo

type NodeInfo struct {
	// Name is the unique identifier of the node (container name, VM ID, etc.)
	Name string

	// ClusterName is the name of the cluster this node belongs to.
	ClusterName string

	// Role is the role of the node (control-plane, worker).
	Role string

	// State is the current state of the node (running, stopped, etc.)
	State string
}

NodeInfo contains information about a node managed by a provider.

type Provider

type Provider interface {
	// StartNodes starts the nodes for a cluster.
	// If no nodes exist, returns ErrNoNodes.
	StartNodes(ctx context.Context, clusterName string) error

	// StopNodes stops the nodes for a cluster.
	// If no nodes exist, returns ErrNoNodes.
	StopNodes(ctx context.Context, clusterName string) error

	// ListNodes returns all nodes for a specific cluster.
	ListNodes(ctx context.Context, clusterName string) ([]NodeInfo, error)

	// ListAllClusters returns the names of all clusters managed by this provider.
	ListAllClusters(ctx context.Context) ([]string, error)

	// NodesExist returns true if nodes exist for the given cluster name.
	NodesExist(ctx context.Context, clusterName string) (bool, error)

	// DeleteNodes removes all nodes for a cluster.
	// Note: Most provisioners handle node deletion through their SDK,
	// so this is primarily used for cleanup scenarios.
	DeleteNodes(ctx context.Context, clusterName string) error
}

Provider defines the interface for infrastructure providers. Providers handle node-level operations independent of the Kubernetes distribution.

Directories

Path Synopsis
Package docker provides a Docker-based infrastructure provider.
Package docker provides a Docker-based infrastructure provider.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL