Skip to content

feat(k8s): enable squid caching forward proxy cluster-wide and resolve root ca - #143

Merged
dan-petty merged 5 commits into
release/v0.2.16from
feat/k8s-squid-proxy-enablement
Sep 11, 2026
Merged

dan-petty merged 5 commits into
release/v0.2.16from
feat/k8s-squid-proxy-enablement

Conversation

@dan-petty

@dan-petty dan-petty commented Sep 11, 2026 •

Copy link
Copy Markdown
Owner

Summary & Context

This PR enables full Squid caching forward proxy functionality cluster-wide with Store-ID content-addressable layer normalization and container loopback rewriting, resolves pod restarts on gpu-feature-discovery and the Prometheus monitoring stack with Burstable QoS resource allocations, provisions root CA trust distribution, adds CLI model overrides for devops ai chat, and incorporates the high-throughput LLM gateway / vLLM roadmap deliverables.

Resolves #135, #141. Relates to #142.

Key Changes

1. Kubernetes & Squid Caching Forward Proxy

  • Store-ID URL Rewriter for Content-Addressable Blobs: Added /etc/squid/storeid_rewrite.conf powered by store_id_program /usr/lib/squid/storeid_file_rewrite to rewrite ephemeral presigned Cloudflare R2 / S3 URLs to canonical SHA-256 keys (http://ollama-cache.local/blobs/sha256/<hash>), enabling true cross-node cache hits (TCP_HIT).
  • Loopback & Localhost Container Rewriter: Mounted /etc/squid/url_rewrite.pl via url_rewrite_program to intercept client requests to 0.0.0.0:11434 and 127.0.0.1:11434 from container CLI tools and rewrite the destination to the caller pod IP (http://<client_ip>:11434), eliminating proxy connection drops without requiring blanket cluster exclusions.
  • NetworkPolicy & TLS Splicing: Updated k8s/squid/networkpolicy.yaml to allow in-cluster pod/service egress across all namespaces and local LAN nodes (192.168.0.0/16). Configured ssl_bump splice to_localnet and expanded SSL_ports (8443, 11434, 8080) to pass internal traffic without certificate interception.
  • Ollama DaemonSet Proxy Enablement: Configured clean HTTP_PROXY, HTTPS_PROXY, and NO_PROXY: localhost,127.0.0.1 with node-local NVMe storage (hostPath: /var/lib/ollama). Verified model pulls stream through Squid and cache cleanly across GPU nodes.
  • Squid Hardening & Security Controls: Enabled strip_query_terms on to scrub SAS tokens and credentials from logs, routed access logs to /var/log/squid/access.log tailed to stdout, and made squid-ca-secret a required, non-optional volume.

2. Pod Restart Remediation & Burstable QoS Allocation

  • gpu-feature-discovery: Fixed recurring kernel OOM kill terminations (Exit Code 255) under node memory pressure caused by BestEffort QoS (oom_score_adj: 1000). Authored declarative DaemonSet manifest (k8s/gpu-feature-discovery/daemonset.yaml) with requests: {cpu: 50m, memory: 64Mi} and limits: {cpu: 200m, memory: 256Mi}, elevating it to Burstable QoS.
  • Prometheus Monitoring Stack: Updated k8s/monitoring/prometheus-values.yaml:
    • Prometheus Core: Increased memory request from 512Mi to 1024Mi (above baseline 578Mi TSDB footprint), set generous limits.memory: 4096Mi, and removed CPU limits to prevent scrape CPU throttling.
    • Node Exporter: Configured requests: {cpu: 50m, memory: 64Mi} and limits: {cpu: 200m, memory: 256Mi}, resolving repeated OOM kills across worker nodes.
    • Grafana & Kube-State-Metrics: Elevated memory requests and limits to support continuous dashboarding and metric export.
  • Live Cluster Rollout: All DaemonSets, Deployments, and StatefulSets patched and rolled out cleanly with 0 restarts.

3. AI Chat Model Resolution & CLI Overrides

  • CLI Model Override: Added --model / -m option to devops ai chat command.
  • Unified Client Interface: Exposed @property def model(self) -> str: on LLMClient.
  • Prewarming & Header Formatting: Corrected devops ai chat prewarming logs and section headers to dynamically resolve the client's actual model instead of global settings.

4. Roadmap & Task Grounding

Verification

  • All 10 CI Gates Passed: Version, Pytest (528 tests), Coverage ($\ge 90%$), Ruff Lint, Ruff Format, Strict Mypy (py3.14), Dependency Audit, Security Scanning, Actionlint, and Docs.
  • In-Cluster Validation: Verified Squid Store-ID layer normalization, loopback URL rewriting, and healthy 0-restart pod status across all nodes.

Copilot AI lite review requested due to automatic review settings September 11, 2026 06:37
@dan-petty dan-petty added this to the v0.2.16 milestone Sep 11, 2026
@dan-petty dan-petty added type/infra Type infra: the build, CI, images or cluster scope/ai AI review pipeline, personas, prompts, LLM client, or RAG scope/k8s Kubernetes commands, Helm charts, pods, services, and policies priority/p1-high Priority P1: high-impact work for the next planned milestone labels Sep 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical CA, caching, and storage issues, along with a moderate rollout issue, remain unresolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR enables Squid proxying and caching for Ollama, adds AI chat model overrides, and documents future LLM gateway work.

Changes:

  • Updates Squid logging, caching, exporter, and CA configuration.
  • Enables Ollama proxy trust with node-local model storage.
  • Adds devops ai chat --model, tests, documentation, and task tracking.
File summaries
File Summary
tests/test_k8s_squid.py Updates Squid logging assertions.
tests/test_ai_cmd.py Tests model overrides and client model behavior.
src/devops_cli/commands/ai.py Adds chat model override handling.
src/devops_cli/ai/client/unified.py Exposes the active model property.
k8s/squid/docker/entrypoint.sh Streams Squid access logs.
k8s/squid/deployment.yaml Updates exporter configuration.
k8s/squid/configmap.yaml Critical (2 votes): Cache rules may retain private or revoked objects. Critical (1 vote): Raw URLs may expose credentials in logs. Nits (2, 1 votes): Update operator documentation and add cache-rule tests.
k8s/squid/ca-configmap.yaml Critical (3 votes): The published CA lacks its corresponding private key, allowing clean deployments to generate a mismatched CA.
k8s/llm/ollama-daemonset.yaml Critical (1 vote): Replacing NFS with node-local storage can hide existing models and caches. Moderate (1 vote): Add assertions for the hostPath storage contract.
k8s/llm/ca-configmap.yaml Moderate (1 vote): CA updates do not refresh existing subPath mounts without a rollout.
docs/ROADMAP.md Nit (1 vote): Scope the description to planning or include the promised gateway and vLLM implementation.
docs/commands/ai.md Documents the --model option.
docs/CLI_REFERENCE.md Updates CLI reference documentation.
docs/agent/tasks/task-142-llm-gateway-distributed-router.md Moderate (2 votes): Change the task status from Backlog to In Review.
docs/agent/tasks/task-141-squid-proxy-cluster-enablement.md Nits (1 vote each): Generalize the private registry address and replace the TBD PR field.
Review details

Suppressed comments (6)

docs/ROADMAP.md:331

  • The PR description says it incorporates the LLM gateway/vLLM roadmap deliverables, but this change only adds the roadmap specification and a backlog checklist: no gateway or vLLM manifests, dynamic router, or FastMCP tools are present, and issue #142's acceptance criteria remain unchecked. Either scope the description to planning or include the promised implementations.
### High-Throughput LLM Gateway, vLLM Tensor Parallelism & Distributed Inference Mesh (v0.2.18 - Scheduled)

docs/agent/tasks/task-141-squid-proxy-cluster-enablement.md:40

  • This repeats the concrete RFC1918 registry address in public task documentation. Generalize the registry host here as required by AGENTS.md:22, rather than recording an environment-specific private endpoint in the completed checklist.
- [x] Build and push `192.168.1.4:30500/squid:0.2.16` to in-cluster registry.

docs/agent/tasks/task-141-squid-proxy-cluster-enablement.md:4

  • This task is marked In Review, but its PR field remains TBD. The task-file format requires the active PR number for an open review (docs/agent/tasks/README.md:40-45); replace the placeholder before merging so the tracking record is linked to this PR.
**PR**: TBD

k8s/llm/ca-configmap.yaml:16

  • Updating this ConfigMap does not update an existing ConfigMap volume mounted with subPath in ollama-daemonset.yaml. After a CA rotation, running Ollama pods keep the old certificate while Squid reads the new keypair, so proxy TLS fails until every pod is manually restarted. Mount the directory instead or add a guaranteed DaemonSet rollout whenever the CA changes.
    MIIDjTCCAnWgAwIBAgIUQcYyk9HO3bO28v24K7Zhs/NIzRwwDQYJKoZIhvcNAQEL
    BQAwVjEnMCUGA1UEAwweRGV2T3BzIENMSSBJbi1DbHVzdGVyIFNxdWlkIENBMRMw
    EQYDVQQKDApEZXZPcHMgQ0xJMRYwFAYDVQQLDA1DYWNoaW5nIFByb3h5MB4XDTI2
    MDkxMTA2MDM1MloXDTM2MDkwODA2MDM1MlowVjEnMCUGA1UEAwweRGV2T3BzIENM

k8s/llm/ollama-daemonset.yaml:107

  • Switching from NFS to a node-local hostPath changes model persistence and cache behavior per GPU node, but the existing manifest tests never guard this storage contract. Add an assertion for /var/lib/ollama and DirectoryOrCreate so a future change cannot silently restore or alter the persistence model.
          hostPath:
            path: /var/lib/ollama
            type: DirectoryOrCreate

k8s/squid/configmap.yaml:108

  • The new cache rules are not covered by test_squid_conf_caching_and_observability_directives, which only asserts the pre-existing /v2/.*/blobs/sha256: rule. Add assertions for the new slash-form blob and R2 patterns so a regression in these cache paths cannot pass the suite.
    refresh_pattern -i .*/blobs/sha256/.* 525600 100% 525600 override-expire override-lastmod ignore-no-cache ignore-no-store ignore-reload ignore-private
    refresh_pattern -i .*\.r2\.cloudflarestorage\.com/.* 525600 100% 525600 override-expire override-lastmod ignore-no-cache ignore-no-store ignore-reload ignore-private
  • Files reviewed: 15/15 changed files
  • Comments generated: 6
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread k8s/llm/ollama-daemonset.yaml Resolved
Comment thread k8s/squid/ca-configmap.yaml Resolved
Comment thread k8s/squid/configmap.yaml Resolved
Comment thread k8s/squid/configmap.yaml Resolved
Comment thread k8s/squid/configmap.yaml Resolved
@dan-petty
dan-petty merged commit 0e597c4 into release/v0.2.16 Sep 11, 2026
4 checks passed
@dan-petty
dan-petty deleted the feat/k8s-squid-proxy-enablement branch September 11, 2026 14:26
dan-petty added a commit that referenced this pull request Sep 12, 2026
* docs(changelog): document v0.2.15 release highlights and features (#105)

* docs(changelog): document v0.2.15 release highlights and features

* docs(changelog): clarify k8s logs invocation and list all 11 security scanners

* docs(agents): update agent instructions to honor API rate limits and quotas (#130)

* docs(agents): update agent instructions to honor API rate limits and quotas

- Add API rate limiting, complexity budgeting, and quota guidelines to AGENTS.md across core engineering, GitHub integration, and AI inference.
- Synchronize DEVOPS_CLI_AGENTS_METADATA_TEMPLATE in instruction_generator.py with rate-limiting rules.
- Add regression test assertions to test_instruction_generator.py.
- Track deliverable in task-129-agent-instructions-rate-limits.md.

Closes #129

* docs(agents): include AI inference rate limits and expand generator test assertions

* docs(agents): make semaphore example executable and link PR in task tracking

* feat(ai): render chat persona title in orange styling (#133)

* feat(ai): render chat persona title in orange styling

- Render persona title in bold dark_orange in chat section header rule
- Output persona reply prompt in bold dark_orange using Rich console
- Preserve bold cyan styling for 'You:' user prompt
- Update unit tests in test_ai_cmd.py asserting persona and user prompt colors

Closes #132

* test(ai): assert dark_orange section header styling and update task status to In Review

* fix(k8s): review pod restarts, eliminate cgroup oom kills, and optimize workload resource limits (#136)

* fix(k8s): review pod restarts, eliminate cgroup oom kills, and optimize workload resource limits

- Remove hard memory limits on Ollama DaemonSet (leaving requests at 3000m CPU and 8Gi RAM), allowing dynamic memory bursting into available node RAM without cgroup OOM kills
- Add startupProbe to Ollama DaemonSet with 5-minute failure threshold for cold starts and large model weight loading
- Relax Ollama livenessProbe (10s timeout, 15s period, 6 failure threshold) to prevent premature kubelet SIGKILL terminations during heavy inference
- Raise memory and CPU limits across core workloads (ArgoCD controller, repoServer, server, and Redis; Valkey; Jaeger; Registry; Fluent Bit; and Loki)
- Add comprehensive regression tests in tests/test_k8s.py verifying resource limit invariants and probe resilience
- Create task tracking document docs/agent/tasks/task-135-k8s-pod-restarts-resource-limits.md

Closes #135

* fix(k8s): bound Ollama memory limit, enforce probe contracts, and assert all resource changes

* feat(k8s): deploy squid caching proxy with ssl bump, observability, and failover handling (#134)

* feat(k8s): deploy squid caching proxy with ssl bump, observability, and failover handling

- Deploy high-capacity Squid caching proxy configured for 100GB single objects
- Enable SSL-Bump TLS interception with dynamic cert generation for Ollama 70B layers
- Add Prometheus observability via squid-exporter sidecar on port 9301
- Enable structured JSON access logging to stdout and Cache Manager API
- Implement LFUDA dynamic aging eviction with proactive high/low watermarks (92%/85%)
- Integrate Squid proxy env vars and CA certificate mount in ollama-daemonset
- Document failover architecture across node crash, WAN outage, and storage domains
- Add comprehensive unit test suite in test_k8s_squid.py

Closes #131

* fix(docker): format and sort imports in _client helper

* refactor(k8s): relocate squid docker assets to k8s/squid/docker to prevent SDK namespace shadowing

* feat(k8s): add condor node affinity for high-capacity 1.8TB NVMe storage allocation

* fix(docker): format import order in client builder

* fix(k8s): resolve review feedback on squid probes, egress policy, ca sync, and chown

* feat(docs): implement document compaction engine and enhance review self-improvement loop (#138)

* feat(docs): implement document compaction engine and enhance review self-improvement loop

- Author DocCompactor engine supporting roadmap, release notes, and log compaction
- Integrate devops docs compact subcommand with check, dry-run, and series filtering
- Expose docs_compact tool on FastMCP server and synchronize MCP JSON schemas
- Harden reference extractor to exclude glob patterns, examples, and stdlib prefixes
- Resolve executive summary reporting error handling for skipped and errored files
- Enhance review prompts and system instructions for closed-loop self-improvement
- Constrain Loki logging NetworkPolicy ingress to ingress-nginx controller
- Add comprehensive test suites for compaction engine and MCP tools

Closes #137

* fix(docs): resolve review feedback on error sanitization, path containment, and syntax boundaries

- Sanitize and bound error strings in pipeline errored_files registry to <= 256 chars
- Enforce strict regex validation and archive directory containment for release series
- Use negative lookbehind boundaries for secret tokens to support underscore identifiers
- Restore process dry-run state via try/finally in docs compact CLI command
- Refine log header version extraction and eliminate hardcoded series strings
- Populate roadmap and release notes section counters in DocCompactionResult
- Truncate caller-provided details in DocCompactionError to 256 characters
- Replace hardcoded package prefixes with dynamic importlib package introspection

* feat(ai): format chat responses as rich markdown and failover ollama models

* docs(roadmap): add agentic sandbox iteration architecture tasks

* feat(k8s): enable squid caching forward proxy cluster-wide and resolve root ca (#143)

* feat(k8s): enable squid caching forward proxy cluster-wide and resolve root ca

* feat(ai): support chat model cli overrides and map llm gateway to roadmap

* fix(k8s): address copilot review on squid proxy security and ca rotation

* feat(k8s): enable in-cluster squid proxying, store-id caching, and loopback rewriting

* fix(k8s): resolve pod restarts on gpu-feature-discovery and prometheus stack with burstable qos

* docs(agent): reconcile task lifecycles for v0.2.16 milestone release merge

* docs(devcontainer): align devcontainer usage guide with modern best practices (#145)

* docs(devcontainer): align devcontainer usage guide with modern best practices

* docs(devcontainer): address peer review feedback and improve configuration examples

* docs: remove obsolete development log and redundant pending features docs (#146) (#147)

* docs: remove obsolete development log and redundant pending features docs (#146)

* docs(agent): update task 146 status to in review with PR #147

* docs(routine): distinguish docs compaction from manual task archival

* refactor(core): decouple circular module imports and streamline convoluted import patterns (#148) (#149)

* refactor(core): decouple circular module imports and streamline convoluted import patterns (#148)

* fix(test): resolve child module import edges in invariant check and decouple config settings (#148)

* fix(k8s): route stack lifecycle run_subprocess and forward patches to _stack_lifecycle (#148)

* docs(architecture): document pre-1.0 alpha status, zero legacy remnants, and post-1.0 semver policy (#150) (#151)

* docs(architecture): document pre-1.0 alpha status, zero legacy remnants, and post-1.0 semver policy (#150)

* docs(security): sanitize homelab configurations and align release manuals with pre-1.0 alpha policy

- Fix Copilot review feedback on RELEASE_CYCLE.md: use generic SemVer placeholders X.Y.0 and X.Y.Z
- Fix Copilot review feedback on knowledge base: qualify release_management.md and release_engineering_and_semver_governance.md with pre-1.0 alpha zero backwards compatibility policy vs post-1.0 SemVer 2.0.0 governance
- Sanitize internal hostnames, RFC 1918 IPs, and hardware mount paths across k8s/squid/deployment.yaml, tests/test_k8s_squid.py, docs/ROADMAP.md, docs/squid-failover-and-observability.md, and docs/agent/tasks/
- Update AGENTS.md and instruction_generator.py with comprehensive prohibitions against recording internal infrastructure details
- Ground changes in Issue #152 and docs/agent/tasks/task-152-sanitize-internal-systems-and-strengthen-instructions.md

* docs(security): gate pre-1.0 alpha notice on devops-cli and sanitize cluster network docs (#152) (#153)

* docs(security): gate pre-1.0 alpha notice on devops-cli and sanitize cluster network docs (#152)

- Gate pre-1.0 alpha notice on meta.is_devops_cli across generate_pointer_stub, generate_instruction_content, and generate_agents_md so external scaffolded projects do not receive DevOps CLI-specific alpha notices
- Update test_instruction_generator.py to verify is_devops_cli gating behavior on pointer stubs and AGENTS.md
- Sanitize LAN speed reference in docs/squid-failover-and-observability.md to local cluster network speed
- Update task tracking in docs/agent/tasks/task-152-sanitize-internal-systems-and-strengthen-instructions.md

* docs(agent): update task-152 PR reference to #153

* test(ai): assert absence of pre-1.0 alpha lifecycle block for generic external projects

* fix(security): remediate devsecops findings and consolidate embedding configuration (#154) (#155)

* fix(security): remediate devsecops findings and consolidate embedding configuration (#154)

- Remediate review session findings for credential leakage, injection, and resource exhaustion
- Consolidate embedding configuration under ai.tasks.embedding and remove duplicate keys from rag
- Add offline fallback to tldextract and test-wide network egress guard
- Protect local user runtime config.yaml from automated sanitization rewrites
- Enhance review falsification rules, feedback export, and common hallucinations catalog

* fix(security): remediate pr 155 review comments and exclude documented example network references (#154)

* docs(roadmap): add milestones v0.2.19, v0.2.20, and v0.2.21, and mark task 154 complete

* chore(release): bump version to v0.2.16 and finalize changelog

* feat(sandbox): implement long-running workload sandbox lifecycle engine (#157)

* feat(sandbox): implement long-running workload sandbox lifecycle engine

* docs(agent): update task 106 tracking to In Review with PR 157

* feat(sandbox): remediate pr review findings, update agent instructions, and resolve threads

* fix(sandbox): address bandit b108 tmpfs mount false positive and format

* docs(roadmap): reprioritize roadmap and redistribute features across v0.2.17-v0.2.19

* feat(ci): automatically apply formatting and linting across CLI and CI commands (#159)

* feat(ci): automatically apply formatting and linting across CLI and CI commands (#158)

- Default --fix to True on devops ci, devops ci format, and devops ci lint
- Support --check flag for non-mutating validation
- Introduce top-level devops format and devops lint CLI commands with clean usage
- Move _layouts/ and assets/ to docs/ for Jekyll GitHub Pages compliance
- Prevent event loop deadlock in introspect_mcp_tools and offload check_docs
- Update test suites, architectural invariants, and documentation

* fix(docs): address PR 159 review comments on executor cleanup, alias docs, and jekyll layout

- Introspect leaf command aliases directly so devops format and devops lint generate clean leaf command usage rather than inheriting all ci subcommands
- Implement non-blocking thread pool executor cleanup with wait=False, cancel_futures=True and asyncio.wait_for in introspect_mcp_tools
- Remove /docs/ prefix in docs/_layouts/default.html navigation and footer links to prevent 404s on GitHub Pages
- Configure default layout in docs/github-pages.config.yaml for Jekyll markdown pages
- Synchronize task tracking and regenerate documentation

* chore(tasks): mark task-158 as done upon PR #159 merge

* fix(release): add release notes extraction fallback and enforce changelog version check (#140, #160)

Resolves release orchestration failures where release notes extraction fails due to missing version headers or changelog discrepancies:
- Strictly enforce matching version in CHANGELOG.md during devops release check (fatal Exit 1)
- Implement layered fallback extraction across CHANGELOG.md -> docs/RELEASE_NOTES.md -> git commit log
- Defensive fallback to git commit log in .github/workflows/release.yml
- Decompose release_check to maintain cyclomatic complexity <= 10
- Comprehensive unit tests in tests/test_release.py

* chore(tasks): mark task-140 as done upon PR #160 merge

* docs(release): update v0.2.16 changelog and release notes highlights

* fix(review): address PR 161 comments on sandbox port allocation, secret lookbehind, and gfd image

* fix(sandbox): align requested_ports type annotation in SandboxRegistry with allocate_ports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/p1-high Priority P1: high-impact work for the next planned milestone scope/ai AI review pipeline, personas, prompts, LLM client, or RAG scope/k8s Kubernetes commands, Helm charts, pods, services, and policies type/infra Type infra: the build, CI, images or cluster

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants