Open firaxis opened 4 years ago
This also breaks any FROM from a GCR repository that depends on authentication.
i have the same issue. I worked around it by removing --no-push
and pushing the image with the tag _
so that the cache is updated
Neither reading the existing cache nor pushing to it works, as you mentioned last working version is 0.19.0
Msg when reading cache
INFO[0002] No cached layer found for ...
Msg when trying to push to cache
INFO[0222] Pushing layer .... to cache now
WARN[0222] error uploading layer to cache: failed to push to destination ... UNAUTHORIZED: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
This is critical since without cache builds take a long time, and removing --no-push is not an option since one may just want the tar image to use in next steps of cloudbuild only.
We have the same issue with a FROM for an image in GCR (submitted with #1347).
Running into this when trying to test out kaniko locally. We shouldn't need to push to be able to test out local builds.
I've digged into the diffs from v0.19.0 to 0.20.0 and found the issue is because the credential-helper is no longer being called by default
The only other place where the credential-helper may be called is in this function
However as we can see, there're are 2 issues with it
POST https://index.docker.io/v2/library/$YOUR_DESTINATION_TAG UNAUTHORIZED: authentication required;
So either we add another block for credential-helper to run when the --noPush is set and gcr is set as cache, or CheckPushPermissions
needs a refactor to support this use case.
While a PR comes, here's the workaround:
- name: 'gcr.io/kaniko-project/executor:debug-v1.2.0'
id: my_step
entrypoint: sh
args:
- '-c'
- |
docker-credential-gcr configure-docker -registries us.gcr.io &&
executor \
--dockerfile=Dockerfile \
--cache=true \
--cache-repo=us.gcr.io/$PROJECT/$NAME \
--no-push \
--destination=my-image:latest \
--tarPath=/workspace/my-image.tar
Just call docker-credential-gcr configure-docker -registries us.gcr.io
before executor (adapt the registry name if you're not using the US registry) and it will both retrieve cached layers and push cache layers without issues.
Reopening as it was broken in a recent commit.
Actual behavior When running the docker kaniko with --no-push, cache is not available and pushing new cache layers fails.
Expected behavior Docker image should be built using cache.
To Reproduce
Additional Information
Dockerfile
Triage Notes for the Maintainers The latest version it works is v0.19.0
--cache
flag