Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 93 additions & 32 deletions templates/test/ci/cluster-template-prow-dalec-custom-builds.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -92,35 +92,50 @@ spec:
set -o pipefail
set -o errexit
systemctl stop kubelet
export KUBEADM_REVISION="${KUBEADM_REVISION:-""}"
export KUBECTL_REVISION="${KUBECTL_REVISION:-""}"
export KUBELET_REVISION="${KUBELET_REVISION:-""}"
declare -a BINARIES=("kubeadm" "kubectl" "kubelet")
systemctl stop kubelet
# Define the base URL and version
BASE_URL="https://kubernetesreleases.blob.core.windows.net/dalec-packages"
VERSION="${KUBERNETES_VERSION}"
VERSION=$${VERSION#v}
OS_VERSION="azl3"
ARCH="x86_64"
# Build lists of binaries to replace based on what's set
declare -a BINARIES=()
declare -A RPM_RELEASES=()
[[ -n "${KUBEADM_REVISION}" ]] && BINARIES+=("kubeadm") && RPM_RELEASES["kubeadm"]="$${KUBEADM_REVISION}.$${OS_VERSION}"
[[ -n "${KUBECTL_REVISION}" ]] && BINARIES+=("kubectl") && RPM_RELEASES["kubectl"]="$${KUBECTL_REVISION}.$${OS_VERSION}"
[[ -n "${KUBELET_REVISION}" ]] && BINARIES+=("kubelet") && RPM_RELEASES["kubelet"]="$${KUBELET_REVISION}.$${OS_VERSION}"
# Skip if nothing to replace (check first element)
if [[ -z "$${BINARIES[0]:-}" ]]; then
echo "No *_REVISION variables set. Skipping binary replacement."
systemctl start kubelet
exit 0
fi
echo "Replacing binaries: $${BINARIES[*]}"
for BINARY in "$${BINARIES[@]}"; do
echo "* downloading and extracting binary: $${BINARY} $${VERSION}"
BINARY_VAR="$${BINARY^^}_REVISION"
REVISION=$${!BINARY_VAR}
RPM_FILE="/tmp/$${BINARY}-$${VERSION}-$${REVISION}.$${OS_VERSION}.$${ARCH}.rpm"
RPM_URL="$${BASE_URL}/$${BINARY}/$${VERSION}/$${OS_VERSION}/$${ARCH}/$${BINARY}-$${VERSION}-$${REVISION}.$${OS_VERSION}.$${ARCH}.rpm"
RPM_RELEASE="$${RPM_RELEASES[$${BINARY}]}"
echo "* downloading and extracting binary: $${BINARY} $${VERSION} with rpm release $${RPM_RELEASE}"
RPM_FILE="/tmp/$${BINARY}-$${VERSION}-$${RPM_RELEASE}.$${ARCH}.rpm"
RPM_URL="$${BASE_URL}/$${BINARY}/$${VERSION}/$${OS_VERSION}/$${ARCH}/$${BINARY}-$${VERSION}-$${RPM_RELEASE}.$${ARCH}.rpm"
echo "Downloading from: $${RPM_URL}"
curl -L --retry 10 --retry-delay 5 "$${RPM_URL}" --output "$${RPM_FILE}"
# Extract binary from RPM package in a temporary directory
echo "Extracting $${BINARY} binary to /usr/bin"
TEMP_DIR="/tmp/$${BINARY}-extract-$$"
mkdir -p "$${TEMP_DIR}"
cd "$${TEMP_DIR}"
rpm2cpio "$${RPM_FILE}" | cpio -idmv
# Move the binary to the correct location
if [ -f "./usr/bin/$${BINARY}" ]; then
mv "./usr/bin/$${BINARY}" "/usr/bin/$${BINARY}"
chmod +x "/usr/bin/$${BINARY}"
Expand All @@ -129,17 +144,17 @@ spec:
exit 1
fi
# Clean up
cd /
rm -rf "$${TEMP_DIR}"
rm -f "$${RPM_FILE}"
done
systemctl restart kubelet
echo "kubeadm version: $(kubeadm version -o=short)"
echo "kubectl version: $(kubectl version --client=true)"
echo "kubelet version: $(kubelet --version)"
# Print versions
[[ " $${BINARIES[*]} " =~ " kubeadm " ]] && echo "kubeadm version: $(kubeadm version -o=short)"
[[ " $${BINARIES[*]} " =~ " kubectl " ]] && echo "kubectl version: $(kubectl version --client=true)"
[[ " $${BINARIES[*]} " =~ " kubelet " ]] && echo "kubelet version: $(kubelet --version)"
path: /opt/install-custom-k8s-binaries.sh
owner: "root:root"
permissions: "0744"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,64 @@
set -o nounset
set -o pipefail
set -o errexit
export KUBEADM_REVISION="${KUBEADM_REVISION:-""}"
export KUBECTL_REVISION="${KUBECTL_REVISION:-""}"
export KUBELET_REVISION="${KUBELET_REVISION:-""}"
systemctl stop kubelet
declare -a BINARIES=("kubeadm" "kubectl" "kubelet")
# Define the base URL and version
BASE_URL="https://kubernetesreleases.blob.core.windows.net/dalec-packages"
VERSION="${KUBERNETES_VERSION}"
VERSION=$${VERSION#v}
OS_VERSION="ubuntu24.04"
ARCH="amd64"
# Build lists of binaries to replace based on what's set
declare -a BINARIES=()
declare -A DEB_VERSIONS=()
[[ -n "${KUBEADM_REVISION}" ]] && BINARIES+=("kubeadm") && DEB_VERSIONS["kubeadm"]="$${OS_VERSION}u$${KUBEADM_REVISION}"
[[ -n "${KUBECTL_REVISION}" ]] && BINARIES+=("kubectl") && DEB_VERSIONS["kubectl"]="$${OS_VERSION}u$${KUBECTL_REVISION}"
[[ -n "${KUBELET_REVISION}" ]] && BINARIES+=("kubelet") && DEB_VERSIONS["kubelet"]="$${OS_VERSION}u$${KUBELET_REVISION}"
# Skip if nothing to replace (check first element)
if [[ -z "$${BINARIES[0]:-}" ]]; then
echo "No *_REVISION variables set. Skipping binary replacement."
systemctl start kubelet
exit 0
fi
echo "Replacing binaries: $${BINARIES[*]}"
for BINARY in "$${BINARIES[@]}"; do
BINARY_VAR="$${BINARY^^}_REVISION"
DEB_VERSION=$${!BINARY_VAR}
DEB_VERSION="$${DEB_VERSIONS[$${BINARY}]}"
echo "* downloading and extracting binary: $${BINARY} $${VERSION} with deb version $${DEB_VERSION}"
DEB_FILE="/tmp/$${BINARY}_$${VERSION}-$${DEB_VERSION}_$${ARCH}.deb"
DEB_URL="$${BASE_URL}/$${BINARY}/$${VERSION}/$${OS_VERSION}/$${ARCH}/$${BINARY}_$${VERSION}-$${DEB_VERSION}_$${ARCH}.deb"
echo "Downloading from: $${DEB_URL}"
curl -L --retry 10 --retry-delay 5 "$${DEB_URL}" --output "$${DEB_FILE}"
# Extract just the binary from the deb package directly to /usr/bin
echo "Extracting $${BINARY} binary to /usr/bin"
dpkg-deb --fsys-tarfile "$${DEB_FILE}" | tar -xf - --strip-components=3 -C /usr/bin ./usr/bin/$${BINARY}
chmod +x "/usr/bin/$${BINARY}"
# Clean up the downloaded deb file
rm -f "$${DEB_FILE}"
done
systemctl restart kubelet
echo "kubeadm version: $(kubeadm version -o=short)"
echo "kubectl version: $(kubectl version --client=true)"
echo "kubelet version: $(kubelet --version)"
# Print versions
[[ " $${BINARIES[*]} " =~ " kubeadm " ]] && echo "kubeadm version: $(kubeadm version -o=short)"
[[ " $${BINARIES[*]} " =~ " kubectl " ]] && echo "kubectl version: $(kubectl version --client=true)"
[[ " $${BINARIES[*]} " =~ " kubelet " ]] && echo "kubelet version: $(kubelet --version)"
path: /tmp/replace-k8s-binaries.sh
owner: "root:root"
permissions: "0744"
- op: add
path: /spec/kubeadmConfigSpec/preKubeadmCommands/-
value:
bash -c /tmp/replace-k8s-binaries.sh
- op: add
path: /spec/kubeadmConfigSpec/initConfiguration/nodeRegistration/ignorePreflightErrors
value:
- HTTPProxyCIDR

Copy link
Contributor

Choose a reason for hiding this comment

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

Newline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean I should remove the existing newline? Or add one somewhere

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant to add one at the end of the file. GitHub flags "no final newline" with a little red icon, so I pointed it out, but it's trivial so don't worry about it.

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 see the newline at my end so I think it's okay?

Image

Loading