Skip to content

feat: add token support for kubectl commands#37

Merged
EItanya merged 10 commits into
mainfrom
eitanya/kubectl-token-support
Feb 17, 2026
Merged

feat: add token support for kubectl commands#37
EItanya merged 10 commits into
mainfrom
eitanya/kubectl-token-support

Conversation

@EItanya

@EItanya EItanya commented Dec 29, 2025

Copy link
Copy Markdown
Contributor

Some users of the kagent tool server want to be able to use client authentication for k8s tools. In order to enable this, the k8s tools will now attempt to pass Bearer tokens from the request into the kubectl commands.

Introduces helm values for configuring this:

# When true: pods use the default service account and no ClusterRole/ClusterRoleBinding are created.
# When false: a dedicated ServiceAccount and RBAC are created.
UseDefaultServiceAccount: false
tools:
  k8s:
    # When true: a Bearer token in the Authorization header on each request is passed to kubectl; fails if missing
    # When false: kubectl uses in-cluster ServiceAccount.
    tokenPassthrough: false

Testing

Defaults (matches current approach)

UseDefaultServiceAccount: false
tools:
  k8s:
    tokenPassthrough: false

Output:

time=2026-02-16T19:56:35.920Z level=INFO msg="executing command" trace_id=bd2fb0c590239cb8b183e60f4c0801bd span_id=7dcc9f5c919cb145 command=kubectl args="[get namespaces -o wide]"
time=2026-02-16T19:56:36.153Z level=INFO msg="command execution successful" trace_id=bd2fb0c590239cb8b183e60f4c0801bd span_id=7dcc9f5c919cb145 command=kubectl args="[get namespaces -o wide]" duration=0.233024001

Token passthrough + disable service account

UseDefaultServiceAccount: false
tools: 
  k8s:
    tokenPassthrough: false

With token:

time=2026-02-16T19:59:41.010Z level=INFO msg="executing command" trace_id=bd2fb0c590239cb8b183e60f4c0801bd span_id=ce0a811d4704fc88 command=kubectl args="[get namespaces -o wide --token <REDACTED>]"
time=2026-02-16T19:59:41.384Z level=INFO msg="command execution successful" trace_id=bd2fb0c590239cb8b183e60f4c0801bd span_id=ce0a811d4704fc88 command=kubectl args="[get namespaces -o wide --token <REDACTED>]" duration=0.374007129

Without token, the client receives:
Bearer token required when TOKEN_PASSTHROUGH is true

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
@dimetron

dimetron commented Jan 5, 2026

Copy link
Copy Markdown
Collaborator

@EItanya I have only concern if this will be consistent across all other tools

@EItanya

EItanya commented Jan 5, 2026

Copy link
Copy Markdown
Contributor Author

@EItanya I have only concern if this will be consistent across all other tools

I think that's fair, the issue is that not all CLIs allow for passing tokens in this way

Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
@iplay88keys
iplay88keys force-pushed the eitanya/kubectl-token-support branch from 6f0cb36 to fbc804d Compare January 28, 2026 21:02
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
@EItanya
EItanya merged commit e4347f5 into main Feb 17, 2026
5 checks passed
mesutoezdil pushed a commit to mesutoezdil/tools that referenced this pull request Jun 14, 2026
* feat: add token support for kubectl commands

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>

* use pre-v4 helm version

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>

* Add configuration to disable service token automount

Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>

* Remove automountServiceAccountToken config

Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>

* helm config for using default service account

Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>

* Add tools.k8s.tokenPassthrough for requiring token from auth header

Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>

* Fix helm version

Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>

* Remove automountServiceAccountToken from helm test

Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>

* Redact tokens

Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>

---------

Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
Signed-off-by: Jeremy Alvis <jeremy.alvis@solo.io>
Co-authored-by: Jeremy Alvis <jeremy.alvis@solo.io>
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