-
Notifications
You must be signed in to change notification settings - Fork 557
Description
I have several EKS clusters I want to access using the nodejs client. Weirdly enough, the first cluster I access works, all subsequent clusters do not.
Digging into the code I found the following line:
https://github.com/kubernetes-client/javascript/blob/master/src/exec_auth.ts#L71
And when console logging, I found user.name
to be 'undefined'. Which causes the fist call to fetch the token from cluster 1, and all the follow-up calls to different clusters use the first token, resulting in Unauthorized errors.
Looking at the KubeConfig (I always use loadFromOptions)
{
"contexts" : [
{
"name" : "level0",
"context" : {
"user" : "staging-beige-frog",
"cluster" : "staging-beige-frog"
}
}
],
"clusters" : [
{
"name" : "staging-beige-frog",
"cluster" : {
"certificate-authority-data" : "...",
"server" : "...",
"skipTLSVerify" : true
}
}
],
"users" : [
{
"name" : "staging-beige-frog",
"user" : {
"exec" : {
"apiVersion" : "client.authentication.k8s.io/v1alpha1",
"command" : "aws-iam-authenticator",
"args" : [
"token",
"-i",
"staging-beige-frog"
]
}
}
}
],
"currentContext" : "level0"
}
I see the following line that fetches the user object:
https://github.com/kubernetes-client/javascript/blob/master/src/config.ts#L121
But it fetches the user
key in the first user object, which does not contain name
, that is a "level" higher, hence the "undefined".
Commenting out following lines makes it work
https://github.com/kubernetes-client/javascript/blob/master/src/exec_auth.ts#L71-L78