nodepool

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package nodepool manages node pools and the cluster autoscaler (§6.5): provider-backed pools create servers that join with cloud-init, grow when tasks cannot be placed or capacity runs low, and shrink by draining and deleting underused nodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UserData

func UserData(controller, token, name, pin string) string

UserData is the cloud-init script a new server runs to join.

func Validate

func Validate(name, role string, provider bool, s *Spec, min, max int) error

Validate checks a pool before it is stored.

Types

type Manager

type Manager struct {

	// ControllerURL is the address new servers join through (public).
	ControllerURL func() string
	// Pin is the controller certificate's key pin while it is self-signed.
	Pin func() string
	// contains filtered or unexported fields
}

Manager runs pools.

func New

func New(st *store.Store, box *secrets.Box, reg *nodes.Registry, wl *workload.Manager, bus *events.Bus, log *slog.Logger) *Manager

func (*Manager) Draining

func (m *Manager) Draining() map[string]string

Draining lists nodes the autoscaler is removing.

func (*Manager) EdgeNodes

func (m *Manager) EdgeNodes() []nodes.View

EdgeNodes lists the nodes of edge pools (they run Traefik replicas, §8.5).

func (*Manager) JoinToken

func (m *Manager) JoinToken(ctx context.Context, poolID, nodeName string, ttl time.Duration) (string, error)

JoinToken creates a single-use token that puts a node in a pool.

func (*Manager) PoolOf

func (m *Manager) PoolOf(nodeID string) (string, string)

PoolOf names a node's pool and role (workload.Manager.NodePool).

func (*Manager) Provider

func (m *Manager) Provider(ctx context.Context, id string) (cloud.Provider, error)

Provider returns a pool provider's client.

func (*Manager) Reload

func (m *Manager) Reload(ctx context.Context) error

Reload refreshes the pool cache (after any change).

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run reconciles pools every 15 seconds until ctx ends.

func (*Manager) SealProvider

func (m *Manager) SealProvider(id string, c cloud.Config) []byte

SealProvider seals a provider configuration.

type Spec

type Spec struct {
	// Servers created by the provider.
	Region  string   `json:"region,omitempty"`
	Type    string   `json:"type,omitempty"`
	Image   string   `json:"image,omitempty"`
	SSHKeys []string `json:"sshKeys,omitempty"`
	// Capacity of one new node, for planning (cores, MiB).
	NodeCPU       float64 `json:"nodeCpu,omitempty"`
	NodeMemoryMiB int     `json:"nodeMemoryMiB,omitempty"`
	// Cluster autoscaling.
	Autoscale    bool `json:"autoscale"`
	Headroom     int  `json:"headroom,omitempty"`     // % reserved above which to add a node (default 80)
	ScaleInBelow int  `json:"scaleInBelow,omitempty"` // % reserved below which a node may go (default 40)
	ScaleInAfter int  `json:"scaleInAfter,omitempty"` // seconds below that first (default 600)
	PendingAfter int  `json:"pendingAfter,omitempty"` // seconds tasks wait unplaced before adding nodes (default 60)
	MaxStep      int  `json:"maxStep,omitempty"`      // nodes added or removed at once (default 2)
	JoinTimeout  int  `json:"joinTimeout,omitempty"`  // seconds a new server has to join (default 600)
}

Spec is a pool's settings.

Jump to

Keyboard shortcuts

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