mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
refactor function is-preloaded in configure.sh
This commit is contained in:
parent
994275aa55
commit
f561a299ac
@ -113,11 +113,7 @@ function download-or-bust {
|
|||||||
function is-preloaded {
|
function is-preloaded {
|
||||||
local -r key=$1
|
local -r key=$1
|
||||||
local -r value=$2
|
local -r value=$2
|
||||||
if [[ -f ${KUBE_HOME}/preload_info ]] && (grep "${key}" "${KUBE_HOME}/preload_info" | grep "${value}" > /dev/null 2>&1);then
|
grep -qs "${key},${value}" "${KUBE_HOME}/preload_info"
|
||||||
echo 0
|
|
||||||
else
|
|
||||||
echo 1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function split-commas {
|
function split-commas {
|
||||||
@ -127,8 +123,7 @@ function split-commas {
|
|||||||
function install-gci-mounter-tools {
|
function install-gci-mounter-tools {
|
||||||
CONTAINERIZED_MOUNTER_HOME="${KUBE_HOME}/containerized_mounter"
|
CONTAINERIZED_MOUNTER_HOME="${KUBE_HOME}/containerized_mounter"
|
||||||
local -r mounter_tar_sha="8003b798cf33c7f91320cd6ee5cec4fa22244571"
|
local -r mounter_tar_sha="8003b798cf33c7f91320cd6ee5cec4fa22244571"
|
||||||
preload=$(is-preloaded "mounter" "${mounter_tar_sha}")
|
if is-preloaded "mounter" "${mounter_tar_sha}"; then
|
||||||
if [[ preload -eq 0 ]]; then
|
|
||||||
echo "mounter is preloaded."
|
echo "mounter is preloaded."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -156,8 +151,7 @@ function install-node-problem-detector {
|
|||||||
local -r npd_sha1="a57a3fe64cab8a18ec654f5cef0aec59dae62568"
|
local -r npd_sha1="a57a3fe64cab8a18ec654f5cef0aec59dae62568"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
preload=$(is-preloaded "node-problem-detector" "${npd_sha1}")
|
if is-preloaded "node-problem-detector" "${npd_sha1}"; then
|
||||||
if [[ preload -eq 0 ]]; then
|
|
||||||
echo "node-problem-detector is preloaded."
|
echo "node-problem-detector is preloaded."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -179,8 +173,7 @@ function install-cni-binaries {
|
|||||||
#TODO(andyzheng0831): We should make the cni version number as a k8s env variable.
|
#TODO(andyzheng0831): We should make the cni version number as a k8s env variable.
|
||||||
local -r cni_tar="cni-0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff.tar.gz"
|
local -r cni_tar="cni-0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff.tar.gz"
|
||||||
local -r cni_sha1="1d9788b0f5420e1a219aad2cb8681823fc515e7c"
|
local -r cni_sha1="1d9788b0f5420e1a219aad2cb8681823fc515e7c"
|
||||||
preload=$(is-preloaded "${cni_tar}" "${cni_sha1}")
|
if is-preloaded "${cni_tar}" "${cni_sha1}"; then
|
||||||
if [[ preload -eq 0 ]]; then
|
|
||||||
echo "${cni_tar} is preloaded."
|
echo "${cni_tar} is preloaded."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -209,8 +202,7 @@ function install-kube-manifests {
|
|||||||
local -r manifests_tar_hash=$(cat "${manifests_tar}.sha1")
|
local -r manifests_tar_hash=$(cat "${manifests_tar}.sha1")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
preload=$(is-preloaded "${manifests_tar}" "${manifests_tar_hash}")
|
if is-preloaded "${manifests_tar}" "${manifests_tar_hash}"; then
|
||||||
if [[ preload -eq 0 ]]; then
|
|
||||||
echo "${manifests_tar} is preloaded."
|
echo "${manifests_tar} is preloaded."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -283,16 +275,15 @@ function install-kube-binary-config {
|
|||||||
local -r server_binary_tar_hash=$(cat "${server_binary_tar}.sha1")
|
local -r server_binary_tar_hash=$(cat "${server_binary_tar}.sha1")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
preload=$(is-preloaded "${server_binary_tar}" "${server_binary_tar_hash}")
|
if is-preloaded "${server_binary_tar}" "${server_binary_tar_hash}"; then
|
||||||
if [[ preload -eq 0 ]]; then
|
|
||||||
echo "${server_binary_tar} is preloaded."
|
echo "${server_binary_tar} is preloaded."
|
||||||
else
|
else
|
||||||
echo "Downloading binary release tar"
|
echo "Downloading binary release tar"
|
||||||
download-or-bust "${server_binary_tar_hash}" "${server_binary_tar_urls[@]}"
|
download-or-bust "${server_binary_tar_hash}" "${server_binary_tar_urls[@]}"
|
||||||
tar xzf "${KUBE_HOME}/${server_binary_tar}" -C "${KUBE_HOME}" --overwrite
|
tar xzf "${KUBE_HOME}/${server_binary_tar}" -C "${KUBE_HOME}" --overwrite
|
||||||
# Copy docker_tag and image files to ${KUBE_HOME}/kube-docker-files.
|
# Copy docker_tag and image files to ${KUBE_HOME}/kube-docker-files.
|
||||||
src_dir="${KUBE_HOME}/kubernetes/server/bin"
|
local -r src_dir="${KUBE_HOME}/kubernetes/server/bin"
|
||||||
dst_dir="${KUBE_HOME}/kube-docker-files"
|
local dst_dir="${KUBE_HOME}/kube-docker-files"
|
||||||
mkdir -p "${dst_dir}"
|
mkdir -p "${dst_dir}"
|
||||||
cp "${src_dir}/"*.docker_tag "${dst_dir}"
|
cp "${src_dir}/"*.docker_tag "${dst_dir}"
|
||||||
if [[ "${KUBERNETES_MASTER:-}" == "false" ]]; then
|
if [[ "${KUBERNETES_MASTER:-}" == "false" ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user