cluster

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClusterImagesVolumePrefix = "cluster-images"
	ClusterImagesMountPath    = "/var/lib/cluster-images"
)

Variables

View Source
var (
	ErrImageInspect          = errors.New("inspecting node image")
	ErrKubeadmVersionUnknown = errors.New("cannot determine kubeadm version")
)

Functions

func ClusterImagesVolumeName

func ClusterImagesVolumeName(kubeadmVersion string) string

ClusterImagesVolumeName returns the versioned volume name for a given kubeadm version.

func GetKubeadmVersionFromImage

func GetKubeadmVersionFromImage(ctx context.Context, podmanClient PodmanClient, nodeImage string) (string, error)

GetKubeadmVersionFromImage inspects the node image and returns the kubeadm version from its label.

func PopulatorContainerName

func PopulatorContainerName(kubeadmVersion string) string

PopulatorContainerName returns the populator container name scoped to a kubeadm version.

Types

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

Cluster represents a Kubernetes cluster

func New

func New(cfg Config) *Cluster

New creates a new Cluster

func (*Cluster) EnsureImagesVolume

func (c *Cluster) EnsureImagesVolume(ctx context.Context, nodeImage string) (string, error)

EnsureImagesVolume creates and populates a versioned cluster-images volume. It inspects the node image for its kubeadm version and creates a volume named cluster-images-<version>. Returns the volume name.

func (*Cluster) GetNodeClusterIP

func (c *Cluster) GetNodeClusterIP(nodeName string) string

GetNodeClusterIP returns the cluster IP for a node

func (*Cluster) Init

func (c *Cluster) Init(ctx context.Context, opts InitOptions) error

Init initializes a Kubernetes cluster on the control plane node

func (*Cluster) Join

func (c *Cluster) Join(ctx context.Context, opts JoinOptions) error

Join joins a node to the cluster

func (*Cluster) WaitForCloudInit

func (c *Cluster) WaitForCloudInit(ctx context.Context, nodeName string, timeout time.Duration) error

WaitForCloudInit waits for cloud-init to complete on a node

type Config

type Config struct {
	Name                 string // Cluster name (default: "bink")
	ControlPlane         string // Control plane node name (default: "node1")
	HostNetworkPopulator bool   // Use host networking for the image populator container
	Logger               *logrus.Logger
	PodmanClient         PodmanClient
}

Config holds cluster configuration

type InitOptions

type InitOptions struct {
	NodeName string
	Timeout  time.Duration
}

InitOptions holds options for cluster initialization

type JoinOptions

type JoinOptions struct {
	NodeName       string
	ControlPlane   string
	IsControlPlane bool
	NodeClusterIP  string
	Timeout        time.Duration
	Labels         map[string]string
}

JoinOptions holds options for joining a node to the cluster

type PodmanClient

type PodmanClient interface {
	EnsureImage(ctx context.Context, image string) error
	ImageInspectLabels(ctx context.Context, name string) (map[string]string, error)
	VolumeExists(ctx context.Context, name string) (bool, error)
	VolumeCreate(ctx context.Context, name string, labels map[string]string) error
	ContainerCreate(ctx context.Context, opts *podman.ContainerCreateOptions) (string, error)
	ContainerExists(ctx context.Context, name string) (bool, error)
	ContainerRemove(ctx context.Context, name string, force bool) error
	ContainerCopyContent(ctx context.Context, content []byte, containerName, destPath string, mode int64) error
	ContainerExec(ctx context.Context, name string, cmd []string) (string, error)
	ContainerExecQuiet(ctx context.Context, name string, cmd []string) error
	ContainerRunQuiet(ctx context.Context, image string, cmd []string, volumeMounts []string) error
	ContainerWait(ctx context.Context, name string) (int64, error)
	GetPublishedPort(ctx context.Context, containerName, containerPort string) (int, error)
}

Jump to

Keyboard shortcuts

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