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

fix issue, docker push in kaniko failed since permission error #706

Closed
wants to merge 1 commit into from

Conversation

vincent-pli
Copy link
Member

@vincent-pli vincent-pli commented Apr 2, 2019

Changes

I tried this example, at the step of "build-push-kaniko", it try to push image to docker.hub,
then hit permission error, seems it's not authorized to do that.
As we know, the "taskrun" will launch a "init container" to do that for us after set the "service account".

After some search, I find in "kaniko", it use a env parameter: DOCKER_CONFIG which point to ".docker/config.json". by default, the value is "/kaniko/.docker/".
As we know, the "taskrun" will put the docker authentication file at "/builder/home/.docker/"

So, to make the example work, need add additional config to rewrite the " DOCKER_CONFIG"

Submitter Checklist

examples/taskruns/taskrun.yaml
These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide
for more details.

Release Notes

release-note

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Apr 2, 2019
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vincent-pli
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: dlorenc

If they are not already assigned, you can assign the PR to them by writing /assign @dlorenc in a comment when ready.

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 2, 2019
@tekton-robot
Copy link
Collaborator

Hi @vincent-pli. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 2, 2019
@@ -66,6 +66,9 @@ spec:
- --dockerfile=${inputs.params.pathToDockerFile}
- --destination=${outputs.resources.builtImage.url}
- --context=${inputs.params.pathToContext}
env:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 interesting, this shouldn't be required as $HOME should be /builder/home and… it works on the CI :sweat_smile: cc @bobcatfish because I might overlook something 🙃

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue suffered me several hours, then I found this:
https://github.com/GoogleContainerTools/kaniko/issues/290

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm it might have something to do with what the default account in the namespace has permission to do (for example, mine always has permission to push to registries within the same project)

I think it makes sense that by default kaniko wouldn't be using anything in /builder/home/.docker/

For context @vincent-pli, were you providing a service account to this TaskRun when running it, or just running it with the default service account in the namespace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bobcatfish
I provide specific service account rather that default one, which include two secret, one for git another for docker.

By default, the kaniko try to find docker configuration file at /kaniko/.docker/config.json(the path define by env parameter: DOCKER_CONFIG), it's empty.
The "creds-init" just generate the file to /builder/home/.docker/

That's why I suggest to rewrite DOCKER_CONFIG in the task definition.

@bobcatfish
Copy link
Collaborator

bobcatfish commented Apr 2, 2019

Thanks for the PR!! 🎉

Super quick note @vincent-pli , in the PR description, could you take a look at the checklist and make sure to check the items off (after making sure the PR complies with them ;) ):

Includes tests (if functionality changed/added)
Includes docs (if user facing)
Commit messages follow commit message best practices

(Some of the details that you have in the PR description would be great in the commit message as well!)

@vincent-pli
Copy link
Member Author

vincent-pli commented Apr 9, 2019

@bobcatfish @vdemeester
Hi guys, I back to this issue :)
As I describe upper. it caused by behavior of kaniko, kaniko always try to find authorization file from:
/kaniko/.docker/config.json which decide by env parameter: DOCKER_CONFIG

I find another evidence: https://github.com/knative/build-templates/tree/master/kaniko

Please check it, thanks

@vincent-pli
Copy link
Member Author

Interesting🤔, the embed url cannot open, always get 404, please copy and paste the url to address bar😅, thanks

@Aisuko
Copy link

Aisuko commented May 3, 2019

The same issue. So, Is there have any official solution for that.

INFO[0205] Skipping paths under /workspace, as it is a whitelisted directory 
INFO[0205] CMD ["./web"]                                
INFO[0205] COPY --from=builder /web .                   
INFO[0205] Taking snapshot of files...                  
error pushing image: failed to push to destination index.docker.io/aisuko/skaffold:latest: UNAUTHORIZED: "authentication required"

@vincent-pli
Copy link
Member Author

/assign @bobcatfish

@vdemeester
Copy link
Member

@vincent-pli I think this mainly need to be fixed in the tektoncd/catalog project now, for the kaniko task.

@vincent-pli
Copy link
Member Author

@vdemeester
Agree with you, I will check the kaniko task later.
Please help to review this PR to avoid people hit same issue, thanks

AkihiroSuda added a commit to AkihiroSuda/catalog that referenced this pull request May 10, 2019
Discussed in tektoncd/pipeline#706
Fix tektoncd/pipeline#848

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda
Copy link

opened tektoncd/catalog#22

@vincent-pli
Copy link
Member Author

vincent-pli commented May 10, 2019

@akihikokuroda
Thanks to fix that :D

@akihikokuroda
Copy link
Member

I can not take credit for this :-) it’s for you @AkihiroSuda

@AkihiroSuda
Copy link

lol 😄

@vincent-pli
Copy link
Member Author

😓 😓 😓 😓 😓 😓

tekton-robot pushed a commit to tektoncd/catalog that referenced this pull request May 10, 2019
Discussed in tektoncd/pipeline#706
Fix tektoncd/pipeline#848

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@vdemeester
Copy link
Member

tektoncd/catalog#22 is merged, I think we can close this one 👼
/close

@tekton-robot
Copy link
Collaborator

@vdemeester: Closing this PR.

In response to this:

tektoncd/catalog#22 is merged, I think we can close this one 👼
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@AkihiroSuda
Copy link

I think we can close this one

Why? The example in this PR seems independent from the kaniko catalog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants