service

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 21 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerArgs

func ContainerArgs(name string) ([]string, error)

ContainerArgs returns the CMD of the running container identified by name. Used by upgrade to preserve the original configuration flags.

func ContainerExists

func ContainerExists(name string) bool

ContainerExists reports whether the KubeSolo container for the given instance name exists. Convenience wrapper around ContainerExistsByName.

func ContainerExistsByName

func ContainerExistsByName(cname string) bool

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

func ContainerNameFor(name string) string

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

func GetContainerAPIPort(name string) (int, error)

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

func GetContainerD2KPort(name string) (int, error)

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

func ParseContainerPorts(spec string) (nat.PortSet, nat.PortMap, error)

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

func RemoveContainerVolume(name string) error

RemoveContainerVolume removes the data volume for the named instance. Called during uninstall --purge to delete all cluster state.

func ResetContainer

func ResetContainer(name string) error

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.

func New

func New(info *detect.SystemInfo, runMode, name string) (Manager, error)

New returns the appropriate Manager for the detected init system and run mode. name is the instance identifier used by the container manager as the Docker container name; it is ignored for non-container run modes.

Jump to

Keyboard shortcuts

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