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

Error: Unable to connect to the server: getting credentials: exec: exec: "aws": executable file not found in $PATH #1562

Closed
aradwyr opened this issue Nov 18, 2019 · 16 comments

Comments

@aradwyr
Copy link

aradwyr commented Nov 18, 2019

What happened?
Error: Unable to connect to the server: getting credentials: exec: exec: "aws": executable file not found in $PATH

I successfully created a cluster with $ eksctl create cluster

Then successfully ran: $ sudo aws2 eks --region ${REGION} update-kubeconfig --name ${CLUSTER_ID}

Then tried $ kubectl get nodes but got the error listed above.

In addition, $ aws-iam-authenticator init returns could not get config: cluster ID cannot be empty

Anything else we need to know?

  • OS: Mac
  • Download eksctl from binary
  • Download aws-iam-authenticator from homebrew
  • I was able to create a cluster without kubectl installed yet

Versions

$ eksctl version:  "0.9.0"
$ kubectl version: "v1.16.3"
$ aws-cli: v2

Logs
Include the output of the command line when running eksctl.

$ eksctl get clusters -v 4 returns
role ARN for the current session is "xxxxxxxxxxxxxx"
NAME REGION
${CLUSTER_ID} ${REGION}

To rule out IAM auth issues:
$ aws-iam-authenticator token -i environment_name.region.environment_type returns error-free

@aradwyr
Copy link
Author

aradwyr commented Nov 18, 2019

I'm thinking this is happening b/c for cli version 2 I have to use aws2-based commands not aws, should I switch to v1?

Similar issue reported here: kubernetes-sigs/aws-iam-authenticator#132

@dddeee777888
Copy link

Same issue on Windows 10 workstation

Unable to connect to the server: getting credentials: exec: exec: "aws": executable file not found in %PATH%

@aradwyr
Copy link
Author

aradwyr commented Nov 18, 2019

Ok so somewhat similar to the issue #132 listed above, I fixed it I believe:

Edit the kub config file directly: $ vim "/Users/home_dir/.kube/config"

Go down to this section:

user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:
- --region
- xxxxxregion_namexxxxx
- eks
- get-token
- --cluster-name
- xxxxxxxxxxxxcluster_idxxxxx
command: aws

and change the command field to: aws2

You should now be able to run:
$ eksctl get clusters
$ kubectl get svc --all-namespaces

@xiaowheat
Copy link

What is the long term solution for this issue?

@abhishekweb
Copy link

Hi Experts,
I have aws cli version aws-cli/2.0.7 Python/3.7.5 Windows/8.1 botocore/2.0.0dev11 .
eksctl version 0.16.0
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:53:57Z", GoVersion:"
go1.12.1", Compiler:"gc", Platform:"windows/amd64"}

But while giving command eksctl version for server i am getting below response 👍
Unable to connect to the server: dial tcp 35.158.204.250:443: connectex: No connection could be made because the target machine actively refused it.

I tried verious version but no luck. I have windows 8 computer and trying to connect to AWS EKS cluster. I am able to create cluster successfully with eksctl.

Kindly help !

@SandyCloudOps
Copy link

I'm facing similar issue while switching to user (devops) from root user on RedHat linx OS machine.

su - devops

Last login: Tue Apr 21 05:57:03 UTC 2020 on pts/3
Unable to connect to the server: getting credentials: exec: exec: "aws": executable file not found in $PATH

aws cli version is v1 only and ~/.kube/config has below settings:

user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:
- --region
- ap-northeast-1
- eks
- get-token
- --cluster-name
- xxxxxxxxxxxxxxxxxxxxxx
command: aws
env:
- name: AWS_PROFILE
value: xxxxxxxxxxx

$ aws --version
aws-cli/1.18.39 Python/2.7.5 Linux/3.10.0-862.11.6.el7.x86_64 botocore/1.15.39

Please help to resolve it!

@ssaila
Copy link

ssaila commented May 2, 2020

I'm facing similar issue while switching to user (devops) from root user on RedHat linx OS machine.

su - devops

Last login: Tue Apr 21 05:57:03 UTC 2020 on pts/3
Unable to connect to the server: getting credentials: exec: exec: "aws": executable file not found in $PATH

aws cli version is v1 only and ~/.kube/config has below settings:

user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:

  • --region
  • ap-northeast-1
  • eks
  • get-token
  • --cluster-name
  • xxxxxxxxxxxxxxxxxxxxxx
    command: aws
    env:
  • name: AWS_PROFILE
    value: xxxxxxxxxxx

$ aws --version
aws-cli/1.18.39 Python/2.7.5 Linux/3.10.0-862.11.6.el7.x86_64 botocore/1.15.39

Please help to resolve it!

Do a "which aws" for me it is /usr/local/bin/aws and then mention the whole path in kubeconfig file command: /usr/local/bin/aws

See if this helps

@SandyCloudOps
Copy link

I'm facing similar issue while switching to user (devops) from root user on RedHat linx OS machine.

su - devops

Last login: Tue Apr 21 05:57:03 UTC 2020 on pts/3
Unable to connect to the server: getting credentials: exec: exec: "aws": executable file not found in $PATH
aws cli version is v1 only and ~/.kube/config has below settings:
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:

  • --region
  • ap-northeast-1
  • eks
  • get-token
  • --cluster-name
  • xxxxxxxxxxxxxxxxxxxxxx
    command: aws
    env:
  • name: AWS_PROFILE
    value: xxxxxxxxxxx

$ aws --version
aws-cli/1.18.39 Python/2.7.5 Linux/3.10.0-862.11.6.el7.x86_64 botocore/1.15.39
Please help to resolve it!

Do a "which aws" for me it is /usr/local/bin/aws and then mention the whole path in kubeconfig file command: /usr/local/bin/aws

See if this helps

Thanks @ssaila . Indeed it helped when I provided full path.

For me it was under ~/.local/bin/ and I have to provide full path /home/devops/.local/bin/aws

@michaelbeaumont
Copy link
Contributor

There seem to be 2 issues here:

  1. updating configs with aws2 eks and it's overwriting configs from eksctl, nothing can be done about this in eksctl. (covered here [v2] aws2 eks update-kubeconfig should use current binary name aws/aws-cli#4675)
  2. using the same config across different users or where PATH is different. I'm not convinced this is something we want to handle specifically.
    1. Use cases mentioned in [v2] aws2 eks update-kubeconfig should use current binary name aws/aws-cli#4675 (comment) where the same user effectively has different PATH settings. These seem like cases of misconfiguration.
    2. Should different users be using the same kubeconfig? Even if they are, I think we can expect aws to be in PATH for both of them.

To write the whole path of the executable would bypass the purpose of PATH.

@michaelbeaumont
Copy link
Contributor

Closing this, if the above solutions/comments don't work for you, let us know here.

@durgeshpan
Copy link

Same issue on Windows 10 workstation

Unable to connect to the server: getting credentials: exec: exec: "aws": executable file not found in %PATH%

what is the solution for this error

@ssaila
Copy link

ssaila commented Aug 27, 2020

Same issue on Windows 10 workstation
Unable to connect to the server: getting credentials: exec: exec: "aws": executable file not found in %PATH%

what is the solution for this error

Do a "which aws" (for eg : /usr/local/bin/aws) and then mention the whole path in kubeconfig file command: /usr/local/bin/aws

@eins
Copy link

eins commented Jan 29, 2021

This error bug saved me.

I had this issue with a cronjob only. it worked well from a shell.
I added the full path in ~/.kube/config and it worked in a cronjob too

            command: /home/jolla/.local/bin/aws-iam-authenticator

Thanks

@asalinasj
Copy link

asalinasj commented Apr 30, 2021

I'm facing similar issue while switching to user (devops) from root user on RedHat linx OS machine.

su - devops

Last login: Tue Apr 21 05:57:03 UTC 2020 on pts/3
Unable to connect to the server: getting credentials: exec: exec: "aws": executable file not found in $PATH
aws cli version is v1 only and ~/.kube/config has below settings:
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:

  • --region
  • ap-northeast-1
  • eks
  • get-token
  • --cluster-name
  • xxxxxxxxxxxxxxxxxxxxxx
    command: aws
    env:
  • name: AWS_PROFILE
    value: xxxxxxxxxxx

$ aws --version
aws-cli/1.18.39 Python/2.7.5 Linux/3.10.0-862.11.6.el7.x86_64 botocore/1.15.39
Please help to resolve it!

Do a "which aws" for me it is /usr/local/bin/aws and then mention the whole path in kubeconfig file command: /usr/local/bin/aws

See if this helps

That worked! Adding the whole path did the trick. I set it up on Windows so it is C:\Program Files\Amazon\AWSCLIV2\aws if anyone needs it.

@rpicheta
Copy link

A similar situation is with oci - (oci-cli) from Oracle Cloud Infrastructure. The new version of Lens has a problem with executing oci. The solution is simple: replace oci in your kubeconfig file with the result of the command which oci. In my case, it was /usr/local/bin/oci.

@saurabhatarenaclub
Copy link

I'm facing similar issue while switching to user (devops) from root user on RedHat linx OS machine.

su - devops

Last login: Tue Apr 21 05:57:03 UTC 2020 on pts/3
Unable to connect to the server: getting credentials: exec: exec: "aws": executable file not found in $PATH
aws cli version is v1 only and ~/.kube/config has below settings:
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:

  • --region
  • ap-northeast-1
  • eks
  • get-token
  • --cluster-name
  • xxxxxxxxxxxxxxxxxxxxxx
    command: aws
    env:
  • name: AWS_PROFILE
    value: xxxxxxxxxxx

$ aws --version
aws-cli/1.18.39 Python/2.7.5 Linux/3.10.0-862.11.6.el7.x86_64 botocore/1.15.39
Please help to resolve it!

Do a "which aws" for me it is /usr/local/bin/aws and then mention the whole path in kubeconfig file command: /usr/local/bin/aws

See if this helps

Where & How to add this line?
How should file look after adding?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests