-
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
VPA: Create a build and deploy locally script #7654
Merged
k8s-ci-robot
merged 4 commits into
kubernetes:master
from
adrianmoisey:add-local-build-script
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2025 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -o nounset | ||
set -o pipefail | ||
|
||
SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/.. | ||
|
||
SUITE=full-vpa | ||
REQUIRED_COMMANDS=" | ||
docker | ||
git | ||
go | ||
kubectl | ||
make | ||
" | ||
|
||
for i in $REQUIRED_COMMANDS; do | ||
if ! command -v $i > /dev/null 2>&1 | ||
then | ||
echo "$i could not be found, please ensure it is installed" | ||
echo | ||
echo "The following commands are required to run these tests:" | ||
echo $REQUIRED_COMMANDS | ||
exit 1; | ||
fi | ||
done | ||
|
||
if ! docker ps >/dev/null 2>&1 | ||
then | ||
echo "docker isn't running" | ||
echo | ||
echo "Please ensure that docker is running" | ||
exit 1 | ||
fi | ||
|
||
if ! kubectl version >/dev/null 2>&1 | ||
then | ||
echo "Kubernetes isn't running" | ||
echo | ||
echo "Please ensure that Kubernetes is running" | ||
exit 1 | ||
fi | ||
|
||
COMMIT=$(git rev-parse HEAD 2>/dev/null) | ||
COMMIT=${COMMIT:0:14} | ||
export BUILD_LD_FLAGS="-s -X=k8s.io/autoscaler/vertical-pod-autoscaler/common.gitCommit=$COMMIT" | ||
export TAG=$COMMIT | ||
|
||
|
||
echo " ** Deploying building and deploying all VPA components" | ||
${SCRIPT_ROOT}/hack/deploy-for-e2e-locally.sh full-vpa | ||
|
||
echo " ** Restarting all VPA components" | ||
for i in admission-controller updater recommender; do | ||
kubectl -n kube-system rollout restart deployment/vpa-$i | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,9 @@ COPY common common | |
COPY pkg pkg | ||
|
||
ARG TARGETOS TARGETARCH | ||
ARG BUILD_LD_FLAGS="-s" | ||
|
||
RUN CGO_ENABLED=0 LD_FLAGS=-s GOARCH=$TARGETARCH GOOS=$TARGETOS go build -C pkg/admission-controller -o admission-controller-$TARGETARCH | ||
RUN CGO_ENABLED=0 GOARCH=$TARGETARCH GOOS=$TARGETOS go build -C pkg/admission-controller -ldflags="${BUILD_LD_FLAGS}" -o admission-controller-$TARGETARCH | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that $ docker create --platform linux/amd64 --name vpa-recommender registry.k8s.io/autoscaling/vpa-recommender:1.2.1
999058e6c14330101bf0ce4e916f5dedbc4d1005d6ff9643033db0289624a7ee
$ docker cp vpa-recommender:/recommender .
Successfully copied 58.2MB to /Users/Adrian/.
$ file recommender
recommender: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=1NTySJ_TLdHBpDxDiF3X/gpLdixJiYC-YAHAH54Dt/1soeNlTu_Tj_uuiTrLyP/hqX1KbQPpE4_hW1xIaiQ, with debug_info, not stripped There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before: $ GOOS=linux go build -C pkg/admission-controller -o admission-controller-not-stripped
$ file pkg/admission-controller/admission-controller-not-stripped
pkg/admission-controller/admission-controller-not-stripped: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=FdIwuV800tRp_DwpAJve/rSttx_oRFM1ycMHfuEdQ/-anDCNZimL-FExp30NhX/EBATf_tSCu-ZUkhthpUD, with debug_info, not stripped
$ ls -lh pkg/admission-controller/admission-controller-not-stripped
-rwxr-xr-x 1 adrian staff 67M Jan 4 17:22 pkg/admission-controller/admission-controller-not-stripped After: $ GOOS=linux go build -C pkg/admission-controller -ldflags="-s" -o admission-controller-stripped
$ file pkg/admission-controller/admission-controller-stripped
pkg/admission-controller/admission-controller-stripped: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=MBFlhlA4r-VBNuUueZHw/jA8qtsf8vlLZF32hl2vw/-anDCNZimL-FExp30NhX/HIDLyY7TlMNMbxcIptrl, stripped
$ ls -lh pkg/admission-controller/admission-controller-stripped
-rwxr-xr-x 1 adrian staff 46M Jan 4 17:22 pkg/admission-controller/admission-controller-stripped |
||
|
||
FROM gcr.io/distroless/static:nonroot | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why do we have to restart all VPA components? Just curious
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.
I made the script add the latest git commit as a tag, which will cause the pods to restart if a new commit is added.
But, if local changes were made without being committed, then the tag won't change, and pods won't restart
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.
Understood. It makes sense.
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.
There may be other ways to handle that, such as hashing all uncommitted files and adding that to the tag. After a quick google it seemed to be more effort than it's worth
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.
Yes, I agree. good job :)