Skip to content

[deckhouse-cli] Run kubectl plugins from d8 k - #505

Merged
yalosev merged 1 commit into
mainfrom
fix/kubectl-plugin-lookup
Oct 8, 2026
Merged

yalosev merged 1 commit into
mainfrom
fix/kubectl-plugin-lookup

Conversation

@yalosev

@yalosev yalosev commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Description

d8 k now runs kubectl plugins: d8 k argo rollouts get rollout demo runs kubectl-argo-rollouts get rollout demo, the same as kubectl argo rollouts get rollout demo. This also works through the kubectl alias that Deckhouse adds on nodes.

Why do we need it, and what problem does it solve?

Starting with Deckhouse 1.76, nodes no longer get a separate kubectl binary. /root/.bashrc aliases kubectl to /opt/deckhouse/bin/d8 k. With that alias in place, kubectl plugins on the nodes stopped working. A client reported this for the argo-rollouts plugin (/usr/local/bin/kubectl-argo-rollouts).

The cause: d8 k passed the whole d8 command line to kubectl's plugin lookup. The word k ended up in the plugin name, so d8 k argo rollouts get searched PATH for kubectl-k-argo-rollouts.

Technical details

NewKubectlCommand passes kubectlPluginArgs(os.Args) to the plugin handler:

d8 command line passed to the lookup plugin found
d8 k argo rollouts get d8 argo rollouts get kubectl-argo-rollouts
d8 kubectl argo rollouts version d8 argo rollouts version kubectl-argo-rollouts
d8 k create foo bar d8 create foo bar kubectl-create-foo
any other d8 <cmd> ... d8 lookup disabled

The last row matters. d8 builds the kubectl command tree on every run, so before this change d8 <name> ran kubectl-<name> from PATH for this tree too.

The same lookup is also present in the delivery-kit dependency. github.com/deckhouse/delivery-kit/v2 cmd/werf/kubectl/kubectl.go builds the d8 dk kubectl tree with Arguments: os.Args, so d8 hello still runs kubectl-hello when that file is in PATH. It is fixed separately in deckhouse/delivery-kit#408 (main, v3) and deckhouse/delivery-kit#409 (2, the v2 line d8 depends on); d8 picks the fix up when it bumps delivery-kit.

Clients who added a kubectl-k-<name> symlink as a workaround need no changes: the original plugin it points to is in PATH and is now found by its own name.

What is the expected result?

With kubectl-argo-rollouts and kubectl-create-foo test scripts in PATH:

Command Before (d8 v0.31.0) After
d8 k argo rollouts get rollout demo -n app kubectl help kubectl-argo-rollouts get rollout demo -n app
d8 kubectl argo rollouts version kubectl help kubectl-argo-rollouts version
d8 k create foo bar error: Unexpected args: [foo bar] kubectl-create-foo bar
d8 k version --client client version client version

Tests:

  • go test ./cmd/commands/ passes;
  • TestKubectlPluginLookup fails on the old code in all three cases;
  • golangci-lint v2.11.4 on ./cmd/commands/ reports 0 issues.

d8 k passed the whole d8 argv to kubectl's plugin lookup, so the "k"
word became part of the plugin name: `d8 k argo rollouts get` searched
PATH for kubectl-k-argo-rollouts and never found kubectl-argo-rollouts.
Since Deckhouse 1.76 nodes alias kubectl to `d8 k`, so every kubectl
plugin stopped working there.

Drop the "k"/"kubectl" word before the lookup. Every other d8 command
now passes no arguments to this lookup, so the d8 k command tree no
longer runs kubectl-<name> for `d8 <name>`.

Signed-off-by: Yuriy Losev <yuriy.losev@flant.com>
@yalosev
yalosev merged commit 9a1d3f7 into main Oct 8, 2026
9 checks passed
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.

2 participants