Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exec_auth spawns the command synchronously #2044

Open
feloy opened this issue Nov 21, 2024 · 3 comments
Open

exec_auth spawns the command synchronously #2044

feloy opened this issue Nov 21, 2024 · 3 comments

Comments

@feloy
Copy link

feloy commented Nov 21, 2024

Describe the bug

exec_auth spawns the command synchronously.

When the exec command sends information to stdout/stderr to inform the user what to do to authenticate, the program is blocked waiting indefinitely, because the spawn is done synchronously.

** Client Version **
1.0.0-rc7

** Server Version **

Azure 1.29.9

To Reproduce

  • Start an Azure cluster with 'Microsoft Entra ID authentication with Kubernetes RBAC' authn & authz
  • get the credentials
  • do not execute any request to the cluster, so the token is not cached (or you can remove it: rm ~/.kube/cache/kubelogin/yourID.json
  • make a request to the API
  • the program is blocked executing the kubelogin app, which is blocked, waiting for the user to authenticate

Expected behavior

The call should be done async
bonus: the information provided by kubelogin should be displayed to the user

** Example Code**

import { CoreV1Api, KubeConfig } from "@kubernetes/client-node";

const kc = new KubeConfig();
kc.loadFromDefault();

const k8sApi = kc.makeApiClient(CoreV1Api);
const result = k8sApi.listNamespace();

Environment (please complete the following information):

  • OS: MacOS
  • NodeJS Version: v20.15.1
  • Cloud runtime: Azure

Additional context
Add any other context about the problem here.

@brendandburns
Copy link
Contributor

Happy to take PRs for this. We should detect if there is an active try and send interactive or not to the exec plugin.

@feloy
Copy link
Author

feloy commented Nov 22, 2024

I have a poc working, I'll look at this interactive thing and propose a PR.
Thanks

@feloy
Copy link
Author

feloy commented Nov 22, 2024

@brendandburns I can see that kubelogin accepts a --login interactive option, which makes the user experience better, as the login is opened on the browser when necessary (the fact that spawn is synchronous is blocking the GUI, which is still annoying).

But I cannot see how kubelogin can work with the auto-detected interactive mode. I tried to modify my kubeconfig to add interactiveMode: IfAvailable and keep it with --login devicecode and am trying with kubectl, but I still get a code, not interactive session

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

No branches or pull requests

2 participants