-
Notifications
You must be signed in to change notification settings - Fork 4k
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
cleanup(vpa): remove go vendoring #7572
cleanup(vpa): remove go vendoring #7572
Conversation
Hi @davidspek. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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-sigs/prow repository. |
/ok-to-test |
30fd171
to
1f9e5d8
Compare
/assign raywainman |
/lgtm e2e tests still pass locally 👍 |
COPY . /gopath/src/k8s.io/autoscaler/vertical-pod-autoscaler | ||
WORKDIR /gopath/src/k8s.io/autoscaler/vertical-pod-autoscaler | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we replace all these copy statements with just one?
COPY . .
Similar to https://github.com/GoogleContainerTools/distroless?tab=readme-ov-file#examples-with-docker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for these separate copy statements is to maximize layer caching. First copying the go.mod
and go.sum
and then downloading the dependencies before before copying any application code allows the layer containing all the dependencies to be cached during a container build. This can make a big difference for build times, especially when doing development. For this same reason the Go code is being explicitly copied into the container instead of a more global copy so that changes to other files (or the addition of new ones) that aren't part of the codebase don't trigger a new image build. Technically this could also be done with a .dockerignore
file, but then any new files or directories would need to be added there, and in my opinion having it copied in the Dockerfile explicitly also helps for clarity. This is also the standard way Dockerfiles are created for projects using kubebuilder
and I believe can be seen as best practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about:
COPY go.mod go.sum .
And later:
COPY common pkg .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should also work, although technically a little less good for layer caching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since both operations are a copy, I don't think there will be a noticeable different to the user if one those layers had to be re executed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raywainman What's your view on this? I'd like to get this sorted so it can be merged and we can move forward with the dependency upgrade PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layer caching seems like a reasonable reason to do this. LGTM.
I'm going to /lgtm |
Signed-off-by: David van der Spek <[email protected]>
Signed-off-by: David van der Spek <[email protected]>
Signed-off-by: David van der Spek <[email protected]>
Signed-off-by: David van der Spek <[email protected]>
Signed-off-by: David van der Spek <[email protected]>
e1d544c
to
82908da
Compare
/lgtm /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: davidspek, raywainman 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 |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR removes the
vendor
directories for the VPA. Vendoring the dependencies into the repo not only increases the size, but also makes reviewing PRs that include dependency changes more difficult. Sometimes to the point of breaking the GitHub UI like in #7551 and likely this PR. The relevant Dockerfiles have been updated to function without thevendor
directory and maximize layer caching. Along with that, the final image was change togcr.io/distroless/static:nonroot
so the containers don't run as root used by default.Which issue(s) this PR fixes:
Fixes #7570
Special notes for your reviewer:
The
hack/update-codegen.sh
script will need to be modified. However, doing so with the current version and this change is quite difficult. So I would like to postpone this to the PR that updates the k8s dependencies.Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: