Documentation
¶
Index ¶
- Constants
- func NewDB(path string) (*sqlx.DB, error)
- func StatePath(dataDir string) string
- type Config
- type Machine
- func (m *Machine) CheckPrerequisites(_ context.Context, _ *emptypb.Empty) (*pb.CheckPrerequisitesResponse, error)
- func (m *Machine) ContainerdSock() string
- func (m *Machine) IP() netip.Addr
- func (m *Machine) Info(ctx context.Context) *pb.MachineInfo
- func (m *Machine) InitCluster(ctx context.Context, req *pb.InitClusterRequest) (*pb.InitClusterResponse, error)
- func (m *Machine) Initialised() bool
- func (m *Machine) Inspect(ctx context.Context, _ *emptypb.Empty) (*pb.MachineInfo, error)deprecated
- func (m *Machine) InspectMachine(ctx context.Context, _ *emptypb.Empty) (*pb.InspectMachineResponse, error)
- func (m *Machine) InspectService(ctx context.Context, req *pb.InspectServiceRequest) (*pb.InspectServiceResponse, error)
- func (m *Machine) InspectWireGuardNetwork(_ context.Context, _ *emptypb.Empty) (*pb.InspectWireGuardNetworkResponse, error)
- func (m *Machine) IsNetworkReady() bool
- func (m *Machine) JoinCluster(_ context.Context, req *pb.JoinClusterRequest) (*emptypb.Empty, error)
- func (m *Machine) MachineLogs(req *pb.LogsRequest, stream grpc.ServerStreamingServer[pb.LogEntry]) error
- func (m *Machine) Reset(_ context.Context, _ *pb.ResetRequest) (*emptypb.Empty, error)
- func (m *Machine) Run(ctx context.Context) error
- func (m *Machine) Started() <-chan struct{}
- func (m *Machine) Token(_ context.Context, _ *emptypb.Empty) (*pb.TokenResponse, error)
- func (m *Machine) UpdateMachine(ctx context.Context, req *pb.UpdateMachineRequest) (*pb.UpdateMachineResponse, error)
- func (m *Machine) WaitForNetworkReady(ctx context.Context) error
- func (m *Machine) WaitForStoreVersion(ctx context.Context, req *pb.WaitForStoreVersionRequest) (*emptypb.Empty, error)
- type State
- type Token
Constants ¶
const ( // DefaultMachineAPISockPath is the default path to the Unix socket for API requests handled directly by this // machine. DefaultMachineAPISockPath = "/run/uncloud/machine.sock" // DefaultClusterAPISockPath is the default path to the Unix socket for the client-facing API that routes requests // across the cluster. DefaultClusterAPISockPath = "/run/uncloud/api/uncloud.sock" DefaultSockGroup = "uncloud" // DefaultCaddyAdminSockPath is the default path to the Caddy admin socket for validating the generated Caddy // reverse proxy configuration. DefaultCaddyAdminSockPath = "/run/uncloud/caddy/admin.sock" // DefaultCorrosionRunDir is the default runtime directory for the Corrosion service. DefaultCorrosionRunDir = "/run/uncloud/corrosion" )
const ( DefaultDataDir = "/var/lib/uncloud" StateFileName = "machine.json" )
const DBFileName = "machine.db"
const (
TokenPrefix = "mtkn:"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// DataDir is the directory where the machine stores its persistent state. Default is /var/lib/uncloud.
DataDir string
// MachineAPISockPath is the path to the Unix socket for API requests handled directly by this machine.
MachineAPISockPath string
// ClusterAPISockPath is the path to the Unix socket for the client-facing API that routes requests across the
// cluster.
ClusterAPISockPath string
// ClusterAPIListener is an optional pre-bound listener for the client-facing API that routes requests across the
// cluster. If set, Run takes ownership of it and closes it on shutdown or startup failure.
ClusterAPIListener net.Listener
CorrosionDataDir string
// CorrosionRunDir is the runtime directory for the corrosion service.
CorrosionRunDir string
CorrosionAPIListenAddr netip.AddrPort
CorrosionAPIAddr netip.AddrPort
CorrosionAdminSockPath string
CorrosionService corroservice.Service
// CorrosionUser sets the Linux user for running the corrosion service.
CorrosionUser string
// DockerClient manages system and user containers using the local Docker daemon.
DockerClient *client.Client
// ContainerdSockPath is the path to the containerd.sock used by Docker.
ContainerdSockPath string
// CaddyConfigDir specifies the directory where the machine generates the Caddy reverse proxy configuration file
// for routing external traffic to service containers across the internal network. Default is DataDir/caddy.
CaddyConfigDir string
// DNSUpstreams specifies the upstream DNS servers for the embedded internal DNS server.
DNSUpstreams []netip.AddrPort
}
func (*Config) SetDefaults ¶
SetDefaults returns a new Config with default values set where not provided.
type Machine ¶
type Machine struct {
pb.UnimplementedMachineServer
// contains filtered or unexported fields
}
func NewMachine ¶
func (*Machine) CheckPrerequisites ¶ added in v0.7.0
func (m *Machine) CheckPrerequisites(_ context.Context, _ *emptypb.Empty) (*pb.CheckPrerequisitesResponse, error)
CheckPrerequisites verifies if the machine meets all necessary system requirements to participate in the cluster.
func (*Machine) ContainerdSock ¶ added in v0.19.0
ContainerdSock returns the path to the containerd socket used by Docker, auto-discovering it from well-known locations if it's not explicitly configured. Returns an empty string if the socket cannot be detected.
func (*Machine) IP ¶ added in v0.7.0
IP returns the machine IPv4 address in the cluster network which is the first address in the machine subnet.
func (*Machine) Info ¶ added in v0.20.0
func (m *Machine) Info(ctx context.Context) *pb.MachineInfo
Info returns the machine configuration and runtime details.
func (*Machine) InitCluster ¶
func (m *Machine) InitCluster(ctx context.Context, req *pb.InitClusterRequest) (*pb.InitClusterResponse, error)
InitCluster initialises a new cluster on the local machine with the provided network configuration.
func (*Machine) Initialised ¶
Initialised returns true if the machine has been configured as a member of a cluster, either by initialising a new cluster on it or joining an existing one.
func (*Machine) InspectMachine ¶ added in v0.16.0
func (*Machine) InspectService ¶
func (m *Machine) InspectService( ctx context.Context, req *pb.InspectServiceRequest, ) (*pb.InspectServiceResponse, error)
InspectService returns detailed information about a service and its containers stored in the cluster store.
func (*Machine) InspectWireGuardNetwork ¶ added in v0.16.0
func (m *Machine) InspectWireGuardNetwork( _ context.Context, _ *emptypb.Empty, ) (*pb.InspectWireGuardNetworkResponse, error)
InspectWireGuardNetwork retrieves the current WireGuard network configuration and peer status.
func (*Machine) IsNetworkReady ¶ added in v0.10.0
IsNetworkReady returns true if the Docker network is ready for containers.
func (*Machine) JoinCluster ¶
func (m *Machine) JoinCluster(_ context.Context, req *pb.JoinClusterRequest) (*emptypb.Empty, error)
JoinCluster configures the local machine to join an existing cluster.
func (*Machine) MachineLogs ¶ added in v0.18.0
func (m *Machine) MachineLogs( req *pb.LogsRequest, stream grpc.ServerStreamingServer[pb.LogEntry], ) error
MachineLogs streams logs from a system service.
func (*Machine) Reset ¶ added in v0.9.0
Reset restores the machine to a clean state, scheduling a graceful shutdown and removing all cluster-related configuration and resource. The uncloud daemon will restart the machine if managed by systemd.
func (*Machine) Started ¶
func (m *Machine) Started() <-chan struct{}
Started returns a channel that is closed when the machine and cluster API servers are ready to serve requests.
func (*Machine) Token ¶
Token returns the local machine's token that can be used for adding the machine to a cluster.
func (*Machine) UpdateMachine ¶ added in v0.20.0
func (m *Machine) UpdateMachine(ctx context.Context, req *pb.UpdateMachineRequest) (*pb.UpdateMachineResponse, error)
UpdateMachine updates the configuration of this machine in its local state (the source of truth) and syncs the result to the cluster store.
func (*Machine) WaitForNetworkReady ¶ added in v0.10.0
WaitForNetworkReady waits for the Docker network to be ready for containers. It returns nil when the network is ready or an error if the context is cancelled.
func (*Machine) WaitForStoreVersion ¶ added in v0.21.0
type State ¶
type State struct {
// ID uniquely identifies this machine in the cluster.
ID string
// Name provides a human-readable identifier for the machine.
Name string
// Network specifies the network configuration for this machine.
Network *network.Config
// PublicIP is this machine's advertised public IP for ingress. Zero value if unset.
PublicIP netip.Addr `json:",omitempty"`
// MinStoreVersion is the cluster store version this machine must reach before participating.
// Per-actor vector (Corrosion actor UUID → max processed db_version) captured from an existing
// member at join time. Cleared once reached.
MinStoreVersion api.StoreVersion `json:",omitempty"`
// CorrosionAPIToken authenticates requests to the local Corrosion API.
CorrosionAPIToken secret.Secret `json:",omitempty"`
// contains filtered or unexported fields
}
State defines the machine-specific configuration within a cluster. It encapsulates essential identifiers and settings required to establish an overlay network and operate as a member of a cluster.
func ParseState ¶
ParseState reads and decodes a state from the file at the given path.
Directories
¶
| Path | Synopsis |
|---|---|
|
api
|
|
|
Package caddystorage implements the machine-local Caddy storage API.
|
Package caddystorage implements the machine-local Caddy storage API. |
|
Package corromigrate handles the one-time migration of the on-disk Corrosion store from systemd-managed v0.x to v1.0.0 running in a uncloudd-managed container.
|
Package corromigrate handles the one-time migration of the on-disk Corrosion store from systemd-managed v0.x to v1.0.0 running in a uncloudd-managed container. |
|
Package osinfo collects the host operating system information.
|
Package osinfo collects the host operating system information. |