Skip to content

feat(kubectl): support global context and identity flags - #426

Closed
jordi-murgo wants to merge 1 commit into
rtk-ai:masterfrom
jordi-murgo:fix/kubectl-global-args
Closed

jordi-murgo wants to merge 1 commit into
rtk-ai:masterfrom
jordi-murgo:fix/kubectl-global-args

Conversation

@jordi-murgo

Copy link
Copy Markdown

Summary

  • add a shared KubectlGlobalArgs parser to kubectl pods, kubectl services, and kubectl logs
  • forward --context, --kubeconfig, -n, -l, and --as to underlying kubectl invocations
  • add CLI parsing/unit coverage for the new kubectl flag handling

Why

Using rtk kubectl currently drops common kubectl global flags, which breaks context-specific workflows (e.g. --context). This keeps filtered commands aligned with normal kubectl ergonomics.

Validation

  • cargo test test_kubectl -- --nocapture
  • cargo build --release
  • manual checks:
    • rtk kubectl pods --context savage-ovh
    • rtk kubectl services --context savage-ovh

Forward kubectl global flags (--context, --kubeconfig, -n, -l, --as) to filtered pods/services/logs commands so context-scoped workflows do not fail under rtk parsing.
@pszymkowiak

Copy link
Copy Markdown
Collaborator

Hi! Thanks for the contribution! Since March 6, all PRs should target the develop branch instead of master (see CONTRIBUTING.md).

Could you update the base branch? Click Edit at the top right of this PR and change it from master to develop.

Thanks!

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

pszymkowiak added a commit that referenced this pull request Mar 26, 2026
Add KubectlGlobalArgs struct with --context, --kubeconfig, -n, -l, --as
flags shared across all kubectl subcommands (pods, services, logs).
These flags are forwarded to the underlying kubectl command.

Essential for multi-cluster workflows where --context and -n are used
on every command.

Based on PR #426 by @jordi-murgo, rebased on develop.

Also fixes pre-existing clippy warning in rake_cmd.rs.

1126 tests passed, 0 failed.

Signed-off-by: Patrick szymkowiak <[email protected]>
@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

pszymkowiak added a commit that referenced this pull request May 16, 2026
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ó <[email protected]>
@pszymkowiak

Copy link
Copy Markdown
Collaborator

Thanks @jordi-murgo! The kubectl global-flags work was carried forward in a later PR and this one has had no activity for ~8 weeks. Closing as superseded — reopen anytime if needed.

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.

4 participants