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) IP() netip.Addr
- func (m *Machine) InitCluster(ctx context.Context, req *pb.InitClusterRequest) (*pb.InitClusterResponse, error)
- func (m *Machine) Initialised() bool
- func (m *Machine) Inspect(_ context.Context, _ *emptypb.Empty) (*pb.MachineInfo, error)
- func (m *Machine) InspectService(ctx context.Context, req *pb.InspectServiceRequest) (*pb.InspectServiceResponse, error)
- func (m *Machine) IsNetworkReady() bool
- func (m *Machine) JoinCluster(_ context.Context, req *pb.JoinClusterRequest) (*emptypb.Empty, 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) WaitForNetworkReady(ctx context.Context) error
- type State
- type Token
Constants ¶
const ( DefaultMachineSockPath = "/run/uncloud/machine.sock" DefaultUncloudSockPath = "/run/uncloud/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" )
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
MachineSockPath string
UncloudSockPath string
CorrosionDir 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
// 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) 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) 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) 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) 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) 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 is ready to serve requests on the local API server.
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
// 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.