diff --git a/templates/test/ci/cluster-template-prow-dalec-custom-builds.yaml b/templates/test/ci/cluster-template-prow-dalec-custom-builds.yaml index edf4103d911..618e885c186 100644 --- a/templates/test/ci/cluster-template-prow-dalec-custom-builds.yaml +++ b/templates/test/ci/cluster-template-prow-dalec-custom-builds.yaml @@ -204,7 +204,37 @@ spec: [[ -n "${KUBELET_REVISION}" ]] && ANY_REVISION_SET="true" if [[ "$${ANY_REVISION_SET}" != "true" ]]; then - echo "No *_REVISION variables set. Skipping binary replacement." + # No dalec revisions set — download official upstream binaries from + # dl.k8s.io to ensure binaries match the dalec container image version. + TARGET_VERSION="v$${VERSION}" + + echo "============================================================" + echo "DALEC IMAGE-ONLY TEST: No dalec binary revisions set." + echo "Downloading official upstream binaries ($${TARGET_VERSION})" + echo "from dl.k8s.io for version consistency with dalec images." + echo "============================================================" + + # Download all binaries to temp files first, then replace + DOWNLOAD_DIR=$$(mktemp -d) + ALL_UPSTREAM_BINARIES=("kubeadm" "kubectl" "kubelet") + for BINARY in "$${ALL_UPSTREAM_BINARIES[@]}"; do + DL_URL="https://dl.k8s.io/release/$${TARGET_VERSION}/bin/linux/amd64/$${BINARY}" + echo "* downloading $${BINARY} $${TARGET_VERSION} from $${DL_URL}" + curl --fail --location --retry 10 --retry-delay 5 "$${DL_URL}" --output "$${DOWNLOAD_DIR}/$${BINARY}" + chmod +x "$${DOWNLOAD_DIR}/$${BINARY}" + done + + # All downloads succeeded — now stop kubelet and replace binaries + systemctl stop kubelet + for BINARY in "$${ALL_UPSTREAM_BINARIES[@]}"; do + mv "$${DOWNLOAD_DIR}/$${BINARY}" "/usr/bin/$${BINARY}" + done + rm -rf "$${DOWNLOAD_DIR}" + systemctl restart kubelet + + echo "kubeadm version: $(kubeadm version -o=short)" + echo "kubectl version: $(kubectl version --client=true)" + echo "kubelet version: $(kubelet --version)" exit 0 fi @@ -453,7 +483,37 @@ spec: [[ -n "${KUBELET_REVISION}" ]] && ANY_REVISION_SET="true" if [[ "$${ANY_REVISION_SET}" != "true" ]]; then - echo "No *_REVISION variables set. Skipping binary replacement." + # No dalec revisions set — download official upstream binaries from + # dl.k8s.io to ensure binaries match the dalec container image version. + TARGET_VERSION="v$${VERSION}" + + echo "============================================================" + echo "DALEC IMAGE-ONLY TEST: No dalec binary revisions set." + echo "Downloading official upstream binaries ($${TARGET_VERSION})" + echo "from dl.k8s.io for version consistency with dalec images." + echo "============================================================" + + # Download all binaries to temp files first, then replace + DOWNLOAD_DIR=$$(mktemp -d) + ALL_UPSTREAM_BINARIES=("kubeadm" "kubectl" "kubelet") + for BINARY in "$${ALL_UPSTREAM_BINARIES[@]}"; do + DL_URL="https://dl.k8s.io/release/$${TARGET_VERSION}/bin/linux/amd64/$${BINARY}" + echo "* downloading $${BINARY} $${TARGET_VERSION} from $${DL_URL}" + curl --fail --location --retry 10 --retry-delay 5 "$${DL_URL}" --output "$${DOWNLOAD_DIR}/$${BINARY}" + chmod +x "$${DOWNLOAD_DIR}/$${BINARY}" + done + + # All downloads succeeded — now stop kubelet and replace binaries + systemctl stop kubelet + for BINARY in "$${ALL_UPSTREAM_BINARIES[@]}"; do + mv "$${DOWNLOAD_DIR}/$${BINARY}" "/usr/bin/$${BINARY}" + done + rm -rf "$${DOWNLOAD_DIR}" + systemctl restart kubelet + + echo "kubeadm version: $(kubeadm version -o=short)" + echo "kubectl version: $(kubectl version --client=true)" + echo "kubelet version: $(kubelet --version)" exit 0 fi @@ -817,7 +877,46 @@ spec: [[ -n "${KUBELET_REVISION}" ]] && ANY_REVISION_SET="true" if [[ "$${ANY_REVISION_SET}" != "true" ]]; then - echo "No *_REVISION variables set. Skipping binary replacement." + # No dalec revisions set — download official upstream binaries from + # dl.k8s.io to ensure binaries match the dalec container image version. + TARGET_VERSION="v$${VERSION}" + + echo "============================================================" + echo "DALEC IMAGE-ONLY TEST: No dalec binary revisions set." + echo "Downloading official upstream binaries ($${TARGET_VERSION})" + echo "from dl.k8s.io for version consistency with dalec images." + echo "============================================================" + + # Download all binaries to temp files first, then replace + DOWNLOAD_DIR=$$(mktemp -d) + ALL_UPSTREAM_BINARIES=("kubeadm" "kubectl" "kubelet") + for BINARY in "$${ALL_UPSTREAM_BINARIES[@]}"; do + DL_URL="https://dl.k8s.io/release/$${TARGET_VERSION}/bin/linux/amd64/$${BINARY}" + echo "* downloading $${BINARY} $${TARGET_VERSION} from $${DL_URL}" + curl --fail --location --retry 10 --retry-delay 5 "$${DL_URL}" --output "$${DOWNLOAD_DIR}/$${BINARY}" + chmod +x "$${DOWNLOAD_DIR}/$${BINARY}" + done + + # All downloads succeeded — now stop kubelet and replace binaries + systemctl stop kubelet + for BINARY in "$${ALL_UPSTREAM_BINARIES[@]}"; do + mv "$${DOWNLOAD_DIR}/$${BINARY}" "/usr/bin/$${BINARY}" + done + rm -rf "$${DOWNLOAD_DIR}" + + # Clean up stale kubelet flags in /etc/sysconfig/kubelet. + # The gallery image may ship flags removed in newer k8s versions + # (e.g. --pod-infra-container-image was removed in v1.35). + if [ -f /etc/sysconfig/kubelet ]; then + echo "Sanitizing /etc/sysconfig/kubelet for $${TARGET_VERSION}" + sed -i 's/--pod-infra-container-image=[^ ]*//g' /etc/sysconfig/kubelet + fi + + systemctl restart kubelet + + echo "kubeadm version: $(kubeadm version -o=short)" + echo "kubectl version: $(kubectl version --client=true)" + echo "kubelet version: $(kubelet --version)" exit 0 fi diff --git a/templates/test/ci/prow-dalec-custom-builds/patches/azl3-machine-deployment.yaml b/templates/test/ci/prow-dalec-custom-builds/patches/azl3-machine-deployment.yaml index 93a552ccf3c..37ab535586d 100644 --- a/templates/test/ci/prow-dalec-custom-builds/patches/azl3-machine-deployment.yaml +++ b/templates/test/ci/prow-dalec-custom-builds/patches/azl3-machine-deployment.yaml @@ -110,7 +110,46 @@ spec: [[ -n "${KUBELET_REVISION}" ]] && ANY_REVISION_SET="true" if [[ "$${ANY_REVISION_SET}" != "true" ]]; then - echo "No *_REVISION variables set. Skipping binary replacement." + # No dalec revisions set — download official upstream binaries from + # dl.k8s.io to ensure binaries match the dalec container image version. + TARGET_VERSION="v$${VERSION}" + + echo "============================================================" + echo "DALEC IMAGE-ONLY TEST: No dalec binary revisions set." + echo "Downloading official upstream binaries ($${TARGET_VERSION})" + echo "from dl.k8s.io for version consistency with dalec images." + echo "============================================================" + + # Download all binaries to temp files first, then replace + DOWNLOAD_DIR=$$(mktemp -d) + ALL_UPSTREAM_BINARIES=("kubeadm" "kubectl" "kubelet") + for BINARY in "$${ALL_UPSTREAM_BINARIES[@]}"; do + DL_URL="https://dl.k8s.io/release/$${TARGET_VERSION}/bin/linux/amd64/$${BINARY}" + echo "* downloading $${BINARY} $${TARGET_VERSION} from $${DL_URL}" + curl --fail --location --retry 10 --retry-delay 5 "$${DL_URL}" --output "$${DOWNLOAD_DIR}/$${BINARY}" + chmod +x "$${DOWNLOAD_DIR}/$${BINARY}" + done + + # All downloads succeeded — now stop kubelet and replace binaries + systemctl stop kubelet + for BINARY in "$${ALL_UPSTREAM_BINARIES[@]}"; do + mv "$${DOWNLOAD_DIR}/$${BINARY}" "/usr/bin/$${BINARY}" + done + rm -rf "$${DOWNLOAD_DIR}" + + # Clean up stale kubelet flags in /etc/sysconfig/kubelet. + # The gallery image may ship flags removed in newer k8s versions + # (e.g. --pod-infra-container-image was removed in v1.35). + if [ -f /etc/sysconfig/kubelet ]; then + echo "Sanitizing /etc/sysconfig/kubelet for $${TARGET_VERSION}" + sed -i 's/--pod-infra-container-image=[^ ]*//g' /etc/sysconfig/kubelet + fi + + systemctl restart kubelet + + echo "kubeadm version: $(kubeadm version -o=short)" + echo "kubectl version: $(kubectl version --client=true)" + echo "kubelet version: $(kubelet --version)" exit 0 fi diff --git a/templates/test/ci/prow-dalec-custom-builds/patches/control-plane-custom-builds.yaml b/templates/test/ci/prow-dalec-custom-builds/patches/control-plane-custom-builds.yaml index f636c822e73..96b020d347f 100644 --- a/templates/test/ci/prow-dalec-custom-builds/patches/control-plane-custom-builds.yaml +++ b/templates/test/ci/prow-dalec-custom-builds/patches/control-plane-custom-builds.yaml @@ -25,7 +25,37 @@ [[ -n "${KUBELET_REVISION}" ]] && ANY_REVISION_SET="true" if [[ "$${ANY_REVISION_SET}" != "true" ]]; then - echo "No *_REVISION variables set. Skipping binary replacement." + # No dalec revisions set — download official upstream binaries from + # dl.k8s.io to ensure binaries match the dalec container image version. + TARGET_VERSION="v$${VERSION}" + + echo "============================================================" + echo "DALEC IMAGE-ONLY TEST: No dalec binary revisions set." + echo "Downloading official upstream binaries ($${TARGET_VERSION})" + echo "from dl.k8s.io for version consistency with dalec images." + echo "============================================================" + + # Download all binaries to temp files first, then replace + DOWNLOAD_DIR=$$(mktemp -d) + ALL_UPSTREAM_BINARIES=("kubeadm" "kubectl" "kubelet") + for BINARY in "$${ALL_UPSTREAM_BINARIES[@]}"; do + DL_URL="https://dl.k8s.io/release/$${TARGET_VERSION}/bin/linux/amd64/$${BINARY}" + echo "* downloading $${BINARY} $${TARGET_VERSION} from $${DL_URL}" + curl --fail --location --retry 10 --retry-delay 5 "$${DL_URL}" --output "$${DOWNLOAD_DIR}/$${BINARY}" + chmod +x "$${DOWNLOAD_DIR}/$${BINARY}" + done + + # All downloads succeeded — now stop kubelet and replace binaries + systemctl stop kubelet + for BINARY in "$${ALL_UPSTREAM_BINARIES[@]}"; do + mv "$${DOWNLOAD_DIR}/$${BINARY}" "/usr/bin/$${BINARY}" + done + rm -rf "$${DOWNLOAD_DIR}" + systemctl restart kubelet + + echo "kubeadm version: $(kubeadm version -o=short)" + echo "kubectl version: $(kubectl version --client=true)" + echo "kubelet version: $(kubelet --version)" exit 0 fi diff --git a/templates/test/ci/prow-dalec-custom-builds/patches/kubeadm-bootstrap-custom-builds.yaml b/templates/test/ci/prow-dalec-custom-builds/patches/kubeadm-bootstrap-custom-builds.yaml index d869355c52d..77850b73921 100644 --- a/templates/test/ci/prow-dalec-custom-builds/patches/kubeadm-bootstrap-custom-builds.yaml +++ b/templates/test/ci/prow-dalec-custom-builds/patches/kubeadm-bootstrap-custom-builds.yaml @@ -25,7 +25,37 @@ [[ -n "${KUBELET_REVISION}" ]] && ANY_REVISION_SET="true" if [[ "$${ANY_REVISION_SET}" != "true" ]]; then - echo "No *_REVISION variables set. Skipping binary replacement." + # No dalec revisions set — download official upstream binaries from + # dl.k8s.io to ensure binaries match the dalec container image version. + TARGET_VERSION="v$${VERSION}" + + echo "============================================================" + echo "DALEC IMAGE-ONLY TEST: No dalec binary revisions set." + echo "Downloading official upstream binaries ($${TARGET_VERSION})" + echo "from dl.k8s.io for version consistency with dalec images." + echo "============================================================" + + # Download all binaries to temp files first, then replace + DOWNLOAD_DIR=$$(mktemp -d) + ALL_UPSTREAM_BINARIES=("kubeadm" "kubectl" "kubelet") + for BINARY in "$${ALL_UPSTREAM_BINARIES[@]}"; do + DL_URL="https://dl.k8s.io/release/$${TARGET_VERSION}/bin/linux/amd64/$${BINARY}" + echo "* downloading $${BINARY} $${TARGET_VERSION} from $${DL_URL}" + curl --fail --location --retry 10 --retry-delay 5 "$${DL_URL}" --output "$${DOWNLOAD_DIR}/$${BINARY}" + chmod +x "$${DOWNLOAD_DIR}/$${BINARY}" + done + + # All downloads succeeded — now stop kubelet and replace binaries + systemctl stop kubelet + for BINARY in "$${ALL_UPSTREAM_BINARIES[@]}"; do + mv "$${DOWNLOAD_DIR}/$${BINARY}" "/usr/bin/$${BINARY}" + done + rm -rf "$${DOWNLOAD_DIR}" + systemctl restart kubelet + + echo "kubeadm version: $(kubeadm version -o=short)" + echo "kubectl version: $(kubectl version --client=true)" + echo "kubelet version: $(kubelet --version)" exit 0 fi