KubeSolo Documentation

repository·develop·Indexed 19 days ago

https://github.com/portainer/kubesolo

KubeSolo is an ultra-lightweight, OCI-compliant, single-node Kubernetes distribution optimized for edge devices, IoT gateways, and developer laptops. It provides a full Kubernetes API and ecosystem compatibility with a RAM footprint under 200 MB by replacing etcd with Kine and SQLite, and utilizing a single-process architecture for the API server, controller manager, and kubelet.

Tokens
29K
Snippets
79
Records
143
Agent score
67%

What's inside KubeSolo

  1. What is KubeSolo?

    develop

    KubeSolo is an ultra-lightweight, OCI-compliant, single-node Kubernetes distribution designed for edge devices, IoT gateways, and developer laptops. It aims to replace Docker or Podman by providing a full Kubernetes API and ecosystem compatibility with a RAM footprint under 200 MB.

    Key characteristics:

    • Single-node optimized: Removes clustering machinery (etcd quorum, leader election, multi-node networking) to reduce overhead.
    • Lightweight stack: Uses containerd & crun for runtime, CoreDNS for DNS, and Kine with SQLite for storage (replacing etcd).
    • Single process: The API server, controller manager, and kubelet run together in a single process.
    • Scheduling: Uses a lightweight custom webhook called NodeSetter instead of the full Kubernetes Scheduler.
  2. Run multiple KubeSolo instances

    develop

    In container mode, you can run multiple independent KubeSolo instances side-by-side using the --name flag. Each instance will have its own:

    • Container (kubesolo-<name>)
    • Data volume
    • Kubeconfig context
    • Docker context (if using d2k)

    Always pass the same --name to management commands like upgrade, reset, uninstall, kubeconfig fetch, and d2k fetch to target the specific instance.

  3. How KubeSolo registry configuration works

    develop

    KubeSolo uses containerd's hosts.toml mechanism to support container registry features like mirrors, pull-through proxy caches, private registries, and custom TLS.

    At startup, KubeSolo configures containerd to look for configuration in /var/lib/kubesolo/containerd/registry. To configure a specific registry, you must create a subdirectory named after the registry hostname and place a hosts.toml file inside it:

    /var/lib/kubesolo/containerd/registry/
    └── <registry-hostname>/
        └── hosts.toml

    Key behaviors:

    • No restart required for updates: containerd reads hosts.toml files at pull time. Changes to these files take effect immediately without restarting KubeSolo or containerd.
    • Initial setup: A KubeSolo restart is only required the very first time you enable this feature to ensure the config_path is correctly set in the generated containerd configuration.
    • Requirement: Always use fully-qualified image references (e.g., docker.io/library/nginx:alpine) to ensure containerd can correctly map the pull request to the appropriate hosts.toml file.
  4. Publishing workload ports in container mode

    develop

    Because the KubeSolo node runs in its own network namespace, services using NodePort, LoadBalancer, or pods using hostPort are not automatically reachable from the host.

    You must explicitly publish these ports when creating the container (similar to Kind's extraPortMappings).

    • Using kubesoloctl: Use the --container-ports flag.
    • Using raw docker run: Add the required -p host_port:container_port mappings during the docker run command.
  5. Configure external CNI plugins for KubeSolo

    develop

    KubeSolo uses a non-standard directory for CNI plugin binaries. If you install an external CNI (like Cilium), you must ensure the plugin binaries are placed in KubeSolo's specific path, otherwise pod sandbox creation will fail with a 'failed to find plugin' error.

    Required Path Mappings:

    • Plugin binaries (bin_dirs): /var/lib/kubesolo/containerd/cni/plugins (Note: Stock Kubernetes defaults to /opt/cni/bin)
    • CNI config (conf_dir): /etc/cni/net.d (Matches stock default; no override needed)
  6. Handle KubeSolo's lack of scheduler when using CNIs

    develop

    KubeSolo does not include a kube-scheduler. Instead, a mutating webhook assigns pods to the single node by patching spec.nodeName directly.

    Implications for CNI and Workloads:

    • Replica Counts: Because there is no scheduler to spread workloads, any component that defaults to multiple replicas (like cilium-operator) will attempt to run all replicas on the same node.
    • Host Port Conflicts: If multiple replicas attempt to bind to the same host port on the single node, the kubelet will reject them with a NodePorts status.
    • Best Practice: Always set the replica count to 1 for CNI components and other workloads that rely on host ports or anti-affinity.
  7. How KubeSolo adjusts settings in container mode

    develop

    When running in container mode, KubeSolo automatically applies several adjustments to standard Kubernetes defaults to ensure stability within a containerized environment:

    AreaAdjustment
    cgroup driverUses cgroupfs with controller delegation on the root cgroup
    Mount propagation/ is remounted rshared to allow volume propagation
    kubelet QoS cgroupscgroupsPerQOS: false and enforceNodeAllocatable: [] to avoid cgroupv2 conflicts
    Eviction / GCRelaxed thresholds (memory.available: 50Mi, disk: 0%) to prevent host-driven eviction
    Pod DNSresolv.conf set to /dev/null to prevent host DNS leakage
    CoreDNS upstreamForwards to 1.1.1.1 and 8.8.8.8
    CoreDNS resourcesMemory limit removed to prevent OOM under container constraints
    kube-proxy conntrackSet to 0 to avoid read-only /proc/sys/net/netfilter/nf_conntrack_max errors
  8. Understand KubeSolo run modes

    develop

    kubesoloctl operates in different modes depending on your environment and use case:

    • service (default on Linux): Installs the KubeSolo binary as a system service (systemd, OpenRC, etc.). This is the production path for edge devices and gateways.
    • container: Runs KubeSolo inside a container. This is the required mode for macOS and is recommended for development/CI on Windows (WSL2) or Linux. It requires a running container engine (Docker Engine / Docker Desktop).
    • daemon: Runs KubeSolo as a background process without an init system. Best for minimal hosts.
    • foreground: Keeps the process in the terminal, useful for debugging.
  9. Quickstart: Install KubeSolo on a Linux host (service mode)

    develop

    To install KubeSolo directly on a Linux host as a system service, use the install command with sudo. This performs pre-flight checks, installs the binary to /usr/local/bin/kubesolo, configures the service, and merges the admin kubeconfig into your ~/.kube/config.

    sudo kubesoloctl install
    
    # Verify installation
    kubectl get nodes --watch    # wait until STATUS: Ready
    kubectl get pods -A
  10. Quickstart: Install KubeSolo in Container mode (macOS, WSL2, or Linux dev)

    develop

    To run KubeSolo inside a container (ideal for local development), use the --run-mode=container flag. On macOS, this mode is applied automatically. KubeSolo will publish its API server on a random localhost port and automatically merge/point your kubeconfig to it.

    Note: If the host port changes (e.g., after an upgrade or reset), you must refresh your kubeconfig using kubesoloctl kubeconfig fetch.

    # On macOS this is implied; elsewhere request it explicitly:
    kubesoloctl install --run-mode=container
    
    # Verify installation
    kubectl get nodes --watch
    
    # If the host port changes, refresh kubeconfig:
    kubesoloctl kubeconfig fetch
  11. Verify Cilium installation on KubeSolo

    develop

    After installation or upgrade, verify that the Cilium agent and operator are running correctly and that the binary is in the expected KubeSolo directory.

    Verification Steps:

    1. Check Cilium status: cilium status --wait
    2. Check pod status: kubectl -n kube-system get pods -l k8s-app=cilium
    3. Confirm binary location: ls -l /var/lib/kubesolo/containerd/cni/plugins/cilium-cni

    Cleanup: If failed operator pods are stuck in the system, delete them using:

    kubectl -n kube-system delete pod -l io.cilium/app=operator --field-selector status.phase=Failed
  12. Install KubeSolo (Quick Install)

    develop

    Prerequisites

    WARNING: Ensure that no container engine (e.g., Docker, Podman, containerd) is installed or active on the target system prior to installation to avoid networking interference.

    Installation Variants

    Choose the variant based on your connectivity requirements:

    1. Online (Default): Smaller binary; pulls container images from public registries at startup. Requires internet access.
    2. Offline: Larger binary; bundles all required container images, CNI plugins, and runtime dependencies. Ideal for air-gapped environments.
    3. Air-gapped: For machines with no internet access at all. Requires downloading the bundle on a connected machine first.

    Installation Commands

    Online Installation

    curl -sfL https://get.kubesolo.io | sudo sh -

    Offline Installation (Target has internet, but needs bundled images)

    curl -sfL https://get.kubesolo.io | KUBESOLO_OFFLINE=true sudo -E sh -

    Air-gapped Installation (No internet on target)

    # 1. On a connected machine, download the bundle
    curl -sfL https://get.kubesolo.io | KUBESOLO_OFFLINE=true sh - --download-only=/tmp/kubesolo-bundle
    
    # 2. Transfer the files to the target machine, then install
    sudo sh install.sh --offline-install=<archive.tar.gz>
    # Online installation example
    curl -sfL https://get.kubesolo.io | sudo sh -