Documentation
¶
Overview ¶
Package service provides an init-system-agnostic interface for installing, enabling, and controlling the KubeSolo system service.
Each init system (systemd, OpenRC, SysV, s6, runit, upstart) is implemented as a separate type that satisfies the Manager interface. The Daemon and Foreground runners implement the non-service run modes.
Index ¶
- func ContainerArgs(name string) ([]string, error)
- func ContainerExists(name string) bool
- func ContainerExistsByName(cname string) bool
- func ContainerNameFor(name string) string
- func GetContainerAPIPort(name string) (int, error)
- func GetContainerD2KPort(name string) (int, error)
- func ParseContainerPorts(spec string) (nat.PortSet, nat.PortMap, error)
- func RemoveContainerVolume(name string) error
- func ResetContainer(name string) error
- type Manager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainerArgs ¶
ContainerArgs returns the CMD of the running container identified by name. Used by upgrade to preserve the original configuration flags.
func ContainerExists ¶
ContainerExists reports whether the KubeSolo container for the given instance name exists. Convenience wrapper around ContainerExistsByName.
func ContainerExistsByName ¶
ContainerExistsByName reports whether a container with the given name exists (running or stopped). It returns false — never an error — when the container engine is unreachable or no such container exists, so callers can use it to detect container run mode on any host without a hard dependency on a reachable engine (a host-service install on a box with no engine simply reports false).
func ContainerNameFor ¶
ContainerNameFor returns the Docker container name for a given instance name. The default name ("kubesolo") is used as-is; any other name is prefixed with "kubesolo-" to namespace it away from unrelated Docker workloads.
func GetContainerAPIPort ¶
GetContainerAPIPort returns the host port Docker mapped to the container's API server (6443/tcp). Call this after Install to discover the random port.
func GetContainerD2KPort ¶
GetContainerD2KPort returns the host port Docker mapped to the container's D2K endpoint (2376/tcp). Returns an error if D2K was not enabled on this instance (port not published), guiding the user to reinstall with --d2k.
func ParseContainerPorts ¶
ParseContainerPorts turns a --container-ports value into the exposed-port set and host port bindings to publish on the KubeSolo container.
The value is a comma-separated list of entries. Each entry is one of:
9001 bare port → host 9001 : container 9001 9000-9100 range → host range : same container range (1:1) 8080:80 explicit → host 8080 : container 80 127.0.0.1:80:80 bound IP → only that host IP 53/udp protocol → tcp is assumed when omitted
Bare ports and ranges map host==container (the common case for exposing a workload, like Kind's extraPortMappings). Explicit host:container and ip:host:container forms are passed through to Docker's standard parser.
func RemoveContainerVolume ¶
RemoveContainerVolume removes the data volume for the named instance. Called during uninstall --purge to delete all cluster state.
func ResetContainer ¶
ResetContainer wipes cluster state and starts fresh: it captures the existing container's image and CMD, removes the container and data volume, then re-creates the container with the same configuration.
Types ¶
type Manager ¶
type Manager interface {
// Install writes service files and configures the service to start on boot.
Install(cfg *config.Config, cmdArgs []string) error
// Uninstall removes service files and disables the service.
Uninstall() error
}
Manager is the interface every service backend must implement.