kaniko: Kaniko failing to push to ECR
Actual behavior Trying to push to ECR with Kaniko on Gitlab on Kubernetes and get a user denied with the node instance role as the user even when providing access and secret keys with the credstore.
Expected behavior images pushes to ECS
To Reproduce Steps to reproduce the behavior: $ echo “{"credsStore":"ecr-login","credHelpers":{"$AWS_DOCKER_URL":"ecr-login"}}” > /kaniko/.docker/config.json $ /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $DOCKER_REPOSITORY:$CI_COMMIT_SHORT_SHA --build-arg NPM_TOKEN=$NPM_TOKEN --skip-unused-stages=true error checking push permissions – make sure you entered the correct tag name, and that you are authenticated correctly, and try again: checking push permission for “[MASKED].dkr.ecr.us-east-1.amazonaws.com/[MASKED]:b263001f”: POST https://[MASKED].dkr.ecr.us-east-1.amazonaws.com/v2/[MASKED]/blobs/uploads/: DENIED: User: arn:aws:sts::[MASKED]:assumed-role/[MASKED]-NodeInstanceRole/i-[MASKED] is not authorized to perform: ecr:InitiateLayerUpload on resource: arn:aws:ecr:us-east-1:[MASKED]:repository/[MASKED]
| Description | Yes/No |
|---|---|
| Please check if this a new feature you are proposing |
|
| Please check if the build works in docker but not in kaniko |
|
Please check if this error is seen when you use --cache flag |
|
| Please check if your dockerfile is a multistage dockerfile |
|
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 33 (9 by maintainers)
Commits related to this issue
- README.md: Update docs on building for AWS ECR - Kaniko v.1.8.0 does not require additional cred helper logic for ECR, as it discovers ECR repositories automatically and acts accordingly. Thus remove... — committed to Jasper-Ben/kaniko by Jasper-Ben 2 years ago
- README.md: Update docs on building for AWS ECR - Kaniko v.1.8.0 does not require additional cred helper logic for ECR, as it discovers ECR repositories automatically and acts accordingly. Thus remove... — committed to Jasper-Ben/kaniko by Jasper-Ben 2 years ago
- README.md: Update docs on building for AWS ECR - Kaniko v.1.8.0 does not require additional cred helper logic for ECR, as it discovers ECR repositories automatically and acts accordingly. Thus remove... — committed to Jasper-Ben/kaniko by Jasper-Ben 2 years ago
- README.md: Update docs on building for AWS ECR - Kaniko v.1.8.0 does not require additional cred helper logic for ECR, as it discovers ECR repositories automatically and acts accordingly. Thus remove... — committed to Jasper-Ben/kaniko by Jasper-Ben 2 years ago
- README.md: Update docs on building for AWS ECR (#2020) - Kaniko v.1.8.0 does not require additional cred helper logic for ECR, as it discovers ECR repositories automatically and acts accordingly. T... — committed to GoogleContainerTools/kaniko by Jasper-Ben 2 years ago
Hi all and @tiru1930
Issue is fix for me. Stupid problem but I dont’t know if it’s a bug or not…
As a reminder
With gitlabci and multi-stage image builder my gitlab.com push : OK .
With gitlabci and simple-stage image builder my ECR push : OK .
With gitlabci and multi-stage image builder my ECR push : FAILED .
For my ECR authentification I used the following line :
echo “{"credHelpers":{"$ECR_REGISTRY":"ecr-login"}}” > /kaniko/.docker/config.json
It’s important not to use kaniko user (home directory) for config.json storage. In my case I used /root/.docker/config.json after this issue and my multistage to ECR was good.
this appears to work even without having the
$HOME/.aws/configfile set I reckon kaniko only checks if the PROFILE is set or not….aws/configis not set in the working example…I don’t think I understand the issue well enough to comment. I need to find some time to use Kaniko with ECR myself.
If folks think that documenting AWS_PROFILE behavior would be helpful, I can approve a PR to add that to the README until I can debug it myself.
@Jasper-Ben issue is with AWS_PROFILE due to some reason profile is not working i change the name of profile to
defaultand it start working.Thank you for your fast reply. I use aws credentials for the authentication and kaniko v1.8.0 in a gitlab CICD pipeline
I have a similar issue, but setting
credHelpersdoes not seem to help 😞. However, I am getting an “EOF” error. Maybe I am doing something wrong?Error message:
My terraform config:
I am giving the following IAM permissions using OIDC:
@jordan85 Weird, if it’s only during a multi-stage that indeed sounds like a bug. Sorry I’m not a kaniko dev, just trying to help. 😦 Likely pasting/pastebin-ing a verbose log would be helpful for devs debugging it though. Can’t hurt.
Best of luck!