Skip to content

docs(k8s): name the k3s add-ons and the real spend-log cleanup time #5071

Closed

Description

@dan-petty

Problem Description

Pull requests #5055 and #5048 added three statements that are wrong or incomplete on main:

  1. The GitOps section of k8s/README.md names CoreDNS as the only object that k3s, not git, holds. The line above it says: "An object in the cluster that git does not hold is drift: remove it, or add it to git." The k3s server holds 12 packaged add-ons. A reader who applies the drift rule can delete metrics-server.
  2. The CoreDNS paragraph has a sentence of 33 words. The STE rule (src/devops_cli/ai/tasks/style_ste100.md) permits 25 words in a description. The paragraph also names dan-petty/homelab#344 as future work, and that text becomes wrong when dan-petty/homelab#344 merges.
  3. The comment in k8s/llm/gateway/config.yaml, the Spend logs item of k8s/README.md and the docstring of check_the_gateway_keeps_its_spend_logs_for_30_days say that the gateway deletes old spend logs "once a day". LiteLLM starts the cleanup 24 hours after each start of the gateway process, and the gateway restarts more frequently than that.

Reproduction Steps

  1. Run kubectl -n kube-system get addon (read only).
  2. Read the GitOps section of k8s/README.md.
  3. Read litellm/proxy/proxy_server.py of LiteLLM v1.103.10, lines 10347 to 10388, and litellm/proxy/common_utils/scheduled_job_stagger.py, line 4.
  4. Query Prometheus: max by (pod) (last_over_time(kube_pod_start_time{namespace="llm", pod=~"llm-gateway-[a-z0-9]+-[a-z0-9]{5}"}[14d])).

Expected vs Actual Behavior

Expected: the documents state the objects that k3s holds and the real time of the spend-log cleanup.

Actual:

  • kubectl -n kube-system get addon lists 12 add-ons: coredns, ccm, rolebindings, runtimes, gateway-api-crd and seven metrics-server add-ons (aggregated-metrics-reader, auth-delegator, auth-reader, metrics-apiservice, metrics-server-deployment, metrics-server-service, resource-reader). k8s/README.md names only coredns, and git grep metrics-server k8s/README.md finds nothing.
  • LiteLLM adds the job spend_log_cleanup_job with an "interval" trigger. The interval is maximum_spend_logs_retention_interval (default 1d) plus 0 to 60 seconds (proxy_server.py line 10376). APScheduler sets the first run at the start time plus the interval (scheduled_job_stagger.py line 4), and the stagger only adds an offset. A process that stops before 24 hours does not run the cleanup.
  • 23 gateway pods started in the 14.5 days to 2026-11-12, and 18 of them lived less than 24 hours. One more container restart occurred (kube_pod_container_status_restarts_total). Thus the cleanup ran about 8 times, not 14. The longest time between two runs was about 73 hours.

Retention Risk

The 30-day value holds, but with a delay. One run deletes up to 500 batches of 1,000 rows (SPEND_LOG_RUN_LOOPS and SPEND_LOG_CLEANUP_BATCH_SIZE in litellm/constants.py). The table gets about 10,000 rows a day, so a late run removes all rows older than 30 days.

No limit stops a long time with no run. If each gateway process stops before 24 hours, no cleanup runs, and the database grows by about 50 MB a day. The litellm database is 315 MB now (cnpg_pg_database_size_bytes). GatewayDatabaseNearClaim warns at 80% of the 5 GiB claim. Thus the risk is low, and an alert shows it before the claim fills.

Proposed Fix

  • Write the drift exception for all k3s packaged add-ons, with CoreDNS as one case, and name the command that lists them.
  • Split the sentence of 33 words. Remove the reference to dan-petty/homelab#344 and keep the fact.
  • In the three places, state that the cleanup runs 24 hours after each start of the gateway process, then each 24 hours while the process runs.
  • This item does not set maximum_spend_logs_cleanup_cron. A fixed schedule changes the behavior of the gateway, and the measured delay of about 3 days does not put the claim at risk.

Environment Diagnostics

Homelab k3s cluster, server v1.37.2+k3s1. Gateway image ghcr.io/berriai/litellm:v1.103.10. Data: read-only kubectl get and Prometheus through Grafana, 2026-11-12.

Acceptance Criteria

  • k8s/README.md names the k3s packaged add-ons as the exception to the drift rule, with CoreDNS as one case and the command that lists them.
  • No changed sentence has more than 25 words, and the CoreDNS paragraph names no open issue.
  • The comment in k8s/llm/gateway/config.yaml, the Spend logs item of k8s/README.md and the gate-check docstring state that the cleanup runs 24 hours after each start of the gateway process.
  • uv run devops ci --check --only docs,k8s,openspec passes.

Source: #5055

Activity

  1. added
    source/agent
    type/docs
    scope/k8s
    status/new
    value/medium
    effort/low
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 12, 2026
  4. removed
    status/in-review
    owner/agent
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/k8ssource/agenttype/docsvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions