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

CI: Build/publish multi-architecture Docker images via ko #1124

Closed
wants to merge 27 commits into from

Conversation

aknuds1
Copy link
Contributor

@aknuds1 aknuds1 commented Feb 8, 2022

What this PR does:
Build and publish Docker images via ko, a tool originally made by Google for containerizing Go apps. I've forked ko to allow for storing images as an intermediate step, and then publishing those stored images in another step. The images get stored as an OCI image layout, since it's the most practical format.

The most important change, functionally speaking, is that multi-architecture Docker manifest lists get published (containing AMD64 and ARM64 images) for Mimir and tools (mimirtool, metaconvert, query-tee).

Removal of Dockerfiles

Since ko doesn't use Dockerfiles, I'm removing the Dockerfiles except for the build image one (still has to be built with Docker). I've also updated the Makefile to reflect this, hope I got everything right in this regard.

Testing of ko-based Docker manifest list

I've tested the AMD64 image produced by ko (ko pushes a multi-architecture manifest list, the Docker installation on my machine picks AMD64) by following the getting started guide, and it works well. The integration test suite also works.

Which issue(s) this PR fixes:

Checklist

  • [na] Tests updated
  • [na] Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@aknuds1 aknuds1 added the enhancement New feature or request label Feb 8, 2022
@aknuds1 aknuds1 force-pushed the chore/build-multiplatform-images branch 8 times, most recently from 709f372 to 69b8b21 Compare February 9, 2022 09:48
@pstibrany
Copy link
Member

Great work!

docker run us.gcr.io/kubernetes-dev/mimir-ko-86216e9e58680a21dc5c3f08aab8c895:chore-build-multiplatform-images-291766c22 --version
Mimir, version 1.10.0-rc.0 (branch: chore/build-multiplatform-images, revision: 291766c22)
  build user:
  build date:
  go version:       go1.17.5
  platform:         linux/arm64

🎉

I have few questions:

  • What does our fork of ko add that's missing in upstream? Would it be possible to get our changes upstreamed?
  • Can we make ko part of build image?
  • Image publishing KO_DOCKER_REPO=us.gcr.io/kubernetes-dev ko publish-layout --tags ${IMAGE_TAG} mimir-ko mimir-images goes to us.gcr.io/kubernetes-dev/mimir-ko-86216e9e58680a21dc5c3f08aab8c895 repository. I don't understand where 86216e9e58680a21dc5c3f08aab8c895 part comes from, or how to change it.

@aknuds1
Copy link
Contributor Author

aknuds1 commented Feb 9, 2022

Great work!

Thanks @pstibrany!

  • What does our fork of ko add that's missing in upstream? Would it be possible to get our changes upstreamed?

The fork adds the ability to separate building and publishing into two different steps. I.e., the fork adds a sub-command publish-layout, that can publish an OCI image layout previously made by the build sub-command. publish-layout can publish to either an image registry or to a Docker daemon.

If we start using ko and it works well for us, I will ask upstream if it's interesting to them.

  • Can we make ko part of build image?

Absolutely.

  • Image publishing KO_DOCKER_REPO=us.gcr.io/kubernetes-dev ko publish-layout --tags ${IMAGE_TAG} mimir-ko mimir-images goes to us.gcr.io/kubernetes-dev/mimir-ko-86216e9e58680a21dc5c3f08aab8c895 repository. I don't understand where 86216e9e58680a21dc5c3f08aab8c895 part comes from, or how to change it.

This is because the -B (--bare) flag isn't used, without it ko appends an MD5 suffix to the repository name.

@pstibrany
Copy link
Member

Pushed updated build-image with ko: us.gcr.io/kubernetes-dev/mimir-build-image:chore-build-multiplatform-images-bdfd88900.

@aknuds1 aknuds1 force-pushed the chore/build-multiplatform-images branch 3 times, most recently from 46d8d3a to 956a482 Compare February 9, 2022 13:55
Copy link
Contributor

@simonswine simonswine left a comment

Choose a reason for hiding this comment

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

This is some great work 👍

I think the main gap from my point of view is that (according to my understanding) ko won't make any use at all of cmd/mimir/Dockerfile. Which might lead to some change between images before and after.

So I think lines like

EXPOSE     8080

and

RUN        apk add --no-cache ca-certificates

would need to be implemeted through ko (and I think you have done the ca-certificates using grafana/alpine:3.15.0).

I think ideally we should make use of ko images within GL as well, so we can get to the bottom of potential issues.

.ko.yaml Outdated Show resolved Hide resolved
@aknuds1 aknuds1 force-pushed the chore/build-multiplatform-images branch from 956a482 to 7e8b842 Compare February 9, 2022 14:43
@aknuds1
Copy link
Contributor Author

aknuds1 commented Feb 9, 2022

@simonswine I guess we can migrate away from the Dockerfile once we've eventually migrated to ko, yeah. I have implemented adding CA certificates via the base image yes. Unfortunately I found that ko's default base image breaks the integration tests due to lack of permission to read TLS certificates in the filesystem.

@aknuds1 aknuds1 force-pushed the chore/build-multiplatform-images branch 3 times, most recently from 50c26df to 4518996 Compare February 9, 2022 15:09
@aknuds1
Copy link
Contributor Author

aknuds1 commented Feb 9, 2022

@simonswine do we need to replicate this from Dockerfile? Is it useful at all?

EXPOSE     8080

@simonswine
Copy link
Contributor

@simonswine do we need to replicate this from Dockerfile? Is it useful at all?

EXPOSE 8080

I guess the only thing that uses it which I am aware of is docker run -P. So it might not be that impactful, I also think it could be added by adding it to the defaultBaseImage as ko doesn't appear to support it: ko-build/ko#472

@aknuds1 aknuds1 force-pushed the chore/build-multiplatform-images branch 3 times, most recently from e8e6cc2 to 51ff74f Compare February 10, 2022 17:58
@aknuds1 aknuds1 changed the title WIP: CI: Build/publish multi-architecture Docker images via ko CI: Build/publish multi-architecture Docker images via ko Feb 10, 2022
aknuds1 and others added 23 commits April 15, 2022 08:55
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
Tagging images as latest is necessary for integration test to find the
Mimir image.

Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
@aknuds1 aknuds1 force-pushed the chore/build-multiplatform-images branch from e6e51fe to 242cca9 Compare April 15, 2022 06:55
@pstibrany
Copy link
Member

Thank you for your work. After #1772 we will now publish multiarch images using Docker buildx and skopeo.

@aknuds1
Copy link
Contributor Author

aknuds1 commented Apr 29, 2022

Thank you for your work. After #1772 we will now publish multiarch images using Docker buildx and skopeo.

OK, closing the PR.

@aknuds1 aknuds1 closed this Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants