-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Nomad auth for private ECR repo not working #3526
Comments
Is |
Nomad and 11/09/17 21:26:27 EST Driver Failure failed to initialize task "test-api" for alloc "a22ad474-0a09-24a8-1415-5287d123ddac": Failed to find docker auth for repo "<XYZ>.dkr.ecr.us-west-2.amazonaws.com/test-api": docker-credential-ecr-login with input "https://<XYZ>.dkr.ecr.us-west-2.amazonaws.com/test-api" failed with stderr: 2017-11-10T02:26:27Z [ERROR] Error retrieving credentials: NoCredentialProviders: no valid providers in chain. Deprecated.
For verbose messaging see aws.Config.CredentialsChainVerboseErrors
credentials not found in native keychain FYI, |
@ptarpan Can you try:
And
|
Hey @dadgar, Same issue: Time Type Description
11/10/17 15:48:22 EST Restarting Task restarting in 18.630682115s
11/10/17 15:48:22 EST Driver Failure failed to initialize task "test-api" for alloc "51f5de15-7892-e04a-058f-c01b27ff057e": Failed to pull `<XYZ>.dkr.ecr.us-west-2.amazonaws.com/test-api`: unauthorized: authentication required
11/10/17 15:48:21 EST Driver Downloading image <XYZ>.dkr.ecr.us-west-2.amazonaws.com/test-api:latest
11/10/17 15:48:21 EST Task Setup Building Task Directory
11/10/17 15:48:21 EST Received Task received by client |
If its any help; I use ECS repos by running a cron script which works as expected using the following configuration: Cron:
Nomad Client Config (portion):
IAM Role Permissions:
|
Thx @jrasell. We use cron with instance roles in AWS but this is an issue for agents running in a datacenter. One quick question before I continue testing this on-prem: does |
I can confirm this is happening as well. Adding the AWS keys as environment variables (and the corresponding keys) in the service fixed the issue for me. It seems like Nomad isn't reading AWS keys from IAM roles or the My config files:
|
I got this working now on Amazon Linux and nomad 0.7.1:
One should not to get disturbed by the nomad user account on the instance and the linux init system running nomad:
Docker Config -
|
Fixed this for us using @MatthiasScholz his remarks, thanks! |
@MatthiasScholz Sorry to resurrect this old thread. May i ask you were you able to pull mixed images? What we are seeing is that, using your config we are able to pull ECR images, but images from DockerHub which do not require auth fails because it tries to pull that image from ECR:
Is there a way to mix ECR private images and Public images? |
It is a valid questions. We only use ECR since we want to have a bit more control of the used images. When I get the documentation of AWS ECR Helper right:
-> then it would mean mixed image pulling should be supported. Did you try to play a little bit around with the configuration? Like:
mentioned in the Docker documentation? I am not 100% sure if it will work out since there is still the configuration of the |
I solved this temporarily:
It is not ideal but works for now. |
This has been fixed in #4266 and released in |
@nickethier Is there also a summary on how to configure it properly now? I've updated to 0.8.4 and still can't figure it out.
And also aws credentials setup. When I do a manual pull it all works fine, so why doesn't Nomad just pick up these settings? Do I really also need to set the Nomad client properties? And what should they be (why are they needed at all I question, but ok) Any directions or working sample would be welcome, as this is all confusing as hell.. |
Do not put the setup in the /root/ directory - only the root user has access to it then. Please check my comment above for the correct folders to use for the configuration. |
Ok got it in the end.
The missing link in the end was that the init system doesn't use the aws credentials file so you need to add the credential environment variables. Finally! Thanks for the support 👍 |
Do I need to make the client section at my nomad client or in Nomad server configuration stanza, please clarify ? |
Sorry to quoting it, Did you moved the config.json of docker in client machine and updated the client.hcl file in the Client machine ? Please clarify |
@nattvasan I ended up putting my AWS credentials in an environment file for my systemd setup for Nomad. |
@momania Yes, I figured that lately.! i'm new to nomad, ! Figured out the issue and it resolved!
Yes, I did the same ! |
#3526 (comment) is definitely the way to go. Thanks. |
I can't make this work for the case we are assuming a role with docker-credential-ecr-login as documented here https://github.com/awslabs/amazon-ecr-credential-helper/issues/34. "If you are working with an assumed role please set the environment variable: AWS_SDK_LOAD_CONFIG=true also." I don't know where to put AWS_SDK_LOAD_CONFIG and AWS_PROFILE env variables. I tried everything:
|
From Above
The above works, but is not ideal. What it seems is happening, is that Nomad is running in a subshell, that doesn't bring in the env vars from the external shell. So if you have your
It seems like this has been suggested before: #7357 (comment) I missed it without the example. Note that the current documentation suggests running the client agent as root https://learn.hashicorp.com/tutorials/nomad/get-started-run?in=nomad/get-started
|
After reading the suggestions, I have finally made it work. I am using nomad in localhost. I run the client agent as root, but my credentials are stored in my user directory my-config.hcl
docker.json
My ~./aws/credentials is like this
|
Thanks so much @njones! I was seeing really odd error messages like
adding |
I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues. |
Nomad version
0.5.6
and0.7.0
Operating system and Environment details
CentOS 7.3 and CentOS 7.4 (on-premise datacenter)
Issue
Nomad not acknowledging the
docker-credential-ecr-login
credentials. I've followed this documentation: https://www.nomadproject.io/docs/drivers/docker.html#authentication and this is NOT working.Reproduction steps
Nomad Server logs (if appropriate)
N/A
Nomad Client logs (if appropriate)
Job file (if appropriate)
Note: I've tried this with Nomad version
0.5.6
as well and am receiving the following error:Am I doing something wrong?
The text was updated successfully, but these errors were encountered: