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

aws-iam-authenticator not found when kube config contains exec env variables #243

Closed
michaelgeorgeattard opened this issue May 13, 2019 · 6 comments · Fixed by #246
Closed

Comments

@michaelgeorgeattard
Copy link

michaelgeorgeattard commented May 13, 2019

I am getting an aws-iam-authenticator not found error with the following kube config snippet:

users:
- name: arn:aws:eks:eu-west-1:111111111111:cluster/foo
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1alpha1
      args:
      - token
      - -i
      - foo
      command: aws-iam-authenticator
      env:
      - name: AWS_PROFILE
        value: bar

Looks like this is due to a bug in exec_auth.ts:

const result = shell.exec(cmd, opts);

shelljs.exec second parameter is defined below:

https://github.com/shelljs/shelljs#execcommand--options--callback

Maybe this could be solved using something like:

exec.env.forEach((elt) => {
  shell.env[elt.name] = elt.value;
});
@brendandburns
Copy link
Contributor

The environment variable setup here:

https://github.com/kubernetes-client/javascript/blob/master/src/exec_auth.ts#L58

Can you add more details about the bug?

Thanks!

@brendandburns
Copy link
Contributor

And I think that the error indicates that the aws-iam-authenticator is not in your ${PATH}

@michaelgeorgeattard
Copy link
Author

michaelgeorgeattard commented May 15, 2019

First of all, excuse me for repeating myself, but I think I didn't get the point across in my previous comment:

The bug is probably in the way shell.exec is called.

Transforming the below:

const result = shell.exec(cmd, opts); 

Into:

const result = shell.exec(cmd);

Allows shelljs to "find" aws-iam-authenticator.

Environment variables should NOT be passed as the second variable to shell.exec but rather as below:

https://github.com/shelljs/shelljs#execcommand--options--callback

@michaelgeorgeattard
Copy link
Author

michaelgeorgeattard commented May 15, 2019

Also to replicate add env variables to kube config as below:

users:
- name: arn:aws:eks:eu-west-1:111111111111:cluster/foo
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1alpha1
      args:
      - token
      - -i
      - foo
      command: aws-iam-authenticator
      env: # add this part
      - name: foo
        value: bar

@brendandburns
Copy link
Contributor

Ah, ok, I think I see. The problem is that we should duplicate the existing environment variables before we pass them to exec.

As far as I can read the docs, the way that we are passing environment variables is correct, but because there is no PATH present in the env it isn't present.

I'm pretty sure I see the right way to fix this, I will send a PR.

@brendandburns
Copy link
Contributor

Sent a PR with the fix.

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 a pull request may close this issue.

2 participants