node

package
v1.12.1-0...-676f45f Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidUnlockKey is returned when we can't decrypt the TLS certificate
	ErrInvalidUnlockKey = errors.New("node is locked, and needs a valid unlock key")

	// ErrMandatoryFIPS is returned when the cluster we are joining mandates FIPS, but we are running in non-FIPS mode
	ErrMandatoryFIPS = errors.New("node is not FIPS-enabled but cluster requires FIPS")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Hostname is the name of host for agent instance.
	Hostname string

	// JoinAddr specifies node that should be used for the initial connection to
	// other manager in cluster. This should be only one address and optional,
	// the actual remotes come from the stored state.
	JoinAddr string

	// StateDir specifies the directory the node uses to keep the state of the
	// remote managers and certificates.
	StateDir string

	// JoinToken is the token to be used on the first certificate request.
	JoinToken string

	// ExternalCAs is a list of CAs to which a manager node
	// will make certificate signing requests for node certificates.
	ExternalCAs []*api.ExternalCA

	// ForceNewCluster creates a new cluster from current raft state.
	ForceNewCluster bool

	// ListenControlAPI specifies address the control API should listen on.
	ListenControlAPI string

	// ListenRemoteAPI specifies the address for the remote API that agents
	// and raft members connect to.
	ListenRemoteAPI string

	// AdvertiseRemoteAPI specifies the address that should be advertised
	// for connections to the remote API (including the raft service).
	AdvertiseRemoteAPI string

	// NetworkConfig stores network related config for the cluster
	NetworkConfig *cnmallocator.NetworkConfig

	// Executor specifies the executor to use for the agent.
	Executor exec.Executor

	// ElectionTick defines the amount of ticks needed without
	// leader to trigger a new election
	ElectionTick uint32

	// HeartbeatTick defines the amount of ticks between each
	// heartbeat sent to other members for health-check purposes
	HeartbeatTick uint32

	// AutoLockManagers determines whether or not an unlock key will be generated
	// when bootstrapping a new cluster for the first time
	AutoLockManagers bool

	// UnlockKey is the key to unlock a node - used for decrypting at rest.  This
	// only applies to nodes that have already joined a cluster.
	UnlockKey []byte

	// Availability allows a user to control the current scheduling status of a node
	Availability api.NodeSpec_Availability

	// PluginGetter provides access to docker's plugin inventory.
	PluginGetter plugingetter.PluginGetter

	// FIPS is a boolean stating whether the node is FIPS enabled
	FIPS bool
}

Config provides values for a Node.

type Node

type Node struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Node implements the primary node functionality for a member of a swarm cluster. Node handles workloads and may also run as a manager.

func New

func New(c *Config) (*Node, error)

New returns new Node instance.

func (*Node) Agent

func (n *Node) Agent() *agent.Agent

Agent returns agent instance started by node. May be nil.

func (*Node) BindRemote

func (n *Node) BindRemote(ctx context.Context, listenAddr string, advertiseAddr string) error

BindRemote starts a listener that exposes the remote API.

func (*Node) DowngradeKey

func (n *Node) DowngradeKey() error

DowngradeKey reverts the node key to older format so that it can run on older version of swarmkit

func (*Node) Err

func (n *Node) Err(ctx context.Context) error

Err returns the error that caused the node to shutdown or nil. Err blocks until the node has fully shut down.

func (*Node) IsStateDirty

func (n *Node) IsStateDirty() (bool, error)

IsStateDirty returns true if any objects have been added to raft which make the state "dirty". Currently, the existence of any object other than the default cluster or the local node implies a dirty state.

func (*Node) ListenControlSocket

func (n *Node) ListenControlSocket(ctx context.Context) <-chan *grpc.ClientConn

ListenControlSocket listens changes of a connection for managing the cluster control api

func (*Node) Manager

func (n *Node) Manager() *manager.Manager

Manager returns manager instance started by node. May be nil.

func (*Node) NodeID

func (n *Node) NodeID() string

NodeID returns current node's ID. May be empty if not set.

func (*Node) Ready

func (n *Node) Ready() <-chan struct{}

Ready returns a channel that is closed after node's initialization has completes for the first time.

func (*Node) RemoteAPIAddr

func (n *Node) RemoteAPIAddr() (string, error)

RemoteAPIAddr returns address on which remote manager api listens. Returns nil if node is not manager.

func (*Node) Remotes

func (n *Node) Remotes() []api.Peer

Remotes returns a list of known peers known to node.

func (*Node) Start

func (n *Node) Start(ctx context.Context) error

Start starts a node instance.

func (*Node) Stop

func (n *Node) Stop(ctx context.Context) error

Stop stops node execution

Jump to

Keyboard shortcuts

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