diff --git a/hack/fetch-kubernetes-hash.sh b/hack/fetch-kubernetes-hash.sh new file mode 100755 index 000000000..2e51fa78f --- /dev/null +++ b/hack/fetch-kubernetes-hash.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +v22_patch_max=12 +v23_patch_max=9 +v24_patch_max=3 + +versions=() + +append_k8s_version() { + prefix=$1 + max=$2 + for i in $(seq 0 "$max"); + do + versions+=("${prefix}${i}") + done +} + +append_k8s_version "v1.22." $v22_patch_max +append_k8s_version "v1.23." $v23_patch_max +append_k8s_version "v1.24." $v24_patch_max + +#versions=("v1.22.12" "v1.23.9" "v1.24.3") + +arches=("amd64" "arm64") +apps=("kubeadm" "kubelet" "kubectl") +json="{}" +for app in "${apps[@]}"; +do + for arch in "${arches[@]}" + do + echo "${app}@${arch}" + for ver in "${versions[@]}" + do + url="https://storage.googleapis.com/kubernetes-release/release/${ver}/bin/linux/${arch}/${app}.sha256" + hash=$(wget --quiet -O - "$url") + echo "\"${ver}\": \"${hash}\"," + json=$(echo "$json" | jq ".${app}.${arch} += {\"${ver}\":\"${hash}\"}") + done + done +done + +file="kubernetes-hashes.json" +echo "$json" | jq --indent 4 > "${file}" && echo -e "\n\nThe hash info have saved to file ${file}.\n\n"