Repository navigation
feat(k8s): configurable k8s context setting and conditional minikube autostart (#172) - #174
Conversation
4fcbab3 to
034de21
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Critical and moderate issues remain in context targeting, startup behavior, validation, persistence, and configuration wiring.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds configurable Kubernetes context selection and conditional Minikube autostart across CLI configuration, DevContainers, runtime behavior, documentation, and tests.
Changes:
- Adds
k8s.contextconfiguration and environment support. - Adds context-aware Minikube startup and fallback behavior.
- Updates DevContainer workflows, documentation, knowledge-base content, and tests.
File summaries
| File | Change / review finding |
|---|---|
tests/test_k8s.py |
Updates context-switch tests; no issues noted. |
tests/test_k8s_context.py |
Adds configuration and autostart tests. Nit (1 vote): create cfg_file before setting DEVOPS_CLI_CONFIG to avoid testing global configuration. |
tests/test_devcontainer.py |
Tests conditional lifecycle startup; no issues noted. |
src/devops_cli/templates/devcontainer.json.j2 |
Removes forced Minikube autostart; no issues noted. |
src/devops_cli/config/settings.py |
Adds Kubernetes settings schema. Moderate (1 vote): k8s.context is not wired to k8s status, which still uses the current kubeconfig context. |
src/devops_cli/config/options.py |
Adds the context option. Moderate (1 vote): K8S_CONTEXT is omitted from CONFIG_OPTIONS. |
src/devops_cli/config/env.py |
Registers the environment mapping; no issues noted. |
src/devops_cli/commands/k8s/cluster_runtime.py |
Adds startup, fallback, and context resolution. Critical (3 votes): probing the configured context can differ from the context used by subsequent operations. Moderate (2 votes): unreadable configuration silently defaults to Minikube. Nit (1 vote): GPU-to-CPU fallback lacks regression coverage. |
src/devops_cli/commands/k8s/cluster_context.py |
Adds context switching. Moderate (3 votes): RFC 1123 validation rejects EKS/GKE context names. Moderate (2 votes): dry-run still probes Minikube. Moderate (3 votes): persistence exceptions are swallowed. |
src/devops_cli/commands/k8s/bootstrap.py |
Updates Kubernetes bootstrap integration; no issues noted. |
src/devops_cli/commands/k8s/__init__.py |
Exports runtime helpers; no issues noted. |
src/devops_cli/commands/devcontainer.py |
Gates post-start bootstrap. Moderate (3 votes): the primary workflow still uses the older GPU-only startup helper, so the documented CPU fallback is not applied. |
src/devops_cli/commands/config.py |
Displays Kubernetes context configuration; no issues noted. |
src/devops_cli/ai/knowledge_base/it_domains/topics/cloud_native_kubernetes_and_gitops.md |
Adds multi-cluster guidance; no issues noted. |
src/devops_cli/ai/knowledge_base/it_domains/tools/minikube.md |
Documents conditional startup; no issues noted. |
src/devops_cli/ai/knowledge_base/it_domains/tools/kubectl.md |
Documents context routing. Nit (1 vote): claims switch-context verifies connectivity, but it only changes the kubeconfig context. |
src/devops_cli/ai/knowledge_base/devops_cli/tasks/k8s_stack_deployment.md |
Updates deployment workflow; no issues noted. |
src/devops_cli/ai/knowledge_base/devops_cli/tasks/devcontainer_lifecycle.md |
Updates lifecycle guidance; no issues noted. |
README.md |
Updates CLI reference text; no issues noted. |
docs/ENV_VARS.md |
Documents the new environment variable; no issues noted. |
docs/DEVCONTAINER_USAGE.md |
Adds topology and connectivity guidance. Nit (3 votes): ai.allow_private_network does not configure Kubernetes network access. Nit (1 vote): documented CPU/memory flags are not passed by implementation. |
docs/CONFIGURATION.md |
Documents Kubernetes configuration; no issues noted. |
docs/commands/k8s.md |
Updates context-switch documentation; no issues noted. |
docs/CLI_REFERENCE.md |
Updates generated CLI reference; no issues noted. |
docs/agent/tasks/task-172-k8s-context-minikube-autostart.md |
Tracks implementation details. Nit (2 votes): lifecycle state should be In Review, not In Progress. |
docs/agent/task.md |
Adds the task index entry. Nit (3 votes): replace TBD with the PR link. |
config.example.yaml |
Adds the default Kubernetes context; no issues noted. |
.devcontainer/devcontainer.json |
Removes forced Minikube autostart; no issues noted. |
Review details
Suppressed comments (6)
docs/DEVCONTAINER_USAGE.md:404
- The documented command includes
--cpus=4 --memory=8192, but the implementation in_start_minikubeonly passes--driver=dockerand optionally--gpus=all. As written, this example promises resource settings that are never applied; either implement those flags or make the example match the actual start command.
minikube start --driver=docker --gpus=all --cpus=4 --memory=8192
src/devops_cli/ai/knowledge_base/it_domains/tools/kubectl.md:15
- This new description says
switch-contextverifies external cluster connectivity, but the implementation only runskubectl config use-contextand never probes the selected API server. Either add a bounded connectivity check or remove that claim from the knowledge base.
- `devops k8s switch-context`: Switches active kubeconfig context, updates `k8s.context` setting, autostarts Minikube if stopped and targeted, or verifies external cluster connectivity.
src/devops_cli/commands/k8s/cluster_runtime.py:73
- The new GPU-to-CPU fallback branch is not covered by the added tests: the switch tests mock successful subprocesses and never exercise a failed GPU start followed by a CPU retry. Add a regression test for that path so the advertised fallback cannot regress unnoticed.
start_res = _run_cmd(["minikube", "start", "--driver=docker", "--gpus=all"], check=False)
if start_res.returncode == 0 and _minikube_running():
_run_cmd(["minikube", "update-context"], check=False)
return True, f"Started Minikube cluster{gpu_suffix}"
src/devops_cli/config/options.py:75
- The new key is declared here but is omitted from the
CONFIG_OPTIONStuple below (lines 95-165), which is the repository's supported-option registry. Any consumer that enumerates that registry will omitk8s.context, so addK8S_CONTEXTthere as well as in the environment mapping.
K8S_CONTEXT = "k8s.context"
src/devops_cli/config/settings.py:397
- Adding
k8s.contextto the settings schema does not wire it todevops k8s status:status()still callsload_kube_config()without a context incluster_context.py:104-108, so it queries the kubeconfig's current context rather than the configured target. Pass the effective configured context to the status client and add a regression test.
k8s: KubernetesConfig = KubernetesConfig()
tests/test_k8s_context.py:113
- Because
cfg_fileis never created,_find_project_config_path()ignoresDEVOPS_CLI_CONFIGandsave_settings()falls back to the process-wide config path. This test can mutate a global/user config and its get/show assertions do not prove persistence totmp_path. Create an empty config file before setting the environment variable.
cfg_file = tmp_path / "config.yaml"
monkeypatch.setenv("DEVOPS_CLI_CONFIG", str(cfg_file))
- Files reviewed: 28/28 changed files
- Comments generated: 9
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
* feat(release): v0.2.17 * feat(sandbox): protocol-agnostic endpoint readiness and health probing subsystem (#107) Closes #107 * docs(agent): reconcile task 107 tracking to done (#107) * feat(telemetry): cgroup v2 metrics collection and prometheus application scraping (#108) Closes #108 * docs(agent): reconcile task 108 to done following PR #164 merge * docs(agent): require draft pull requests for in-progress work (#165) (#166) * docs(agent): require draft pull requests for in-progress work (#165) * docs(agent): align lifecycle definitions and update task index for PR #166 * fix(sandbox): resolve cpu delta sampling, ssrf boundaries, and cgroup fallback (#168) * fix(sandbox): remediate pr 164 review findings on sandbox metrics collection (#167) * test(sandbox): normalize whitespace in help assertion for variable terminal widths * test(sandbox): assert help option text without border wrapping sensitivity * fix(sandbox): address pr 168 review comments on url sanitization and telemetry contracts (#167) * fix(sandbox): resolve pr 168 review comments on cpu delta sampling, ssrf boundaries, and cgroup fallback (#167) * test(sandbox): remove redundant comment header in metrics tests * feat(pr): monitor pr checks, copilot reviews, and review threads (#170) (#171) * feat(github): automated pr monitoring and copilot review verification (#170) * fix(pr): resolve copilot review findings and enforce 5m/60s monitoring standards (#170) * feat(k8s): configurable k8s context setting and conditional minikube autostart (#172) (#174) * feat(k8s): configurable k8s context setting and conditional minikube autostart (#172) * docs(k8s): document minikube devcontainer lifecycle and external cluster configurations (#172) * fix(k8s): resolve copilot review findings for context validation and autostart (#172) * test(k8s): update qdrant secret lifecycle assertion for effective context flag (#172) * fix(github): project field options sync, complete pagination, generic owner resolution, and mock hostname standardization (#175) (#173) - Resolve automated GitHub Projects bot resetting status by auto-provisioning missing single-select options (e.g. 'In Review') - Implement complete pagination across projectsV2 items, issues, and PR endpoints - Resolve project owner dynamically via gh api user login without hardcoded usernames - Display draft PR warnings cleanly in monitor exit handler - Standardize all mock/dummy test values across all tests to example.com with no subdomain - Enforce complexity <= 10 and nesting <= 5 architectural invariants * fix(review): remediate devsecops findings and enhance review self-improvement loop (#176) (#177) * docs(agent): bootstrap task 176 for review findings remediation * fix(review): remediate DevSecOps findings and enhance review self-improvement loop (#176) * feat(telemetry): w3c traceparent propagation and distributed trace correlation (#109) (#178) * feat(telemetry): w3c traceparent propagation and distributed trace correlation (#109) * docs(agent): link draft PR 178 in task 109 tracking * fix(k8s): resolve helm ssa conflicts, loki validation, podsecurity, and qdrant permissions (#183) (#182) * fix(k8s): resolve helm ssa conflicts, loki validation, podsecurity, and qdrant permissions (#183) * docs(agent): link pull request #182 in task 183 tracking * feat(sandbox): streaming diagnostic log aggregator and panic detector (#110) (#179) * feat(sandbox): streaming diagnostic log aggregator and panic detector (#110) * docs(agent): link draft PR #179 in task-110 tracking * fix(sandbox): remediate review findings, demux streams, bound follow memory, and sanitize output (#110) * docs(agent): update task 110 status to In Review and record review thread resolutions * fix(github): gate pr merge readiness on required approvals, mergeable state, and reviewer feedback (#183) (#184) * fix(github): gate pr merge readiness on required approvals, mergeable state, and reviewer feedback (#183) * fix(github): remediate copilot review findings on pr merge readiness (#183) * fix(github): enforce review approval gate, exclude negative copilot headings, and forward tokens (#183) * fix(github): restrict copilot heading match, validate approval head sha, and support explicit env (#183) * fix(review): remediate DevSecOps findings and enhance review self-improvement loop (#185) (#186) * fix(github): gate pr merge readiness on required approvals, mergeable state, and reviewer feedback (#183) * fix(review): remediate session 20260913-060209 findings and enhance review self-improvement loop (#185) - sandbox probe: block metadata endpoints, bound regex len and search window, validate target URLs - telemetry waterfall: enforce hex trace ID validation and validate Jaeger endpoints against SSRF - telemetry context: add trace_flags parameter to generate_traceparent - sandbox logs: mask secrets in panic incidents and set 0o600 file / 0o700 dir permissions - sandbox metrics: reject cgroup path traversal and restrict parsing to valid cgroup hierarchies - sandbox models: truncate and mask probe result details and incident messages/stacktraces - sanitizer: mask secrets in non-flag arguments in sanitize_command_args_for_display - valkey client: correctly strip enclosing brackets from IPv6 hostnames - http client: validate timeout argument types - k8s stack lifecycle: mask non-localhost emails in bootstrap summary display - anti-hallucination dataset: calibrate false positives into common_hallucinations.json - documentation & prompts: update SELF_IMPROVEMENT.md, review.md, AGENTS.md, and task tracking * docs(agent): link pull request #186 in task 185 tracking * fix(review): address review feedback across sandbox, telemetry, k8s, and test fixtures (#185) - probe: canonicalize trailing dot and resolve host to block link-local/cloud metadata - waterfall: reject resolved metadata hosts and fix exception tuple in Jaeger trace query - k8s: mask short and malformed emails in bootstrap display and preserve PII in dry-run - pr monitor: exclude unknown mergeable_state from readiness and evaluate latest review per user - http client: raise HTTPTimeoutTypeError derived from ValidationError and TypeError - sandbox logs: unlink archive and raise SandboxError on incident chmod failure - sandbox metrics: enforce path-aware containment for cgroup v2 hierarchies - sandbox models: recursively sanitize nested details and reserve suffix length for truncation cap - telemetry context: raise TraceValidationError on invalid traceparent flags - conftest: detect and fail on unauthorized creation or deletion of workspace config.yaml - tasks: reconcile PR #184 mapping, update taxonomy to status/in-review, and re-sync index * fix(process): preserve GH_TOKEN and GITHUB_REPOSITORY for gh binary execution * fix(repo): prioritize git remote origin before GITHUB_REPOSITORY fallback * fix(security): pin vetted ip transports against dns rebinding and enforce clean merge state (#185) (#186) * feat(github): implement native devops cli functionality for gh operations and pr governance (#181) (#187) * feat(github): implement native devops cli functionality for gh operations and pr governance (#181) - Implement native devops pr ready, diff, and close subcommands - Implement native devops gh rate-limit and runs subcommands - Register FastMCP tools pr_ready, pr_diff, pr_close, gh_rate_limit, gh_runs_list, gh_run_view - Harden config discovery and add pytest safety barrier against workspace config mutations - Configure squid k8s deployment to use internal registry alias registry.local:5000 - Add comprehensive test coverage and documentation updates * feat(github): add REST fallbacks for pr view/checks, issues/pr edit, and resolve loki crashloop (#181) - Fall back to REST API in devops pr view and devops pr checks when GraphQL rate limits are exceeded - Add devops pr edit and devops gh issues edit subcommands - Register FastMCP tools pr_edit and gh_issue_edit - Disable loki-sc-rules sidecar in dev cluster k8s/logging/loki-values.yaml to eliminate k8s API watch crashloop - Add unit tests for pr/issue edit and REST fallbacks * docs(agent): link PR #187 in task 181 tracking * ci(workflows): gate pull request workflow on unresolved review threads and merge blockers (#188) - Update .github/workflows/ci.yml pull_request triggers to include ready_for_review - Add Verify PR Merge Readiness step to CI workflow calling devops pr check-readiness - Add devops pr check-readiness command and REST fallback for list_prs and list_threads - Add pr_check_readiness FastMCP tool and harden _run_mcp_cmd with mask_secrets - Sanitize output and validate formats in gh run view/list and pr view/checks/diff - Remediate and resolve 11 Copilot review findings across PR #187 * fix(process): preserve GH_TOKEN and GITHUB_REPOSITORY for gh binary execution * fix(repo): prioritize git remote origin before GITHUB_REPOSITORY fallback * fix(github): remediate review findings across pr readiness, sanitization, and rest fallbacks (#181) (#188) * fix(ci): support allow-blocked-state in pr check-readiness for github actions workflow * docs(agent): update task 181 checklist with passing ci checks and resolved review feedback * fix(github): add REST API fallback and rate limit handling for pr review threads (#180) (#189) (#191) * fix(github): add REST API fallback and rate limit handling for pr review threads (#180) (#189) * docs(agent): record PR #191 in task 180 tracking * docs(agent): require concise commit messages stating direct effect of change (#169) (#192) * fix(k8s): harden logging perimeter and scope fluent bit namespaces (#121) (#193) * chore(ci): align core dependencies and synchronize lockfile (#115) (#194) * feat(argo): implement automated gitops drift detection and watch command (#111) * feat(argo): implement automated gitops drift detection and watch command (#111) * fix(argo): address PR #195 review feedback on gitops webhook, secret masking, and baseline persistence * feat(github): declarative branch protection auditor and repository secret synchronization (#197) * feat(github): declarative branch protection auditor and repository secret synchronization * docs(agent): link PR #197 in task-114 tracking file * fix(github): lazily fetch public key during secret sync and isolate tests * chore(release): cut v0.2.17 and finalize release notes (#198) * feat(test): add deterministic async memory and connection pool profiler (#199) Implement deterministic async memory and connection pool profiler under devops test profile-memory (#199) Closes #199
Summary
Closes #172.
Implements configurable Kubernetes cluster context setting (
k8s.context) across devops-cli configuration and CLI commands. Adds conditional Minikube autostart logic so that Minikube only autostarts when configured as the active cluster context (or explicitly forced viaDEVOPS_MINIKUBE_AUTOSTART=true), and automatically launches Minikube if it is stopped when switching context tominikube.Additionally provides comprehensive documentation covering DevContainer Minikube workflows and external Kubernetes cluster connectivity across Docker Desktop, local clusters (
kind,k3s,k3d), and cloud-managed clusters (Amazon EKS, Google GKE, Azure AKS).Key Changes
k8s.contextsetting (KubernetesConfig) insrc/devops_cli/config/settings.pydefaulting to"minikube".K8S_CONTEXToption key andDEVOPS_CLI_K8S_CONTEXTenvironment variable.config.example.yamlanddevops config show.should_autostart_minikube()and_start_minikube()with hardware GPU passthrough and CPU fallback insrc/devops_cli/commands/k8s/cluster_runtime.py.devops devcontainer post-startinsrc/devops_cli/commands/devcontainer.pyto conditionally evaluate autostart."DEVOPS_MINIKUBE_AUTOSTART": "true"from.devcontainer/devcontainer.jsonand devcontainer template.devops k8s switch-context <name>to automatically launch Minikube when switching tominikubeif stopped, and synchronizedsettings.k8s.context.docs/DEVCONTAINER_USAGE.md.cloud_native_kubernetes_and_gitops.md,minikube.md,kubectl.md,devcontainer_lifecycle.md,k8s_stack_deployment.md).docs/CONFIGURATION.mdviadevops docs generate --sync-readme.Verification
tests/test_k8s_context.pytests/test_devcontainer.pytests/test_k8s.pytests/test_config*.pyuv run devops ci).