Skip to content

feat(kubectl): add global context and identity flags (#857) - #858

Closed
pszymkowiak wants to merge 1 commit into
developfrom
feat/kubectl-global-flags
Closed

pszymkowiak wants to merge 1 commit into
developfrom
feat/kubectl-global-flags

Conversation

@pszymkowiak

Copy link
Copy Markdown
Collaborator

Summary

Adds KubectlGlobalArgs struct with global kubectl flags shared across all subcommands:

Flag Description
--context kubeconfig context (multi-cluster)
--kubeconfig custom kubeconfig path
-n / --namespace namespace scope
-l / --selector label selector
--as user impersonation

These flags now work on rtk kubectl pods, rtk kubectl services, and rtk kubectl logs.

Example: rtk kubectl pods --context prod -n api -l app=web

Based on PR #426 by @jordi-murgo (inactive since March 9), rebased on develop.
Closes #857 (partial — global flags done, TOML filters for describe/apply/top still needed).

Test plan

  • 1126 tests passed, 0 failed
  • cargo fmt clean
  • cargo clippy clean
  • 3 new tests: flag parsing, to_args conversion, all-namespaces + context combo

@aeppling

Copy link
Copy Markdown
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

Add KubectlGlobalArgs struct with --context, --kubeconfig, -n, -l, --as
flags shared across the kubectl pods, services and logs subcommands.
These flags are forwarded to the underlying kubectl command.

Without them, `rtk kubectl pods --context prod` failed clap parsing
with "unknown command", forcing users onto raw kubectl and losing RTK
filtering. Essential for multi-cluster workflows where --context and -n
are used on every command.

Reapplies the core change from #426 by @jordi-murgo onto the current
develop layout (the original branch predated the #826 src/ reorg).

Closes #857 (partial — global flags done; TOML filters for
describe/apply/top still tracked separately).

Co-authored-by: Jordi Murgó <jordi.murgo@gmail.com>
@pszymkowiak
pszymkowiak force-pushed the feat/kubectl-global-flags branch from 5ccaafe to 575ffac Compare May 16, 2026 09:00
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.

feat: comprehensive Kubernetes (kubectl) ecosystem support

3 participants