Code Monkey home page Code Monkey logo

Comments (7)

imjasonh avatar imjasonh commented on July 18, 2024 13

When using Kaniko you don't have to list the images in the build's images field since Kaniko already pushes them itself.

That error message indicates the build environment doesn't have those images locally so it can't push them, because Kaniko already pushed them directly, skipping local storage.

from cloud-builders-community.

imjasonh avatar imjasonh commented on July 18, 2024 9

I'm working on adding this now, since other users of Kaniko have also previously asked. No definite timeline, but it's on my radar.

from cloud-builders-community.

LanceSandino avatar LanceSandino commented on July 18, 2024 2

^ same I just ran into this issue and found this issue.

from cloud-builders-community.

imjasonh avatar imjasonh commented on July 18, 2024 1

I'll make sure we document this better since it can definitely be confusing.

from cloud-builders-community.

sh avatar sh commented on July 18, 2024

Thanks for coming back so quickly @imjasonh

Is there a way to inform cloudbuild that these images were produced so they'll show up as image artifacts in the cloudbuild history?

from cloud-builders-community.

Sexual avatar Sexual commented on July 18, 2024

@imjasonh Any update regarding this? It is frustrating not having it displayed in the dashboard

from cloud-builders-community.

jeremyschlatter avatar jeremyschlatter commented on July 18, 2024

I just ran into this as well. For future folks who want kaniko builds to display nicely in the Google Cloud dashboard, I came up with this very hacky solution:

steps:
# Build with kaniko.
- name: gcr.io/kaniko-project/executor:latest
  args: [--destination=$_IMAGE/kaniko:$COMMIT_SHA, --cache=true]

# Hacky docker stuff so we can get build info.
- name: docker
  args: [pull, $_IMAGE/kaniko:$COMMIT_SHA]
- name: docker
  args: [tag, $_IMAGE/kaniko:$COMMIT_SHA, $_IMAGE:$COMMIT_SHA]
- name: docker
  args: [push, $_IMAGE:$COMMIT_SHA]

# Deploy.
- name: gcr.io/cloud-builders/gcloud
  args: [run, deploy, my-service, --image=$_IMAGE:$COMMIT_SHA]
  
substitutions:
  _IMAGE: my-image-name

images: [$_IMAGE:$COMMIT_SHA]

Explanation:

  • We need the images field to be set so we can see it nicely in the dashboard.
  • That means we need the image to be present locally, because as mentioned above Cloud Build will try to push this image and kaniko did not leave it present in local storage. So we pull it with docker pull.
  • Now the weirdest (to me) part: if you docker pull and then docker push the image that kaniko built, you will get a different image digest, and so it will still not show up nicely in the dashboard. I'm very confused about this, but you can work around it thusly:
  • Use docker tag to rename the image. kaniko will manipulate images named $_IMAGE/kaniko, but from Cloud Build's perspective you end up with just $_IMAGE.

Note that depending on your purposes, you may be able to simplify this. For example if you don't need to immediately deploy to Cloud Run or whatever, you can probably skip the docker push step, since images will do that for you:

steps:
# Build with kaniko.
- name: gcr.io/kaniko-project/executor:latest
  args: [--destination=$_IMAGE/kaniko:$COMMIT_SHA, --cache=true]

# Hacky docker stuff so we can get build info.
- name: docker
  args: [pull, $_IMAGE/kaniko:$COMMIT_SHA]
- name: docker
  args: [tag, $_IMAGE/kaniko:$COMMIT_SHA, $_IMAGE:$COMMIT_SHA]
  
substitutions:
  _IMAGE: my-image-name

images: [$_IMAGE:$COMMIT_SHA]

And you might also be able to skip the renaming step, if you understand what's going on here better than I do.

Hope this helps!

from cloud-builders-community.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.