LLMKube

repository·main·Indexed 41 days ago

https://github.com/defilantech/llmkube

A Kubernetes operator for self-hosted LLM inference that automates deployment, scaling, and management of models across NVIDIA, AMD, and Apple Silicon hardware. It provides an OpenAI-compatible API and supports deployment via Helm, a dedicated CLI, or Kubernetes custom resources (Model and InferenceService) from the inference.llmkube.dev/v1alpha1 API group. Includes a specialized Metal Agent for macOS acceleration and integrations for Prometheus and Grafana.

Tokens
169.3K
Snippets
366
Records
628
Agent score
53%

What's inside LLMKube

  1. Understand the NVIDIA Blackwell B200 (sm_100) Validation Status

    main

    LLMKube tracks its validation status for NVIDIA Blackwell datacenter GPUs (B200, GB200, compute capability sm_100) via a validation matrix. This matrix ensures that enterprise users running LLMKube on next-generation hardware have verified support for core features like NVLink5, MIG, and FP4 quantization.

    Current Status (as of 2026-08-05):

    • Hardware Access: sm_100 is currently not reachable. Validation is pending NVIDIA dev partnership or customer installation.
    • Partial Proxy: Validation is being partially advanced using NVIDIA DGX Spark (GB10, sm_121) units. Note that sm_121 results are used as supporting evidence but do not count as official sm_100 passes because the instruction sets are not interchangeable.
    • Tracking: Progress is tracked via GitHub issue #413.
  2. What is Foreman and how does it work

    main

    Foreman is a Kubernetes-native control plane for agentic workloads that acts as an opt-in add-on to LLMKube. It dispatches specialized agents (coder, verifier, and reviewer) across a heterogeneous fleet of locally-hosted LLM nodes (e.g., Apple Silicon, NVIDIA CUDA, Intel oneAPI).

    Foreman operates between the inference engine (like vLLM or llama.cpp) and the application layer, using Kubernetes as the substrate to match tasks to hardware capabilities. It produces PR-shaped contributions directly to GitHub repositories.

    Core Workflow

    A Workload (the user's intent) is decomposed by a reconciler into a sequence of AgenticTask units. Each task is claimed by a FleetNode whose advertised hardware capabilities match the Agent's requirements. The process runs a native Go function-calling loop against local inference endpoints.

  3. What is the Model Router and how does it work?

    main

    The ModelRouter is a Kubernetes Custom Resource Definition (CRD) that provides a single, OpenAI-compatible HTTP endpoint to dispatch LLM requests across multiple backends. It acts as a cross-engine handoff layer for agentic chains, allowing an agent to move between local models and cloud providers based on declarative policies.

    Key Capabilities:

    • Backend Support: Routes to local InferenceService instances, external providers (Anthropic, OpenAI), or a LiteLLM proxy.
    • Policy-Driven Routing: Uses rules based on data classification, task complexity, or headers to decide where a request goes.
    • Fail-Closed Semantics: Ensures sensitive data (e.g., pii, phi) never leaves the cluster by refusing requests if local backends are unhealthy, rather than falling back to cloud providers.
    • Audit Logging: Emits one audit-log line per request to stdout.
    • Streaming: Supports SSE/chunked response streaming without buffering.

    Status: ModelRouter is in alpha (as of LLMKube 0.8). The CRD resides in inference.llmkube.dev/v1alpha1.

    apiVersion: inference.llmkube.dev/v1alpha1
    kind: ModelRouter
    metadata:
      name: coding-router
    spec:
      backends:
        - name: local-qwen
          tier: local
          inferenceServiceRef:
            name: qwen3-coder
        - name: cloud-opus
          tier: cloud
          external:
            provider: anthropic
            model: claude-opus-4-7
            url: https://api.anthropic.com
            credentialsSecretRef:
              name: anthropic-key
    
      rules:
        - name: pii-stays-local
          match:
            dataClassification: ["pii", "phi"]
          route:
            backends: ["local-qwen"]
          failClosed: true
    
        - name: complex-to-cloud
          match:
            taskComplexity: complex
          route:
            backends: ["cloud-opus", "local-qwen"]
            strategy: primary-fallback
    
      defaultRoute: local-qwen
  4. What is the macOS Metal Agent?

    main
    The Metal Agent is a native macOS daemon that allows Apple Silicon Macs (M1/M2/M3/M4/M5) to act as first-class Kubernetes inference nodes. It watches the Kubernetes API for InferenceService resources with accelerator: metal, spawns llama-server processes natively to ensure full Metal GPU access, and registers the resulting endpoints back into the Kubernetes cluster. This enables you to serve LLMs from a Mac Studio or Mac mini using the same InferenceService CRD used for NVIDIA GPUs.
  5. What is Foreman and how to use it for agentic workloads

    main

    Foreman is an opt-in orchestrator for agentic workloads built on top of LLMKube. It uses its own API group (foreman.llmkube.dev) and introduces four CRDs: Workload, AgenticTask, Agent, and FleetNode.

    Foreman is designed for high-scale, autonomous agentic tasks (like automated coding/testing pipelines) where on-prem hardware or sovereignty constraints make cloud-only models unsuitable. It features a capability-aware scheduler and a native Go agent loop that executes OpenAI function-calling against local inference endpoints.

    A typical Workload defines an intent, a repository, specific issues to address, and a set of specialized agents (coder, verifier, reviewer) to execute the task pipeline.

    apiVersion: foreman.llmkube.dev/v1alpha1
    kind: Workload
    metadata:
      name: fix-small-bugs
      namespace: default
    spec:
      intent: "Fix small open issues"
      repo: defilantech/LLMKube
      issues: [510, 526, 449]
      coderAgentRef:    { name: qwen36-35b-carnice-mtp-coder }
      verifierAgentRef: { name: shadowstack-gate }
      reviewerAgentRefs:
        - { name: qwen36-35b-a3b-reviewer }
        - { name: devstral-24b-reviewer }
  6. Understand Model Cache topologies

    main

    LLMKube supports three primary model cache topologies depending on your cluster requirements and storage capabilities:

    TopologyMode / ConfigurationBest Use Case
    Shared RWXshared + RWX storageMulti-node clusters where the cache must be reachable from every serving node.
    Operator-managed per-servicemodelCache.mode: perServiceClusters with a WaitForFirstConsumer provisioner that can create volumes on the selected node.
    Pre-provisioned (Strict Taint)spec.modelCache.claimNameGPU nodes with strict NoSchedule taints where dynamic provisioning is unsuitable.

    Key Concept: The Downloader Lifecycle When using claimName with a remote URL, the downloader is an init container within the inference pod itself. This ensures the downloader inherits the same node selection and GPU tolerations as the serving container, allowing it to function even on strictly tainted nodes.

  7. Foreman Agentic Pipeline

    main
    Foreman is a Kubernetes-native agentic pipeline (v0.1) designed to dispatch workloads across a heterogeneous fleet. It follows a coder / verifier / reviewer pattern. Workloads are gated against the repository's own build and tests and can be executed in Job-mode against in-cluster models.
  8. Configure GPUQuota priority ordering

    main

    The minPriority field allows operators to reserve capacity for important workloads. Priorities are ordered from highest to lowest:

    1. critical (Highest)
    2. high
    3. normal (Default)
    4. low
    5. batch (Lowest)

    An InferenceService with priority low will be denied by a quota with minPriority: normal, even if there is available GPU headroom.

  9. When to use Job-mode vs InProcess execution

    main

    Choose the execution mode based on where your model is hosted:

    • Use InProcess (default): When the model is served on the same machine as the foreman-agent (e.g., a Mac using metal-agent and llama-server).
    • Use Job mode: When the model is hosted elsewhere, such as:
      • An in-cluster CUDA InferenceService on a Linux GPU node.
      • An external or remote model endpoint reachable from the cluster.

    Job mode allows the coder loop to communicate with remote models over the cluster network or via external endpoints.

  10. How the Persistent Model Cache works

    main

    LLMKube uses a persistent model cache to avoid re-downloading large models (e.g., 13B-70B) every time an InferenceService is recreated.

    Architecture

    • Per-Namespace PVCs: A PersistentVolumeClaim (PVC) named llmkube-model-cache is automatically created in every namespace where you deploy models. This provides namespace isolation and simple RBAC.
    • Lifecycle:
      • The first pod in a namespace triggers an init-container to download the model into the llmkube-model-cache PVC.
      • Subsequent pods mount the PVC as read-only and skip the download process, allowing deployments to complete in seconds rather than minutes.
    • Cache Keys: Models are indexed in the PVC using a SHA256 hash (first 16 characters) of their source URL. The resulting path follows the pattern /models/<cache-key>/model.gguf.
    Example Cache Mapping:
    Source: https://huggingface.co/TheBloke/Llama-2-7B-GGUF/resolve/main/llama-2-7b.Q4_K_M.gguf
    Cache Key: a3b8c9d4e5f67890
    Path: /models/a3b8c9d4e5f67890/model.gguf
  11. Understand the Foreman Reviewer Agent workflow

    main

    The Foreman Reviewer Agent is a pipeline step (Step 3) that follows the Coder Agent and the automated gate job. Its purpose is to perform a qualitative review of a code diff to determine if it addresses the intended issue in a way a human maintainer would accept.

    Workflow Context:

    1. Coder Agent: Produces a branch on a fork.
    2. Gate Job: Runs make fmt vet lint test and codegen-sync against that branch.
    3. Reviewer Agent: Evaluates the branch. If the gateVerdict is not GATE-PASS, the reviewer should still perform reads and provide a useful review, but must not approve the change.

    Input Payload: The agent receives the following data in its task payload:

    • repo: GitHub owner/name (e.g., defilantech/LLMKube)
    • issue: The integer issue number being addressed.
    • branch: The branch name on the fork (e.g., foreman/issue-510).
    • gateVerdict: Either GATE-PASS or GATE-FAIL.
    • coderSummary: A one-line summary provided by the coder.
  12. How LLMKube Grounding Checks Work

    main

    The LLMKube grounding check specifically scans added lines in documentation and example YAML to validate two types of project-owned symbols:

    1. API Groups: It flags apiVersion: declarations that name an LLMKube-owned API group not defined by any existing CRD (e.g., it would catch llmkube.io if the real group is inference.llmkube.dev).
    2. Metric Tokens: It flags llmkube_* metric tokens that are not registered anywhere in the repository.

    If a reference is flagged, the gate fails and provides specific feedback to the coder, allowing them to fix the citation before a reviewer sees it.

    # A correct example that passes the grounding check:
    apiVersion: inference.llmkube.dev/v1alpha1
    kind: InferenceService
    metadata:
      name: my-service
    spec:
      modelRef: my-model