-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
add new push-node.sh that uses pre-compiled upstream releases #3825
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2024 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. | ||
|
||
# this script replaces hack/release/build/push-node.sh for Kubernetes v1.31+ | ||
# usage: push-node.sh v1.32.0 | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
REGISTRY="${REGISTRY:-gcr.io/k8s-staging-kind}" | ||
IMAGE_NAME="${IMAGE_NAME:-node}" | ||
|
||
# cd to the repo root | ||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." &> /dev/null && pwd -P)" | ||
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. Can we always assume we will be in a git repo and not running on a downloaded copy of the source? If so, might be slightly safer to use 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. This approach is safe unless we move the script relative to the repo root, we use it pretty widely in Kubernetes. BASH_SOURCE[0] will be the script invoked and is reliable vs $0 or something like that. It also works with a downloaded source tarball, for this particular script maybe we don't care, but I prefer using a consistent pattern, and for other scripts some packagers are using tarballs IIRC. (though we currently also have #3645) This trick is a neat combination of things that are safe versus the more trivial
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. ( 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. The main downside of this approach is you need to know the levels of nesting to the repo root ( 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. (er and 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. ... also I think ... I've spent way too much time hacking on these scripts :^), we should really write more of this down somewhere ... |
||
cd "${REPO_ROOT}" | ||
|
||
VERSION="$1" | ||
|
||
# ensure we have up to date kind | ||
make build | ||
|
||
# ensure we have qemu setup so we can run cross-arch images | ||
# TODO: dedupe specifying this image? | ||
docker run --rm --privileged tonistiigi/binfmt:qemu-v7.0.0-28@sha256:66e11bea77a5ea9d6f0fe79b57cd2b189b5d15b93a2bdb925be22949232e4e55 --install all | ||
|
||
# NOTE: adding platforms is costly in terms of build time | ||
# we will consider expanding this in the future, for now the aim is to prove | ||
# multi-arch and enable developers working on commonly available hardware | ||
# Other users are free to build their own images on additional platforms using | ||
# their own time and resources. Please see our docs. | ||
ARCHES="${ARCHES:-amd64 arm64}" | ||
IFS=" " read -r -a __arches__ <<< "$ARCHES" | ||
|
||
set -x | ||
# build for each arch | ||
IMAGE="${REGISTRY}/${IMAGE_NAME}:${VERSION}" | ||
images=() | ||
for arch in "${__arches__[@]}"; do | ||
image="${REGISTRY}/${IMAGE_NAME}-${arch}:${VERSION}" | ||
"${REPO_ROOT}/bin/kind" build node-image --image="${image}" --arch="${arch}" "${VERSION}" | ||
images+=("${image}") | ||
done | ||
|
||
# combine to manifest list tagged with kubernetes version | ||
# images must be pushed to be referenced by docker manifest | ||
# we push only after all builds have succeeded | ||
for image in "${images[@]}"; do | ||
docker push "${image}" | ||
done | ||
docker manifest rm "${IMAGE}" || true | ||
docker manifest create "${IMAGE}" "${images[@]}" | ||
docker manifest push "${IMAGE}" |
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.
(it started as a copy, I added
VERSION="$1"
and then ripped out all of the kubernetes build and version detection bits in favor of passing this as thekind build node-image
argument)