swarm

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DowngradeManager

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

DowngradeManager handles Swarm to single-server downgrade

func NewDowngradeManager

func NewDowngradeManager(client *ssh.Client, projectName, environment string, verbose bool) *DowngradeManager

NewDowngradeManager creates a new downgrade manager

func (*DowngradeManager) DowngradeToSingleServer

func (d *DowngradeManager) DowngradeToSingleServer() error

DowngradeToSingleServer downgrades from Swarm to single-server mode

func (*DowngradeManager) ShouldDowngrade

func (d *DowngradeManager) ShouldDowngrade(currentServers int) bool

ShouldDowngrade checks if downgrade is needed

type Manager

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

Manager handles Docker Swarm operations

func NewManager

func NewManager(cfg *config.Config, sshPool *ssh.Pool, environment string, verbose bool) *Manager

NewManager creates a new Swarm manager

func (*Manager) ClearSwarmState

func (m *Manager) ClearSwarmState() error

ClearSwarmState removes the swarm state file

func (*Manager) DeployService

func (m *Manager) DeployService(
	managerClient *ssh.Client,
	serviceName string,
	service *config.ServiceConfig,
	imageRef string,
	networkName string,
	traefikLabels []string,
) error

DeployService deploys a service to the Docker Swarm

func (*Manager) EnsureSwarmNetwork

func (m *Manager) EnsureSwarmNetwork(managerClient *ssh.Client, networkName string) error

EnsureSwarmNetwork creates an overlay network for the environment if it doesn't exist

func (*Manager) GetJoinToken

func (m *Manager) GetJoinToken(managerClient *ssh.Client, role string) (string, error)

GetJoinToken retrieves the join token for workers

func (*Manager) GetNodeID

func (m *Manager) GetNodeID(client *ssh.Client) (string, error)

GetNodeID retrieves the node ID of the current machine

func (*Manager) GetServiceStatus

func (m *Manager) GetServiceStatus(client *ssh.Client, fullServiceName string) (string, error)

GetServiceStatus retrieves the status of a service

func (*Manager) GetSwarmNodeRole

func (m *Manager) GetSwarmNodeRole(client *ssh.Client) (string, error)

GetSwarmNodeRole returns the role of the current node (manager or worker)

func (*Manager) GetSwarmStateFile

func (m *Manager) GetSwarmStateFile() string

GetSwarmStateFile returns the path to the swarm state file

func (*Manager) InitializeSwarm

func (m *Manager) InitializeSwarm(client *ssh.Client, advertiseAddr string) error

InitializeSwarm initializes Docker Swarm on the manager node

func (*Manager) IsSwarmInitialized

func (m *Manager) IsSwarmInitialized(client *ssh.Client) (bool, error)

IsSwarmInitialized checks if Docker Swarm is already initialized on a node

func (*Manager) JoinSwarm

func (m *Manager) JoinSwarm(workerClient *ssh.Client, managerAddr string, token string) error

JoinSwarm joins a worker node to the swarm

func (*Manager) LeaveSwarm

func (m *Manager) LeaveSwarm(client *ssh.Client, force bool) error

LeaveSwarm removes a node from the swarm

func (*Manager) ListNodes

func (m *Manager) ListNodes(managerClient *ssh.Client) (string, error)

ListNodes lists all nodes in the swarm

func (*Manager) LoadSwarmState

func (m *Manager) LoadSwarmState() (*SwarmState, error)

LoadSwarmState loads and decrypts the swarm state from disk

func (*Manager) RemoveService

func (m *Manager) RemoveService(client *ssh.Client, fullServiceName string) error

RemoveService removes a service from the swarm

func (*Manager) SaveSwarmState

func (m *Manager) SaveSwarmState(state *SwarmState) error

SaveSwarmState saves the swarm state to disk with encryption Swarm tokens are sensitive and should always be encrypted

func (*Manager) ScaleService

func (m *Manager) ScaleService(client *ssh.Client, fullServiceName string, replicas int) error

ScaleService scales a service to the specified number of replicas

func (*Manager) SetNodeLabels

func (m *Manager) SetNodeLabels(managerClient *ssh.Client, nodeID string, labels map[string]string) error

SetNodeLabels sets labels on a swarm node

type SwarmState

type SwarmState struct {
	Initialized  bool              `json:"initialized"`
	ManagerHost  string            `json:"manager_host"`
	WorkerToken  string            `json:"worker_token"`
	ManagerToken string            `json:"manager_token"`
	Nodes        map[string]string `json:"nodes"` // hostname -> node_id
	RegistryHost string            `json:"registry_host"`
	RegistryPort int               `json:"registry_port"`
	LastUpdated  string            `json:"last_updated"`
}

SwarmState holds the state of the Docker Swarm

Jump to

Keyboard shortcuts

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