types

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigAPIVersion versions the document schema. A file declaring an
	// apiVersion KubeSolo does not recognise is rejected rather than guessed at.
	ConfigAPIVersion = "kubesolo.io/v1alpha1"
	ConfigKind       = "Config"
)

Config is the KubeSolo configuration document, read from DefaultConfigFile and served by the config API.

It carries only settings a user supplies. Everything KubeSolo derives from them — the certificate, containerd, kine and kubelet paths — lives on Embedded, which is built from a Config rather than replaced by it.

Fields are tagged for JSON only. sigs.k8s.io/yaml converts YAML to JSON before unmarshalling, so one set of tags serves both the file on disk and the API payload; a second set of yaml tags would be a second thing to keep in sync.

View Source
const (
	DefaultNodeName                  = "kubesolo-node"
	DefaultWebhookName               = "webhook.kubesolo.io"
	DefaultSystemCNIDir              = "/opt/cni"
	DefaultEmbeddedCNIDir            = "bin/cni"
	DefaultWebhookPort               = 10443
	DefaultAPIServerPort             = 6443
	DefaultControllerManagerPort     = 10257
	DefaultKubeletPort               = 10250
	DefaultKubeletHealthzPort        = 10248
	DefaultKubeProxyHealthzPort      = 10256
	DefaultKinePort                  = 2379
	DefaultPprofPort                 = 6060
	DefaultPKIDir                    = "pki"
	DefaultContainerdDir             = "containerd"
	DefaultContainerdSocket          = "containerd.sock"
	DefaultSystemContainerdSock      = "/run/containerd/containerd.sock"
	DefaultStandardCNIConfDir        = "/etc/cni/net.d"
	DefaultContainerdConfigDir       = "/etc/containerd/conf.d"
	LegacyContainerdConfigDir        = "/etc/containerd/config.d"
	DefaultCNIConfigName             = "10-bridge.conflist"
	DefaultK8sNamespace              = "k8s.io"
	DefaultKubeletDir                = "kubelet"
	DefaultAPIServerDir              = "apiserver"
	DefaultPodCIDR                   = "10.42.0.0/16"
	DefaultServiceClusterIPRange     = "10.43.0.0/16"
	DefaultCoreDNSIP                 = "10.43.0.10"
	DefaultKubernetesServiceIP       = "10.43.0.1"
	DefaultKineDir                   = "kine"
	DefaultKineSocket                = "kine.sock"
	DefaultControllerManagerDir      = "controller-manager"
	DefaultSandboxImage              = "docker.io/portainer/pause:latest"
	DefaultPortainerEdgeImage        = "docker.io/portainer/agent:lts"
	DefaultCoreDNSImage              = "docker.io/coredns/coredns:1.14.4"
	DefaultLocalPathProvisionerImage = "docker.io/rancher/local-path-provisioner:v0.0.36"
	DefaultLocalPathStorageDir       = "local-path-storage"
	DefaultD2KImage                  = "docker.io/portainer/d2k:1.2.3"
	DefaultD2KPort                   = int32(2376)
	DefaultD2KDir                    = "d2k"
	DefaultWebhookReadWriteTimeout   = 10 * time.Second
	DefaultWebhookIdleTimeout        = 30 * time.Second
	DefaultContextTimeout            = 60 * time.Second
	DefaultComponentSleep            = 5 * time.Second
	DefaultStartupTimeout            = 600 // seconds
	DefaultNftMasqTable              = "kubesolo-masq"
	DefaultMTU                       = 1500 // fallback when MTU detection fails
	DefaultMetricsBindAddress        = "127.0.0.1:9105"
	DefaultMetricsProbeInterval      = 15 * time.Second
	DefaultKineDBFile                = "state.db"

	// DefaultBasePath is the directory KubeSolo stores all of its state in, and
	// the default for --path. Mirrored by internal/cli/config.DefaultPath.
	DefaultBasePath = "/var/lib/kubesolo"

	// DefaultConfigFile is where KubeSolo reads its configuration from. It sits
	// outside DefaultBasePath deliberately: configuration is not cluster state, so
	// it must survive `kubesoloctl reset`, which removes the data directory.
	DefaultConfigFile = "/etc/kubesolo/config.yaml"

	// DefaultAPISocketName is the unix socket the config API listens on, relative
	// to the base path.
	DefaultAPISocketName = "config.sock"

	// DefaultD2KNamespace is the namespace d2k is deployed into. Distinct from
	// DefaultD2KDir, which names a PKI subdirectory that happens to match.
	DefaultD2KNamespace = "d2k"
)
View Source
const (
	CPUManagerPolicyNone   = "none"
	CPUManagerPolicyStatic = "static"
)

CPU manager policies. With the static policy, Guaranteed-QoS pods that request whole CPUs get exclusive cores instead of sharing the CFS quota pool.

Variables

View Source
var (
	KubesoloKineDir              = filepath.Join(DefaultKineDir, "db")
	KubesoloControllerManagerDir = filepath.Join(DefaultControllerManagerDir, "config")
	KubesoloWebhookDir           = filepath.Join(DefaultPKIDir, "webhook")

	// DefaultRetryCount is the number of health-check retries per component.
	// Derived from --startup-timeout at startup: timeout / DefaultComponentSleep.
	DefaultRetryCount = DefaultStartupTimeout / int(DefaultComponentSleep.Seconds())
)

Functions

This section is empty.

Types

type APIServerCertificatePaths

type APIServerCertificatePaths struct {
	CertificatePaths
}

APIServerCertificatePaths defines paths for API server certificates

type APIServerConfig added in v1.2.1

type APIServerConfig struct {
	// ExtraSANs are additional Subject Alternative Names for the API server
	// certificate, as IP addresses or DNS names.
	ExtraSANs []string `json:"extraSANs,omitempty"`

	// AuthenticationConfigFile names the kube-apiserver AuthenticationConfiguration
	// file. JWT configuration changes are reloaded by kube-apiserver.
	AuthenticationConfigFile string `json:"authenticationConfigFile,omitempty"`

	// StartupTimeoutSeconds bounds how long each component may take to pass its
	// health check at startup. Raise it on slow storage such as SD cards.
	StartupTimeoutSeconds int `json:"startupTimeoutSeconds"`

	// Port is the API server's secure port, on every interface. The generated
	// kubeconfigs point at it.
	Port int `json:"port"`
}

APIServerConfig covers the Kubernetes API server.

type AdminCertificatePaths

type AdminCertificatePaths struct {
	CertificatePaths
}

AdminCertificatePaths defines paths for admin certificates

type CACertificatePaths

type CACertificatePaths struct {
	Cert string
	Key  string
}

CACertificatePaths defines paths for CA certificates

type CPUManagerConfig added in v1.2.0

type CPUManagerConfig struct {
	Policy        string            `json:"policy"`
	PolicyOptions map[string]string `json:"policyOptions,omitempty"`
	ReservedCPUs  string            `json:"reservedCPUs"`
}

CPUManagerConfig contains the kubelet CPU manager settings. With Policy set to CPUManagerPolicyStatic, Guaranteed-QoS pods requesting whole CPUs are given exclusive cores. ReservedCPUs is the cpuset held back for the system and kubesolo itself, which the static policy requires to be non-empty.

type CertificatePaths

type CertificatePaths struct {
	CACert string
	Cert   string
	Key    string
}

CertificatePaths defines the paths for a specific certificate type

type Config added in v1.2.1

type Config struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`

	// Path is the directory KubeSolo stores all of its state in. It cannot be
	// changed on a running install: every certificate, the kine database and all
	// containerd state live below it, and nothing migrates them.
	Path string `json:"path,omitempty"`

	Logging    LoggingConfig    `json:"logging"`
	Network    NetworkConfig    `json:"network"`
	Runtime    RuntimeConfig    `json:"runtime"`
	Kubernetes KubernetesConfig `json:"kubernetes"`
	Storage    StorageConfig    `json:"storage"`
	Portainer  PortainerConfig  `json:"portainer"`
	D2K        D2KConfig        `json:"d2k"`
	Metrics    MetricsConfig    `json:"metrics"`
	API        ConfigAPI        `json:"api"`
}

type ConfigAPI added in v1.2.1

type ConfigAPI struct {
	Enabled bool `json:"enabled"`

	// SocketPath is where the socket is created. Empty means
	// <path>/DefaultAPISocketName.
	SocketPath string `json:"socketPath"`
}

ConfigAPI covers the config API itself.

The API listens on a unix socket rather than a port: the filesystem permissions on the socket are the authorisation model, which avoids putting a mutating endpoint on the network of an edge device.

type ControllerManagerCertificatePaths

type ControllerManagerCertificatePaths struct {
	CertificatePaths
}

ControllerManagerCertificatePaths defines paths for controller manager certificates

type ControllerManagerConfig added in v1.3.0

type ControllerManagerConfig struct {
	// Port is the controller manager's secure (health and metrics) port, on
	// every interface.
	Port int `json:"port"`
}

ControllerManagerConfig covers the Kubernetes controller manager.

type D2KCertificatePaths added in v1.1.7

type D2KCertificatePaths struct {
	CACert     string
	ServerCert string
	ServerKey  string
	ClientCert string
	ClientKey  string
}

D2KCertificatePaths defines paths for the d2k TLS material. CACert is the kubesolo CA certificate that signs both server and client certs; it is the existing /var/lib/kubesolo/pki/ca/ca.crt and is referenced by docker CLI clients via --tlscacert. ServerCert/ServerKey are mounted into the d2k pod as /etc/d2k/tls/tls.crt and tls.key. ClientCert/ClientKey are used by docker CLI clients via --tlscert and --tlskey.

type D2KConfig added in v1.2.1

type D2KConfig struct {
	Enabled bool `json:"enabled"`

	// Namespace is the single namespace d2k is deployed into and translates
	// Docker API calls against.
	Namespace string `json:"namespace"`

	// Port is the port the d2k LoadBalancer Service publishes the Docker API on,
	// at the LoadBalancer IP.
	Port int `json:"port"`
}

D2KConfig covers the Docker-to-Kubernetes API translator.

type EdgeAgentConfig

type EdgeAgentConfig struct {
	Image            string
	EdgeID           string
	EdgeKey          string
	EdgeAsync        bool
	EdgeInsecurePoll string
	EdgeSecret       string
	EnvVars          map[string]string

	// APISocketDir is a host directory holding a KubeSolo API socket for the
	// agent, mounted into its pod. Empty means the agent gets no access to the
	// API.
	APISocketDir string
}

EdgeAgentConfig contains configuration for Portainer Edge Agent

type Embedded

type Embedded struct {
	// NodeName is the name of the single node this control plane manages. It is
	// the kubelet's registered node name, the subject of its client certificate
	// and its RBAC binding, and the node the NodeSetter webhook pins pods to.
	// Resolved from kubernetes.nodeName, falling back to the hostname.
	NodeName string

	// System Node IP
	NodeIP string

	// NodeIPSpecified is true when the node IP was explicitly set via --node-ip
	// (rather than auto-detected). When set, the API server cert SANs are scoped
	// to this IP instead of every local interface address.
	NodeIPSpecified bool

	// Network MTU used by the embedded CNI bridge (cni0) and pod veth interfaces
	MTU int

	// MTUSpecified is true when the MTU was explicitly set via --mtu (rather
	// than auto-detected).
	MTUSpecified bool

	// PKI directories
	PKIDir              string
	PKICADir            string
	PKIAdminDir         string
	PKIAPIServerDir     string
	PKIControllerDir    string
	PKIKubeletDir       string
	PKIWebhookDir       string
	PKIRequestHeaderDir string

	// Admin kubeconfig file
	AdminKubeconfigFile string

	// Certificate paths
	KubeletCerts           KubeletCertificatePaths
	APIServerCerts         APIServerCertificatePaths
	ControllerManagerCerts ControllerManagerCertificatePaths
	AdminCerts             AdminCertificatePaths
	WebhookCerts           WebhookCertificatePaths
	CACerts                CACertificatePaths
	RequestHeaderCerts     RequestHeaderCertificatePaths

	// Containerd directories and files
	ContainerdDir               string
	ContainerdSocketFile        string
	ContainerdBinaryFile        string
	ContainerdImagesDir         string
	ContainerdConfigFile        string
	ContainerdShimBinaryFile    string
	ContainerdRootDir           string
	ContainerdStateDir          string
	ContainerdRegistryConfigDir string

	// Conitainerd CNI directories and files
	ContainerdCNIDir        string
	ContainerdCNIPluginsDir string
	ContainerdCNIConfigDir  string
	ContainerdCNIConfigFile string

	// Crun binary
	CrunBinaryFile string

	// Container runtime. RuntimeExternal is true when KubeSolo attaches to a
	// host-managed CRI runtime given with --container-runtime-endpoint instead of
	// starting its own embedded containerd. RuntimeEndpoint is populated in both
	// cases — for the embedded containerd it is "unix://" + ContainerdSocketFile —
	// so consumers need only one code path. RuntimeSocketPath is the filesystem
	// path of RuntimeEndpoint.
	// RuntimeCgroupDriver is the cgroup driver reported by an external runtime over
	// CRI, which the kubelet must match. Empty when the runtime does not report one,
	// in which case the kubelet detects the driver from the host instead.
	RuntimeExternal     bool
	RuntimeEndpoint     string
	RuntimeSocketPath   string
	RuntimeCgroupDriver string

	// Kubelet directories
	KubeletDir            string
	KubeletConfigDir      string
	KubeletConfigFile     string
	KubeletDropInDir      string
	KubeletKubeConfigFile string
	KubeletPluginsDir     string

	// API Server directory
	APIServerDir          string
	ServiceAccountKeyFile string
	// API Server extra SANs
	APIServerExtraSANs []string
	// API Server structured authentication configuration file
	APIServerAuthenticationConfigFile string

	// Kine directories and files
	KineDir        string
	KineSocketFile string

	// Controller manager directory
	ControllerDir string

	// Webhook directory
	WebhookDir string

	// Images
	PortainerEdgeImageFile        string
	CorednsImageFile              string
	SandboxImageFile              string
	LocalPathProvisionerImageFile string
	D2KImageFile                  string

	// Load Balancer
	LoadBalancer bool

	// LoadBalancerIP is the IP published as the LoadBalancer EXTERNAL-IP.
	// Defaults to NodeIP unless overridden with --load-balancer-ip.
	LoadBalancerIP string

	// Ports the control plane listens on (kubernetes.*.port, storage.kine.port,
	// logging.pprofPort, d2k.port). KineEndpoint is kine's address on loopback.
	APIServerPort         int
	ControllerManagerPort int
	KubeletPort           int
	KubeletHealthzPort    int
	KubeProxyHealthzPort  int
	WebhookPort           int
	KinePort              int
	KineEndpoint          string
	PprofPort             int
	D2KPort               int

	// Cluster networks (kubernetes.podCIDR, kubernetes.serviceCIDR,
	// kubernetes.clusterDNS). KubernetesServiceIP is the first address of
	// ServiceCIDR; ClusterDNS is the CoreDNS Service's cluster IP, resolved.
	PodCIDR             string
	ServiceCIDR         string
	KubernetesServiceIP string
	ClusterDNS          string

	// Local Path Storage
	LocalPathStorageDir string
	LocalStorage        bool

	// Portainer Edge
	IsPortainerEdge    bool
	PortainerEdgeImage string

	// Container Mode
	ContainerMode bool

	// IPv6
	DisableIPv6 bool

	// d2k integration
	D2K          bool
	D2KNamespace string
	D2KCerts     D2KCertificatePaths

	// Metrics endpoint configuration
	Metrics MetricsConfig

	// CPU manager configuration
	CPUManager CPUManagerConfig

	// SystemReserved is the resource list withheld from node allocatable for the
	// host, e.g. {"cpu": "1", "memory": "500Mi"}
	SystemReserved map[string]string
}

type KineConfig added in v1.3.0

type KineConfig struct {
	// Port is the port kine serves the etcd API on, on loopback: only the API
	// server talks to it.
	Port int `json:"port"`
}

KineConfig covers kine, the etcd API in front of the SQLite database.

type KubeProxyConfig added in v1.3.0

type KubeProxyConfig struct {
	// HealthzPort is kube-proxy's health endpoint, on every interface.
	HealthzPort int `json:"healthzPort"`
}

KubeProxyConfig covers kube-proxy.

type KubeletCertificatePaths

type KubeletCertificatePaths struct {
	CertificatePaths
}

KubeletCertificatePaths defines paths for kubelet certificates

type KubeletConfig added in v1.2.1

type KubeletConfig struct {
	CPUManager CPUManagerConfig `json:"cpuManager"`

	// SystemReserved is withheld from node allocatable for the host, keyed by
	// resource name, e.g. {"cpu": "1", "memory": "500Mi"}.
	SystemReserved map[string]string `json:"systemReserved,omitempty"`

	// Port is the kubelet API's port, on every interface: the API server reaches
	// it for logs, exec and port-forward.
	Port int `json:"port"`

	// HealthzPort is the kubelet's health endpoint, on loopback.
	HealthzPort int `json:"healthzPort"`
}

KubeletConfig covers the node agent's resource management.

type KubernetesConfig added in v1.2.1

type KubernetesConfig struct {
	// NodeName is the name of the single node this control plane manages. Empty
	// means the hostname.
	//
	// It is trimmed and lowercased, because that is what the kubelet does to the
	// name before registering it, and the NodeSetter webhook pins every pod to
	// this name — a mismatch leaves the whole cluster Pending.
	NodeName string `json:"nodeName,omitempty"`

	// PodCIDR is the range pod IPs are allocated from: the CNI bridge's, the
	// node's spec.podCIDR, kube-proxy's and the pod masquerade rule's. It cannot
	// be changed on an existing install: the node's spec.podCIDR is immutable
	// once allocated, and running pods keep their addresses.
	PodCIDR string `json:"podCIDR"`

	// ServiceCIDR is the range Service cluster IPs are allocated from. Its first
	// address is the kubernetes Service's, which the API server certificate
	// carries. It cannot be changed on an existing install: Services keep the
	// cluster IPs they were given.
	ServiceCIDR string `json:"serviceCIDR"`

	// ClusterDNS is the cluster IP of the CoreDNS Service, which the kubelet hands
	// to every pod as its nameserver. Empty means the tenth address of
	// ServiceCIDR. Like it, it cannot be changed on an existing install.
	ClusterDNS string `json:"clusterDNS"`

	APIServer         APIServerConfig         `json:"apiServer"`
	ControllerManager ControllerManagerConfig `json:"controllerManager"`
	Kubelet           KubeletConfig           `json:"kubelet"`
	KubeProxy         KubeProxyConfig         `json:"kubeProxy"`
	Webhook           WebhookConfig           `json:"webhook"`
}

KubernetesConfig groups the Kubernetes control plane components.

These are grouped because the family grows. Everything else in this document is single-purpose and stays at the top level.

type LoadBalancerConfig added in v1.2.1

type LoadBalancerConfig struct {
	Enabled bool `json:"enabled"`

	// IP overrides the address published as EXTERNAL-IP. Empty means the node IP.
	IP string `json:"ip"`
}

LoadBalancerConfig controls the EXTERNAL-IP KubeSolo sets on Services of type LoadBalancer.

type LocalPathConfig added in v1.2.1

type LocalPathConfig struct {
	Enabled bool `json:"enabled"`

	// SharedPath is a shared filesystem for local storage. Empty means the
	// provisioner uses its directory below Path.
	SharedPath string `json:"sharedPath"`
}

LocalPathConfig covers the local-path storage provisioner.

type LoggingConfig added in v1.2.1

type LoggingConfig struct {
	Debug bool `json:"debug"`
	Pprof bool `json:"pprof"`

	// PprofPort is the port the pprof server listens on, on every interface,
	// when Pprof is set.
	PprofPort int `json:"pprofPort"`
}

LoggingConfig controls log verbosity and the pprof server.

type MetricsConfig added in v1.2.0

type MetricsConfig struct {
	Enabled     bool   `json:"enabled"`
	BindAddress string `json:"bindAddress"`
}

MetricsConfig contains configuration for the kubesolo Prometheus metrics endpoint. When Enabled is true, kubesolo serves a /metrics HTTP endpoint exposing control plane health gauges, kine DB size, and build info.

type NetworkConfig added in v1.2.1

type NetworkConfig struct {
	// NodeIP overrides the auto-detected node IP. Empty means auto-detect,
	// preferring a private (RFC 1918) address.
	NodeIP string `json:"nodeIP"`

	// MTU overrides the auto-detected MTU used by cni0 and pod veth interfaces.
	// Zero means auto-detect.
	MTU int `json:"mtu"`

	// DisableIPv6 stops CoreDNS serving ip6.arpa reverse zones and makes the
	// kubelet register with an explicit IPv4 node address.
	DisableIPv6  bool               `json:"disableIPv6"`
	LoadBalancer LoadBalancerConfig `json:"loadBalancer"`
}

NetworkConfig covers node addressing and the embedded CNI bridge.

type PortainerConfig added in v1.2.1

type PortainerConfig struct {
	EdgeID string `json:"edgeID"`

	// EdgeKey is a credential. It is redacted in config API responses and the
	// config file is written 0600.
	EdgeKey string `json:"edgeKey"`
	Async   bool   `json:"async"`

	// Image is the full agent image reference including its tag. Anything other
	// than the default is pulled from a registry rather than loaded from the
	// embedded archive.
	Image string `json:"image"`
}

PortainerConfig covers the optional Portainer Edge Agent.

type PreflightCheck added in v1.2.3

type PreflightCheck struct {
	Name   string          `json:"name"`
	Result PreflightResult `json:"result"`
	// Message says what the check found; empty when it passed.
	Message string `json:"message,omitempty"`
}

PreflightCheck is the result of one pre-flight check.

type PreflightReport added in v1.2.3

type PreflightReport struct {
	Checks []PreflightCheck `json:"checks"`
}

PreflightReport is what `kubesoloctl check --json` prints: the result of every pre-flight check, in the order they ran.

func (PreflightReport) Failed added in v1.2.3

func (r PreflightReport) Failed() bool

Failed reports whether any check failed.

type PreflightResult added in v1.2.3

type PreflightResult string

PreflightResult is the outcome of a pre-flight check. Only a failure stops an install.

const (
	PreflightPass PreflightResult = "pass"
	PreflightWarn PreflightResult = "warn"
	PreflightFail PreflightResult = "fail"
)

type RequestHeaderCertificatePaths

type RequestHeaderCertificatePaths struct {
	CACert     string
	CAKey      string
	ClientCert string
	ClientKey  string
}

RequestHeaderCertificatePaths defines paths for request header CA and client certificates

type RuntimeConfig added in v1.2.1

type RuntimeConfig struct {
	// Endpoint is the CRI endpoint of a host-managed runtime, for example
	// unix:///run/crio/crio.sock. Empty means KubeSolo runs its own containerd.
	Endpoint string `json:"endpoint"`

	// ContainerMode forces container mode on or off. Nil — the default — means
	// auto-detect, which is why this is a pointer: false and unset must differ.
	ContainerMode *bool `json:"containerMode,omitempty"`
}

RuntimeConfig selects the container runtime.

type StorageConfig added in v1.2.1

type StorageConfig struct {
	LocalPath LocalPathConfig `json:"localPath"`
	Kine      KineConfig      `json:"kine"`

	// DBWALRepair runs an integrity check against the SQLite database at startup
	// and clears WAL artefacts if it is corrupt. Recovers from power loss.
	DBWALRepair bool `json:"dbWALRepair"`
}

StorageConfig covers the local-path provisioner and the kine database.

type WebhookCertificatePaths

type WebhookCertificatePaths struct {
	CertificatePaths
}

WebhookCertificatePaths defines paths for webhook certificates

type WebhookConfig added in v1.3.0

type WebhookConfig struct {
	// Port is the webhook's port, on loopback: only the API server calls it.
	Port int `json:"port"`
}

WebhookConfig covers KubeSolo's admission webhook, which pins every pod to the node (KubeSolo runs no scheduler) and publishes LoadBalancer IPs.

Jump to

Keyboard shortcuts

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