Skip to content

fix(k8s): require opt-in for default kubeconfig - #808

Merged
Mzack9999 merged 1 commit into
devfrom
fix/806-k8s-kubeconfig-opt-in
Oct 14, 2026
Merged

Mzack9999 merged 1 commit into
devfrom
fix/806-k8s-kubeconfig-opt-in

Conversation

@dogancanbakir

@dogancanbakir dogancanbakir commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Fixes #806

A block without kubeconfig_file/kubeconfig_encoded errors again unless use_default_kubeconfig: true is set; -ad sets it. An explicit path no longer runs the legacy ~/.kube/.kubeconfig migration.

Summary by CodeRabbit

  • New Features

    • The Kubernetes provider can now use kubectl-style kubeconfig lookup when use_default_kubeconfig is enabled. It checks $KUBECONFIG, then ~/.kube/config, and finally in-cluster credentials.
    • Kubernetes auto-discovery now enables this option, allowing it to find default credentials automatically.
  • Documentation

    • Clarified that default kubeconfig lookup is disabled unless explicitly enabled; otherwise, provide a kubeconfig file or encoded configuration.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 5894dc98-afe7-4716-825b-bfac49d50b6a
📥 Commits

Reviewing files that changed from the base of the PR and between 3ead704 and 7be30f9.

📒 Files selected for processing: 5
  • PROVIDERS.md
  • internal/runner/autodiscovery.go
  • internal/runner/autodiscovery_test.go
  • pkg/providers/k8s/kubernetes.go
  • pkg/providers/k8s/kubernetes_test.go

Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

Walkthrough

The Kubernetes provider now requires explicit kubeconfig input unless use_default_kubeconfig is set to "true". When enabled without an explicit path, it uses kubectl-style lookup. Kubernetes auto-discovery sets the option.

Changes

Kubernetes kubeconfig resolution

Layer / File(s) Summary
Provider kubeconfig selection
PROVIDERS.md, pkg/providers/k8s/kubernetes.go, pkg/providers/k8s/kubernetes_test.go
The provider rejects missing kubeconfig inputs unless default lookup is enabled. Explicit paths load only that path; otherwise, kubectl-style lookup applies. Documentation and tests cover the option, selected contexts, and error cases.
Auto-discovery default lookup
internal/runner/autodiscovery.go, internal/runner/autodiscovery_test.go
Kubernetes auto-discovery sets use_default_kubeconfig to "true". A test verifies provider creation using a kubeconfig supplied through KUBECONFIG.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 7be30

The change restricts default Kubernetes configuration lookup while preserving auto-discovery. No actionable merge-blocking issue remains established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: requiring explicit opt-in for default Kubernetes kubeconfig resolution.
Linked Issues check Passed Issue #806 requires an incomplete Kubernetes block to stop using ambient kubeconfig lookup, while auto-discovery must retain that lookup. New now returns an error when both explicit kubeconfig input…
Out of Scope Changes check Passed The changed files support issue #806. The provider code implements the lookup guard, the runner code preserves Kubernetes auto-discovery, the tests verify the behavior, and PROVIDERS.md documents the …
Full details: Docstring Coverage

Explanation

Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the config trail,
Through env and home, it finds the file.
Without the flag, it waits for more,
With auto-discovery, opens the door.
Two contexts hop; the chosen one is clear,
And errors tell when none are near.

Comment @coderabbitai help to get the list of available commands.

@Mzack9999
Mzack9999 merged commit 61a0ddc into dev Oct 14, 2026
9 checks passed
@Mzack9999
Mzack9999 deleted the fix/806-k8s-kubeconfig-opt-in branch October 14, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

k8s: empty kubernetes block falls back to ambient kubeconfig

2 participants