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

Adds image automated build #189

Merged

Conversation

claudiubelu
Copy link
Contributor

@claudiubelu claudiubelu commented Apr 22, 2020

In order for the secret store CSI image to be automatically built and published to the staging registry (from which it will be promoted), the cloudbuild.yaml file has been added.

The file was added in conformance with [1].

Adds the docker folder, which contains several items:

  • cloudbuild.yaml
  • BASEIMAGE: the base image to use when building an image for a certain os/arch
    (or os/arch/version for Windows).
  • BASEIMAGE_CORE: for Windows images, from which image to copy necessary files (DLLs).
  • Makefile
  • build.sh: script that can build, push, and create the manifest list.
  • Dockerfile: needed to build the Linux docker image. Can now accept the a
    BASEIMAGE arg, which can be useful when building multi-arch images.
  • windows.Dockerfile: needed to build the Windows docker image. Can now accept
    BASEIMAGE and BASEIMAGE_CORE args, which can be useful when building images for multiple
    Windows versions.

The image building process will be triggered when changes to the files in the docker changes
are made (for example, you bump the image version, so a new image is built).

[1] https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md

Adds support for multiple Windows versions.

The image will be created with the name gcr.io/k8s-staging-csi-secrets-store/driver:VERSION.

Bumps the driver's image version.

Related PR: kubernetes/test-infra#17335

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 22, 2020
@claudiubelu
Copy link
Contributor Author

claudiubelu commented Apr 22, 2020

/cc @aramase

PS: The reason for the build script, is in case you will want to build multi-arch images in the future. See here an example: https://github.com/kubernetes/kubernetes/blob/master/test/images/image-util.sh#L131

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 22, 2020
@claudiubelu claudiubelu force-pushed the adds-image-promoter branch 2 times, most recently from 45a6bd6 to 2981794 Compare April 22, 2020 15:43
@aramase
Copy link
Member

aramase commented Apr 22, 2020

@claudiubelu The e2e tests are failing because they're looking for Dockerfile in the repo root. Once you update that to docker/Dockerfile in the Makefile - https://github.com/kubernetes-sigs/secrets-store-csi-driver/blob/master/Makefile#L53-L56 and https://github.com/kubernetes-sigs/secrets-store-csi-driver/blob/master/Makefile#L103-L104 the tests should pass.

@claudiubelu claudiubelu force-pushed the adds-image-promoter branch 2 times, most recently from 646062b to b6df6f7 Compare April 22, 2020 19:03
@claudiubelu
Copy link
Contributor Author

I've tried building this image with the added script. The image I've built is at claudiubelu/driver:v0.0.10 (it's a manifest list with all the os/arch/versions described in the BASEIMAGE file).

@claudiubelu claudiubelu changed the title WIP: Adds image automated build Adds image automated build Apr 28, 2020
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 28, 2020
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 17, 2020
@claudiubelu
Copy link
Contributor Author

claudiubelu commented May 19, 2020

FWIW, I've updated the way the image is built, so the Windows nodes are not required at all: https://paste.ubuntu.com/p/phqKvJDDbt/

From what I've tried, containers using the image claudiubelu/driver:v0.0.10 have started on Windows Server 1809, 1903, and 1909. If someone could also check them, that would also be great. The manifest list contains os.version, as you can see: https://paste.ubuntu.com/p/MJjDW4Q3WB/

The more difficult part of this was actually tagging the manifest list with the proper os.version platform entries for the Windows images, which are mandatory for Windows. Without those, a Windows node will try to pull the first image that fits the platform and arch from the manifest list, even if it won't match the OS version, and thus fail to start the container. docker manifest annotate doesn't allow you to set the os.version, at least, in the current version, so I had to use manifest-tool to create and push the manifest list, which supports adding the os.version.

I've also updated the image in cloudbuild.yaml to a newer one that also supports buildx.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 19, 2020
@aramase
Copy link
Member

aramase commented May 20, 2020

@claudiubelu We recently merged the PR to use buildx for building multi-arch images - #205.

so I had to use manifest-tool to create and push the manifest list, which supports adding the os.version.

This is great!

@@ -51,9 +52,15 @@ build: setup
build-windows: setup
CGO_ENABLED=0 GOOS=windows go build -a -ldflags ${LDFLAGS} -o _output/secrets-store-csi.exe ./cmd/secrets-store-csi-driver
image:
docker buildx build --no-cache --build-arg LDFLAGS=${LDFLAGS} -t $(IMAGE_TAG) -f Dockerfile --platform="linux/amd64" --output "type=docker,push=false" .
docker buildx build --no-cache --build-arg LDFLAGS=${LDFLAGS} -t $(IMAGE_TAG) -f docker/Dockerfile --platform="linux/amd64" --output "type=docker,push=false" .
Copy link
Member

Choose a reason for hiding this comment

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

there is no docker/ dir?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I moved some things on rebase (there was a merge conflict). Because of some recent changes, I had to rewrite some bits of the building process, and I moved everything in the root directory.

I still prefer having the docker folder. The reason is because we're configuring the Image Promoter to build the image when changes to files in the docker/.* are being made (for example, you'd trigger the builder on an image version bump). Having everything on the root directory would mean that the builder would be triggered on every PR, which is unnecessary.

Copy link
Member

Choose a reason for hiding this comment

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

@claudiubelu I'm just wondering if we can make it more architecture natural so that we can build other platforms as well like arm, ppc64le and s390x as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did, in the build.sh below.

As I mentioned before, I've made a separate docker/Makefile which is going to be used by the Image Builder / Promoter. This target is still being used for testing, and is called in this Makefile. This only builds the linux/amd64 image, which is sufficient for testing, while mine builds all images, which takes a lot more time, especially due to the Windows images.

Copy link
Member

Choose a reason for hiding this comment

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

cool

@claudiubelu claudiubelu force-pushed the adds-image-promoter branch 2 times, most recently from a64b2d7 to 269fe38 Compare May 20, 2020 09:54
@claudiubelu
Copy link
Contributor Author

@claudiubelu We recently merged the PR to use buildx for building multi-arch images - #205.

so I had to use manifest-tool to create and push the manifest list, which supports adding the os.version.

This is great!

Hmm, from what I see, there is still only linux/amd64 and windows/amd64. There is no arm, amr64, etc. archs added.

@@ -51,9 +52,15 @@ build: setup
build-windows: setup
CGO_ENABLED=0 GOOS=windows go build -a -ldflags ${LDFLAGS} -o _output/secrets-store-csi.exe ./cmd/secrets-store-csi-driver
image:
docker buildx build --no-cache --build-arg LDFLAGS=${LDFLAGS} -t $(IMAGE_TAG) -f Dockerfile --platform="linux/amd64" --output "type=docker,push=false" .
docker buildx build --no-cache --build-arg LDFLAGS=${LDFLAGS} -t $(IMAGE_TAG) -f docker/Dockerfile --platform="linux/amd64" --output "type=docker,push=false" .
Copy link
Member

Choose a reason for hiding this comment

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

@claudiubelu I'm just wondering if we can make it more architecture natural so that we can build other platforms as well like arm, ppc64le and s390x as well?

docker/Makefile Outdated

REGISTRY?=docker.io/deislabs
IMAGE_NAME=driver
IMAGE_VERSION?=v0.0.10
Copy link
Member

Choose a reason for hiding this comment

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

Could you update this to v0.0.11 as that's the last release we cut?

Copy link
Member

@aramase aramase left a comment

Choose a reason for hiding this comment

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

@claudiubelu The PR looks great! 🎉

Just one small nit to update the IMAGE_VERSION to the latest release version.

In order for the secret store CSI image to be automatically built and published
to the staging registry (from which it will be promoted), the cloudbuild.yaml
file has been added.

The file was added in conformance with [1].

Adds the docker folder, which contains several items:
- cloudbuild.yaml
- BASEIMAGE: the base image to use when building an image for a certain os/arch
  (or os/arch/version for Windows).
- BASEIMAGE_CORE: for Windows images, from which image to copy necessary files (DLLs).
- Makefile
- build.sh: script that can build, push, and create the manifest list.
- Dockerfile: needed to build the Linux docker image. Can now accept the a
  BASEIMAGE arg, which can be useful when building multi-arch images.
- windows.Dockerfile: needed to build the Windows docker image. Can now accept
  BASEIMAGE and BASEIMAGE_CORE args, which can be useful when building images for multiple
  Windows versions.

The image building process will be triggered when changes to the files in the docker changes
are made (for example, you bump the image version, so a new image is built).

Adds support for multiple Windows versions.

The image will be created with the name gcr.io/k8s-staging-csi-secrets-store/driver:VERSION.

Bumps the driver's image version.

[1] https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md
@claudiubelu
Copy link
Contributor Author

Updated version

Copy link
Member

@aramase aramase left a comment

Choose a reason for hiding this comment

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

/lgtm

/hold
for @ritazh review

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 2, 2020
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 2, 2020
@ritazh
Copy link
Member

ritazh commented Jun 2, 2020

/hold cancel
/lgtm

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 2, 2020
@aramase
Copy link
Member

aramase commented Jun 2, 2020

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aramase, claudiubelu

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 2, 2020
@k8s-ci-robot k8s-ci-robot merged commit ff1dc3b into kubernetes-sigs:master Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants