provisioner

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const Shebang = `#! /usr/bin/env bash
set -xe
`

Variables

This section is empty.

Functions

func BuildComponentsStatus added in v0.3.0

func BuildComponentsStatus(env v1alpha1.Environment) *v1alpha1.ComponentsStatus

BuildComponentsStatus creates a ComponentsStatus from the environment spec. This captures what was requested for provisioning (source, version, git refs) so the CLI can display provenance information.

func Dryrun

func Dryrun(log *logger.FunLogger, env v1alpha1.Environment) error

Dryrun validates the environment configuration without making changes.

func NewDirectTransport added in v0.3.0

func NewDirectTransport(host string) *sshutil.DirectTransport

NewDirectTransport returns a DirectTransport that dials host; ":22" is appended only when host has no port (sshutil handles host:port targets, which the old provisioner-local implementation could not).

Types

type ClusterHealth added in v0.3.0

type ClusterHealth struct {
	Healthy         bool
	TotalNodes      int
	ReadyNodes      int
	ControlPlanes   int
	Workers         int
	APIServerStatus string
	Nodes           []NodeHealth
	Message         string
}

ClusterHealth represents the health status of a multinode cluster

func GetClusterHealthFromEnv added in v0.3.0

func GetClusterHealthFromEnv(log *logger.FunLogger, env *v1alpha1.Environment) (*ClusterHealth, error)

GetClusterHealthFromEnv gets cluster health using environment configuration

type ClusterProvisioner added in v0.3.0

type ClusterProvisioner struct {

	// SSH credentials
	KeyPath  string
	UserName string

	// Cluster information
	Environment *v1alpha1.Environment

	// JoinToken is generated after kubeadm init and used by joining nodes
	JoinToken string
	// CertificateKey is used for control-plane joins in HA mode
	CertificateKey string
	// ControlPlaneEndpoint is the API server endpoint (LB DNS or first CP IP)
	ControlPlaneEndpoint string
	// CACertHash is the CA certificate hash for secure joins
	CACertHash string
	// contains filtered or unexported fields
}

ClusterProvisioner handles provisioning of multinode Kubernetes clusters

func NewClusterProvisioner added in v0.3.0

func NewClusterProvisioner(log *logger.FunLogger, keyPath, userName string, env *v1alpha1.Environment) *ClusterProvisioner

NewClusterProvisioner creates a new cluster provisioner

func (*ClusterProvisioner) GetClusterHealth added in v0.3.0

func (cp *ClusterProvisioner) GetClusterHealth(firstCPHost string) (*ClusterHealth, error)

GetClusterHealth checks the health of a multinode cluster by querying the first control-plane. firstCPHost is the SSH-reachable address — PublicIP for direct SSH, PrivateIP for SSM transport.

func (*ClusterProvisioner) ProvisionCluster added in v0.3.0

func (cp *ClusterProvisioner) ProvisionCluster(nodes []NodeInfo) error

ProvisionCluster provisions a multinode Kubernetes cluster It follows the order: init first CP → join additional CPs → join workers

type DependencyConfigurator added in v0.2.0

type DependencyConfigurator interface {
	Resolve() []ProvisionFunc
	// contains filtered or unexported methods
}

DependencyConfigurator defines methods for configuring dependencies

type DependencyResolver added in v0.2.0

type DependencyResolver struct {
	Dependencies []ProvisionFunc
	// contains filtered or unexported fields
}

DependencySolver is a struct that holds the dependency list

func NewDependencies added in v0.2.0

func NewDependencies(env *v1alpha1.Environment) *DependencyResolver

NewDependencies creates a new DependencyResolver for the given environment.

func (*DependencyResolver) Resolve added in v0.2.0

func (d *DependencyResolver) Resolve() []ProvisionFunc

Resolve returns the dependency list in the correct order

func (*DependencyResolver) SetBaseDir added in v0.3.0

func (d *DependencyResolver) SetBaseDir(dir string)

SetBaseDir sets the base directory for resolving relative file paths in custom templates.

type DirectTransport added in v0.3.0

type DirectTransport = sshutil.DirectTransport

DirectTransport aliases sshutil.DirectTransport (direct TCP to host:22).

type NodeHealth added in v0.3.0

type NodeHealth struct {
	Name       string
	Role       string
	Ready      bool
	Status     string
	Version    string
	InternalIP string
}

NodeHealth represents the health status of a single node

type NodeInfo added in v0.3.0

type NodeInfo struct {
	Name        string
	PublicIP    string
	PrivateIP   string
	Role        string    // "control-plane" or "worker"
	SSHUsername string    // SSH username for this node (optional, falls back to ClusterProvisioner.UserName)
	InstanceID  string    // EC2 instance ID (used by SSMTransport for private-subnet nodes)
	Transport   Transport // Transport controls how SSH connections are established; nil falls back to DirectTransport
}

NodeInfo represents a node to be provisioned

type Option added in v0.3.0

type Option func(*Provisioner)

Option is a functional option for configuring a Provisioner.

func WithSSHConfig added in v0.4.0

func WithSSHConfig(cfg *v1alpha1.SSHConfig) Option

WithSSHConfig supplies advanced SSH settings (bastion hop, agent auth, host-key policy, timeouts, retries). A nil cfg preserves the historical direct-dial envelope: 20 attempts x 1s, 15s handshake, 30s keepalive.

func WithTransport added in v0.3.0

func WithTransport(t Transport) Option

WithTransport sets the transport used for SSH connections. If not provided, the Provisioner defaults to DirectTransport(hostUrl).

type ProvisionFunc

type ProvisionFunc func(tpl *bytes.Buffer, env v1alpha1.Environment) error

type Provisioner

type Provisioner struct {
	Client         *ssh.Client
	SessionManager *ssm.Client

	HostUrl  string
	UserName string
	KeyPath  string
	// contains filtered or unexported fields
}

func New

func New(log *logger.FunLogger, keyPath, userName, hostUrl string, opts ...Option) (*Provisioner, error)

func (*Provisioner) Close added in v0.4.0

func (p *Provisioner) Close() error

Close tears down the resources the provisioner owns: the SSH client and the transport (which for SSM/bastion holds an OS process or a hop-1 SSH client). It is idempotent and safe on a partially-constructed Provisioner. The Dialer never closes the transport — that lifecycle belongs to the caller, i.e. here.

func (*Provisioner) Run

Run provisions the environment and returns component provenance status. The returned ComponentsStatus captures source/version/commit information for each installed component.

type SSMTransport added in v0.3.0

type SSMTransport struct {
	InstanceID string
	Region     string
	Profile    string
	// contains filtered or unexported fields
}

SSMTransport establishes SSH connections through AWS Systems Manager (SSM) port forwarding. This is used for cluster nodes in private subnets that do not have public IP addresses.

Known limitation (D2): There is a TOCTOU race between finding a free port and starting the SSM session. If the port is taken between these two operations, Dial() will fail with "connection refused" after SSM started. The caller should retry with a new SSMTransport instance if this occurs.

func (*SSMTransport) Close added in v0.3.0

func (s *SSMTransport) Close() error

Close terminates the SSM port-forwarding session.

func (*SSMTransport) DialContext added in v0.4.0

func (s *SSMTransport) DialContext(ctx context.Context) (net.Conn, error)

DialContext starts an SSM port-forwarding session and connects to the local tunnel endpoint. Uses retry-based dial with exponential backoff (D1) instead of a fixed sleep. Idempotent: if a previous session exists, it is closed before starting a new one. ctx bounds both the aws process (exec.CommandContext) and the local tunnel dial.

func (*SSMTransport) Target added in v0.3.0

func (s *SSMTransport) Target() string

Target returns the EC2 instance ID.

type Transport added in v0.3.0

type Transport = sshutil.Transport

Transport is the SSH connection transport, now owned by pkg/sshutil. The alias keeps the provisioner package's public surface stable while the single canonical Transport interface (DialContext/Target/Close) lives in sshutil.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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