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

🌱 Refactor docker-push* Makefile targets so users can control with ALL_DOCKER_BUILD which images are pushed #8586

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

AndiDog
Copy link
Contributor

@AndiDog AndiDog commented May 2, 2023

What this PR does / why we need it:

Previously, make docker-push-all would try to push the combined manifest and image of each component, while make docker-build-all would respect ALL_DOCKER_BUILD and only build the specified components. This change makes the Makefile target naming consistent (docker-push-<component> and docker-push-manifest-<component>, clusterctl not specially named anymore) and refactors so that ALL_DOCKER_BUILD defines which components are built and pushed.

Specifically, this allows a build of only production components using ALL_DOCKER_BUILD="core kubeadm-bootstrap kubeadm-control-plane".

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

n/a

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 2, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @AndiDog. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@AndiDog AndiDog changed the title Refactor docker-push* Makefile targets so users can control with ALL_DOCKER_BUILD which images are pushed 🌱 Refactor docker-push* Makefile targets so users can control with ALL_DOCKER_BUILD which images are pushed May 2, 2023
@fabriziopandini
Copy link
Member

/ok-to-test

cc @kubernetes-sigs/cluster-api-release-team

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 2, 2023
AndiDog added a commit to giantswarm/cluster-api that referenced this pull request May 3, 2023
AndiDog added a commit to giantswarm/cluster-api that referenced this pull request May 4, 2023
AndiDog added a commit to giantswarm/cluster-api that referenced this pull request May 23, 2023
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 7, 2023
Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

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

Overall this change makes sense to me, however @AndiDog can you please rebase the PR?

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 7, 2023
@AndiDog
Copy link
Contributor Author

AndiDog commented Jun 7, 2023

Rebased by applying the patch also to the in-memory infrastructure provider Makefile targets

@fabriziopandini
Copy link
Member

/lgtm
@killianmuldoon @sbueringer PTAL when you have time

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 13, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 6917729a11deff0e6df18e65c3da6d18eb2be75e

@fabriziopandini
Copy link
Member

/unassign

@nawazkh
Copy link
Member

nawazkh commented Jul 26, 2023

/lgtm

@nawazkh
Copy link
Member

nawazkh commented Jul 26, 2023

/cc @sbueringer @killianmuldoon @CecileRobertMichon What do you all think about this?

Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

Thx looks good to me, just two questions

Otherwise ready for merge

Sorry for the long delay

Makefile Show resolved Hide resolved
Makefile Outdated
@@ -694,6 +694,7 @@ docker-build-all: $(addprefix docker-build-,$(ALL_ARCH)) ## Build docker images
docker-build-%:
$(MAKE) ARCH=$* docker-build

# Choice of images to build/push
ALL_DOCKER_BUILD = core kubeadm-bootstrap kubeadm-control-plane docker-infrastructure in-memory-infrastructure test-extension clusterctl
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ALL_DOCKER_BUILD = core kubeadm-bootstrap kubeadm-control-plane docker-infrastructure in-memory-infrastructure test-extension clusterctl
ALL_DOCKER_BUILD ?= core kubeadm-bootstrap kubeadm-control-plane docker-infrastructure in-memory-infrastructure test-extension clusterctl

Q: Do we have to add this to make it overwritable via env var?

I assume not, just no idea why we usually use ?= for stuff like this :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe you do. Using ?= allows the env var to take precedence if it's set whereas = just ignores the env var.

Copy link
Member

Choose a reason for hiding this comment

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

Hm, this would mean the PR wouldn't work in its current state, right?

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 made this configurable since fork builds (as my company's) may not require building all components. For example, only the controllers may be required but not the test or CLI images.

Copy link
Member

Choose a reason for hiding this comment

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

I got this part. My question is, is it currently possible to overwrite this via an env var without changing the above to ?=?

(basically a newbie Makefile question :))

Copy link
Member

Choose a reason for hiding this comment

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

export ALL_DOCKER_BUILD=core
➜ make docker-build
...
➜ /Library/Developer/CommandLineTools/usr/bin/make ARCH=arm64 docker-build-core docker-build-kubeadm-bootstrap docker-build-kubeadm-control-plane docker-build-docker-infrastructure docker-build-in-memory-infrastructure docker-build-test-extension docker-build-clusterctl

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah sorry, I thought this was part of my changes already but it's a GitHub suggested change 🙈.

We definitely use this change with overridden ALL_DOCKER_BUILD already, and make ALL_DOCKER_BUILD="core" ARCH=boom REGISTRY=myreg docker-push on macOS works fine to build only the core image. I found it's because make will override variables if you set them on the command line. Therefore, ALL_DOCKER_BUILD="core" ARCH=boom REGISTRY=myreg make docker-push, i.e. using real environment variables only, doesn't work. I will quickly test again and switch multiple places to ?=. Good find, thx!!

Copy link
Member

Choose a reason for hiding this comment

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

Ah thank you very much, that is good to know :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unless you don't want to make environment vs. command line parameters the same. Not sure if that is desired?!

Copy link
Member

Choose a reason for hiding this comment

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

I think it would be good if both works

Copy link
Contributor

@CecileRobertMichon CecileRobertMichon left a comment

Choose a reason for hiding this comment

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

/cc @Jont828

@Jont828
Copy link
Contributor

Jont828 commented Aug 15, 2023

/lgtm

@Jont828
Copy link
Contributor

Jont828 commented Aug 15, 2023

@CecileRobertMichon I think this should work as is for any of our use cases since it would use the default values unless specified.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 16, 2023
@sbueringer
Copy link
Member

Thank you very much!!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 16, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: c2fb9a47e81fcf984db3b07617ec6e657f9af980

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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 Aug 16, 2023
@sbueringer
Copy link
Member

/area devtools

@k8s-ci-robot k8s-ci-robot added the area/devtools Issues or PRs related to devtools label Aug 16, 2023
@k8s-ci-robot k8s-ci-robot merged commit bb26882 into kubernetes-sigs:main Aug 16, 2023
18 of 19 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.6 milestone Aug 16, 2023
@sbueringer
Copy link
Member

sbueringer commented Aug 16, 2023

I don't expect any problems, but let's verify that everything works as expected by checking the logs of https://prow.k8s.io/view/gs/kubernetes-jenkins/logs/post-cluster-api-push-images/1691699431717474304
(should finish in ~15-20 min)

@sbueringer
Copy link
Member

sbueringer commented Aug 16, 2023

Looks all good to me, e.g.

➜ docker buildx imagetools inspect gcr.io/k8s-staging-cluster-api/cluster-api-controller:v20230816-v1.5.0-rc.0-174-gbb2688217
Name:      gcr.io/k8s-staging-cluster-api/cluster-api-controller:v20230816-v1.5.0-rc.0-174-gbb2688217
MediaType: application/vnd.docker.distribution.manifest.list.v2+json
Digest:    sha256:01c215327091a4aeb0d0c34a60b4dbcdc4fc53e1aa03e5507000ae9dfc4d1b6d

Manifests:
  Name:      gcr.io/k8s-staging-cluster-api/cluster-api-controller:v20230816-v1.5.0-rc.0-174-gbb2688217@sha256:420e6bd0557990e026abebda0f18aeec0a65c878fe7c48b19e726b49caf907ce
  MediaType: application/vnd.docker.distribution.manifest.v2+json
  Platform:  linux/amd64

  Name:      gcr.io/k8s-staging-cluster-api/cluster-api-controller:v20230816-v1.5.0-rc.0-174-gbb2688217@sha256:f6836cff88a704d87eb3c0164c4b8e5d0fda54a02764ed7eff3071d9303dccce
  MediaType: application/vnd.docker.distribution.manifest.v2+json
  Platform:  linux/arm

  Name:      gcr.io/k8s-staging-cluster-api/cluster-api-controller:v20230816-v1.5.0-rc.0-174-gbb2688217@sha256:34c7ae653098373a65d53b2756ea6249288484342c43a64916d54a25fe906e0b
  MediaType: application/vnd.docker.distribution.manifest.v2+json
  Platform:  linux/arm64

  Name:      gcr.io/k8s-staging-cluster-api/cluster-api-controller:v20230816-v1.5.0-rc.0-174-gbb2688217@sha256:9afbc9f3a88d037099f6e72ec9205d0abac42d8c96409684ad7f1a0d787c1795
  MediaType: application/vnd.docker.distribution.manifest.v2+json
  Platform:  linux/ppc64le

  Name:      gcr.io/k8s-staging-cluster-api/cluster-api-controller:v20230816-v1.5.0-rc.0-174-gbb2688217@sha256:a09ace82c8d92ee5768820d436c1e84175f55bd3a7b8e031fb5863c8ccc93a41
  MediaType: application/vnd.docker.distribution.manifest.v2+json
  Platform:  linux/s390x

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. area/devtools Issues or PRs related to devtools 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants