mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #25504 from andyzheng0831/binary
GCI: Ensure that the right version of kubelet is used
This commit is contained in:
commit
01cf9869fc
@ -122,17 +122,34 @@ install_kube_binary_config() {
|
|||||||
# a test cluster.
|
# a test cluster.
|
||||||
readonly BIN_PATH="/usr/bin"
|
readonly BIN_PATH="/usr/bin"
|
||||||
if ! which kubelet > /dev/null || ! which kubectl > /dev/null; then
|
if ! which kubelet > /dev/null || ! which kubectl > /dev/null; then
|
||||||
|
# This should be the case of trusty.
|
||||||
cp "${src_dir}/kubelet" "${BIN_PATH}"
|
cp "${src_dir}/kubelet" "${BIN_PATH}"
|
||||||
cp "${src_dir}/kubectl" "${BIN_PATH}"
|
cp "${src_dir}/kubectl" "${BIN_PATH}"
|
||||||
elif [ "${TEST_CLUSTER:-}" = "true" ]; then
|
else
|
||||||
kube_bin="${kube_home}/bin"
|
# This should be the case of GCI.
|
||||||
|
readonly kube_bin="${kube_home}/bin"
|
||||||
mkdir -p "${kube_bin}"
|
mkdir -p "${kube_bin}"
|
||||||
|
mount --bind "${kube_bin}" "${kube_bin}"
|
||||||
|
mount -o remount,rw,exec "${kube_bin}"
|
||||||
cp "${src_dir}/kubelet" "${kube_bin}"
|
cp "${src_dir}/kubelet" "${kube_bin}"
|
||||||
cp "${src_dir}/kubectl" "${kube_bin}"
|
cp "${src_dir}/kubectl" "${kube_bin}"
|
||||||
mount --bind "${kube_bin}/kubelet" "${BIN_PATH}/kubelet"
|
chmod 544 "${kube_bin}/kubelet"
|
||||||
mount --bind -o remount,ro,^noexec "${BIN_PATH}/kubelet" "${BIN_PATH}/kubelet"
|
chmod 544 "${kube_bin}/kubectl"
|
||||||
mount --bind "${kube_bin}/kubectl" "${BIN_PATH}/kubectl"
|
# If the built-in binary version is different from the expected version, we use
|
||||||
mount --bind -o remount,ro,^noexec "${BIN_PATH}/kubectl" "${BIN_PATH}/kubectl"
|
# the downloaded binary. The simplest implementation is to always use the downloaded
|
||||||
|
# binary without checking the version. But we have another version guardian in GKE.
|
||||||
|
# So, we compare the versions to ensure this run-time binary replacement is only
|
||||||
|
# applied for OSS kubernetes.
|
||||||
|
readonly builtin_version="$(/usr/bin/kubelet --version=true | cut -f2 -d " ")"
|
||||||
|
readonly required_version="$(/home/kubernetes/bin/kubelet --version=true | cut -f2 -d " ")"
|
||||||
|
if [ "${TEST_CLUSTER:-}" = "true" ] || [ "${builtin_version}" != "${required_version}" ]; then
|
||||||
|
mount --bind "${kube_bin}/kubelet" "${BIN_PATH}/kubelet"
|
||||||
|
mount --bind "${kube_bin}/kubectl" "${BIN_PATH}/kubectl"
|
||||||
|
else
|
||||||
|
# Remove downloaded binary just to prevent misuse.
|
||||||
|
rm -f "${kube_bin}/kubelet"
|
||||||
|
rm -f "${kube_bin}/kubectl"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Put kube-system pods manifests in /home/kubernetes/kube-manifests/.
|
# Put kube-system pods manifests in /home/kubernetes/kube-manifests/.
|
||||||
|
Loading…
Reference in New Issue
Block a user