Skip to content

exec_auth token caching does not work #429

@roderik

Description

@roderik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions