-
Notifications
You must be signed in to change notification settings - Fork 492
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
Will this sdk work with Azure Kubernetes #389
Comments
This definitely does work with Azure Kubernetes (I test it with AKS, myself) however, it doesn't currently refresh your token if it is expired if there isn't a https://github.com/kubernetes-client/javascript/blob/master/src/cloud_auth.ts#L62 A quick way to validate is to run If that works, one option is to add: user:
...
cmd-path: kubectl
cmd-args: version To your kubeconfig. We should definitely add better support for refreshing tokens to the client SDK. |
Just running kubectl version command, my program gave output and not the error |
right and now your token should be updated and the Javascript client code should work. |
Yes It is working now, Thanks @brendandburns |
Closing this in favor of the more general #399 |
I am following this link: https://github.com/kubernetes-client/javascript
and trying to list pods in the given namespace with azure kubernetes, here the code that I am referring:
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
k8sApi.listNamespacedPod('abc').then((res) => {
console.log(res.body);
});
I have successfully logged in to Kubernetes console, In the console, I am able to do the normal operation, but when I am running this code I am getting below error:
(node:30816) UnhandledPromiseRejectionWarning: Error: Token is expired!
at CloudAuth.updateAccessToken (D:\project\IOT-KT\dl\node_modules@kubernetes\client-node\dist\cloud_auth.js:46:19)
at CloudAuth.getToken (D:\project\IOT-KT\dl\node_modules@kubernetes\client-node\dist\cloud_auth.js:24:18)
at CloudAuth. (D:\project\IOT-KT\dl\node_modules@kubernetes\client-node\dist\cloud_auth.js:15:32)
at Generator.next ()
at D:\project\IOT-KT\dl\node_modules\tslib\tslib.js:110:75
at new Promise ()
at Object.__awaiter (D:\project\IOT-KT\dl\node_modules\tslib\tslib.js:106:16)
at CloudAuth.applyAuthentication (D:\project\IOT-KT\dl\node_modules@kubernetes\client-node\dist\cloud_auth.js:14:24)
at KubeConfig. (D:\project\IOT-KT\dl\node_modules@kubernetes\client-node\dist\config.js:299:37)
at Generator.next ()
(node:30816) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:30816) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
My Config file looks like this:
apiVersion: v1
clusters:
certificate-authority-data: LS0tLS1C..................Cg==
server: https://.azmk8s.io:443
name: removed>
contexts:
cluster: removed>
user: removed>
name: removed>
current-context: removed>
kind: Config
preferences: {}
users:
user:
auth-provider:
config:
apiserver-id: removed>
client-id: removed>
environment: removed>
tenant-id: removed>
name: azure
The text was updated successfully, but these errors were encountered: