Documentation
¶
Index ¶
Constants ¶
const ( DefaultVersion = "v1.3.0" DefaultPath = "/var/lib/kubesolo" DefaultInstallPath = "/usr/local/bin/kubesolo" DefaultRunMode = RunModeService AppName = "kubesolo" PIDFile = "/var/run/kubesolo.pid" LogFile = "/var/log/kubesolo.log" // CNIConfigFile is the CNI configuration KubeSolo drops into the standard CNI // directory, as a symlink when it runs its own containerd and as a regular file // when it attaches to a host-managed runtime. Mirrors // types.DefaultStandardCNIConfDir + types.DefaultCNIConfigName in the kubesolo // binary, the same way DefaultPath mirrors its --path default. CNIConfigFile = "/etc/cni/net.d/10-bridge.conflist" // CPUManagerPolicyNone is the default kubelet CPU manager policy, in which every // pod shares all CPUs. Mirrors types.CPUManagerPolicyNone in the kubesolo binary. CPUManagerPolicyNone = "none" // MinConfigFileVersion is the first KubeSolo release whose binary understands // --config. Older binaries are installed with the full flag list instead: // passing them --config would abort the service on every start. MinConfigFileVersion = "v1.2.1" // MinD2KVersion is the first KubeSolo release whose binary understands the // --d2k / --d2k-namespace flags (d2k integration landed after v1.1.5). // The installer refuses to pass --d2k to an older binary, which would crash-loop. MinD2KVersion = "v1.1.8" RunModeService = "service" RunModeDaemon = "daemon" RunModeForeground = "foreground" RunModeContainer = "container" // KubeSolo runs inside a container (macOS, Windows WSL2, or Linux with a container engine) // DefaultContainerImage is the container image used in container run mode. DefaultContainerImage = "portainer/kubesolo" )
const ContainerConfigFile = types.DefaultConfigFile
ContainerConfigFile is where a KubeSolo container reads its configuration: a volume of its own, so that a reset, which wipes the data volume, keeps the settings, as a reset of a host install keeps /etc/kubesolo.
Variables ¶
var ContainerIgnored = []string{
"path",
"network.nodeIP",
"network.mtu",
"network.loadBalancer.ip",
"runtime.endpoint",
"runtime.containerMode",
"kubernetes.nodeName",
"kubernetes.kubelet.cpuManager.policy",
"kubernetes.kubelet.cpuManager.policyOptions",
"kubernetes.kubelet.cpuManager.reservedCPUs",
"api.enabled",
"api.socketPath",
"kubernetes.apiServer.port",
"d2k.port",
}
ContainerIgnored lists the KubeSolo settings that mean nothing inside a container, because kubesoloctl or the container decides them. A container instance leaves them out of its configuration, and kubesoloctl reports them as ignored:
- path: the data volume is mounted at the default path.
- network.nodeIP: the node is the container's address on its network.
- network.mtu: the container's network decides it, and KubeSolo detects it from its own interface.
- network.loadBalancer.ip: LoadBalancer addresses are the container's own; the host reaches services through published ports.
- runtime.*: a container always runs the embedded containerd, in container mode.
- kubernetes.nodeName: the node name is the container's hostname, which kubesoloctl keeps stable when it replaces the container.
- the CPU manager: exclusive cores are bounded by the container's cpuset, which KubeSolo does not control.
- api.*: the API serves upgrades, which a container cannot do to itself, and its socket is not reachable from the host.
- kubernetes.apiServer.port, d2k.port: kubesoloctl publishes the container's 6443 and 2376 on host ports of its own choosing, so it leaves them out of a container's configuration.
Functions ¶
func ContainerConfig ¶ added in v1.2.3
func ContainerConfig(args []string) (doc *types.Config, kept, dropped []string, warnings []kubesoloconfig.Warning, err error)
ContainerConfig resolves KubeSolo flags — the installer's, or an existing container's command line — into the configuration of a container instance. The settings in ContainerIgnored are left out before anything is parsed, so that a value that means nothing in a container cannot fail the install; the rest is validated as KubeSolo will. It returns the document, the flags that remain (for a release that predates the configuration file), and the flags it left out, a --path naming the default path aside.
func ContainerIgnoredSet ¶ added in v1.2.3
ContainerIgnoredSet returns the settings in ContainerIgnored that doc changes from what a container instance has: a configuration a user edited to set one.
func UsesConfigFile ¶ added in v1.2.3
UsesConfigFile reports whether a KubeSolo command line reads a configuration file rather than flags.
Types ¶
type Config ¶
type Config struct {
// Name identifies this KubeSolo instance. Used as the container name
// and kubeconfig context name. Defaults to AppName ("kubesolo").
Name string
// Version of KubeSolo to install (e.g. "v1.3.0")
Version string
// Path is the base directory KubeSolo stores its data in
Path string
// APIServerExtraSANs is an optional comma-separated list of extra SANs for the API server certificate
APIServerExtraSANs string
// NodeIP optionally overrides the auto-detected node IP (useful on multi-NIC hosts)
NodeIP string
// MTU optionally overrides the auto-detected network MTU used by the embedded
// CNI bridge (cni0) and pod veth interfaces. Empty means auto-detect. It is
// ignored in container run mode; see ContainerIgnored.
MTU string
// PortainerEdgeID is the Portainer edge agent ID
PortainerEdgeID string
// PortainerEdgeKey is the Portainer edge agent key
PortainerEdgeKey string
// PortainerEdgeAsync enables async mode for the Portainer edge agent
PortainerEdgeAsync bool
// PortainerEdgeImage overrides the image deployed for the Portainer edge agent.
// Empty means the flag is not passed and the KubeSolo binary uses its default.
PortainerEdgeImage string
// APIEnabled turns on the KubeSolo API, which is mounted into the Portainer
// edge agent's pod when an edge ID and key are set. It exists only in the
// configuration file: KubeSolo has no flag for it.
APIEnabled bool
// LocalStorage enables the local-path storage provisioner
LocalStorage bool
// Debug enables verbose debug logging in the installed KubeSolo process
Debug bool
// PprofServer enables the pprof HTTP server in the installed KubeSolo process
PprofServer bool
// RunMode controls how KubeSolo is started: "service" (default), "daemon", or "foreground"
RunMode string
// Proxy is an optional HTTP/HTTPS proxy URL injected into the service environment
Proxy string
// OfflineInstall is a path to a local binary or tarball to install instead of downloading
OfflineInstall string
// InstallPrereqs causes the installer to automatically install missing OS-level
// prerequisites (e.g. iptables or nftables) instead of hard-failing
InstallPrereqs bool
// D2K enables the d2k Docker-to-Kubernetes API translator
D2K bool
// D2KNamespace is the namespace d2k is deployed into and translates against
D2KNamespace string
// CPUManagerPolicy selects the kubelet CPU manager policy ("none" or "static").
// The static policy gives Guaranteed-QoS pods requesting whole CPUs exclusive
// cores, and is ignored in container run mode.
CPUManagerPolicy string
// CPUManagerPolicyOptions is a comma-separated list of key=value options that
// fine-tune the static CPU manager policy
CPUManagerPolicyOptions string
// ReservedCPUs is the cpuset held back for the host and KubeSolo itself, and
// never handed out as an exclusive core (e.g. "0" or "0-1")
ReservedCPUs string
// SystemReserved is a comma-separated ResourceName=Quantity list withheld from
// node allocatable for the host (e.g. "cpu=1,memory=500Mi")
SystemReserved string
// ContainerImage is the container image reference used in container run mode.
// If empty, defaults to DefaultContainerImage:Version.
// Specify a full reference (e.g. "myrepo/kubesolo:custom") to override entirely.
ContainerImage string
// ContainerPorts is a comma-separated list of host↔container port mappings to
// publish in container run mode (e.g. "9001,8080:80,9000-9100,53/udp"). Bare
// ports and ranges map host==container. It is a container-runtime concern and
// is deliberately NOT passed to the kubesolo binary via CmdArgs.
ContainerPorts string
// ContainerMounts is a comma-separated list of SRC:DST[:ro] host directories
// mounted into the container in container run mode, like kind's extraMounts.
// Like ContainerPorts, it is a container-runtime concern and is not passed to
// the kubesolo binary.
ContainerMounts string
// ConfigFile is where the KubeSolo configuration document is written, and
// the only flag passed to the binary once it is. Empty means the target
// binary predates the configuration file and must be given flags instead.
ConfigFile string
}
Config holds all configuration for the installer, sourced from CLI flags and environment variables. CLI flags take precedence over environment variables.
func (*Config) CmdArgs ¶
CmdArgs builds the argument list passed to the kubesolo binary when constructing service files or launching in daemon/foreground mode.
When the target binary understands --config, that is the whole command line: every setting lives in the configuration file instead. Older binaries predate the file and still get the full flag list, so kubesoloctl can install them.
func (*Config) ToKubeSoloConfig ¶ added in v1.2.1
func (c *Config) ToKubeSoloConfig(installed *types.Config) (*types.Config, []kubesoloconfig.Warning, error)
ToKubeSoloConfig resolves the installer's settings into the KubeSolo configuration document that will be written to ConfigFile.
The mapping is not written out a second time here. kubesoloFlags renders the settings as flags, and those flags are resolved through the same loader the kubesolo binary uses, against the same field registry. A setting can therefore not mean one thing to the installer and another to KubeSolo.
The environment is deliberately excluded: kubesoloctl's own environment is not the installed service's, and folding it in would write values into the file that the operator never asked for.
installed is the configuration it replaces (its defaults on a first install): the settings the installer has no flag for are kept from it, so a re-install does not reset a cluster's ports and networks.