2023-11-17 01:37:05 +01:00
|
|
|
#!/usr/bin/env -S bash +e
|
2017-08-01 15:26:11 -07:00
|
|
|
|
2020-09-01 23:19:25 +09:00
|
|
|
KUBE_VERSION=${1:-"v1.15.12"}
|
2017-08-01 15:26:11 -07:00
|
|
|
null_str=
|
|
|
|
|
KUBE_INSTALL_VERSION="${KUBE_VERSION/v/$null_str}"-00
|
|
|
|
|
|
2017-09-14 09:40:34 -07:00
|
|
|
# Kubelet cannot run with swap enabled: https://github.com/kubernetes/kubernetes/issues/34726
|
2020-04-16 01:51:46 +09:00
|
|
|
# Disabling swap when installing k8s via kubeadm
|
|
|
|
|
which systemctl >/dev/null && sudo systemctl stop swap.target
|
2017-10-04 12:10:14 -07:00
|
|
|
sudo swapoff -a
|
2017-08-01 15:26:11 -07:00
|
|
|
|
2017-08-09 17:34:10 -07:00
|
|
|
wait_for_dpkg_unlock() {
|
|
|
|
|
#wait for dpkg lock to disappear.
|
|
|
|
|
retry=0
|
2019-01-23 17:22:58 -08:00
|
|
|
maxRetries=100
|
2017-08-09 17:34:10 -07:00
|
|
|
retryInterval=10
|
|
|
|
|
until [ ${retry} -ge ${maxRetries} ]
|
|
|
|
|
do
|
2021-08-06 12:01:57 +05:30
|
|
|
if [[ $(sudo lsof /var/lib/dpkg/lock|wc -l) -le 0 ]]; then
|
2018-06-09 15:40:08 +02:00
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
((++retry))
|
|
|
|
|
echo "."
|
|
|
|
|
sleep ${retryInterval}
|
2017-08-09 17:34:10 -07:00
|
|
|
done
|
|
|
|
|
|
2021-08-06 12:01:57 +05:30
|
|
|
if [ "${retry}" -ge ${maxRetries} ]; then
|
2017-08-09 17:34:10 -07:00
|
|
|
echo "Failed after ${maxRetries} attempts! - cannot install kubeadm"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-03 11:20:19 -07:00
|
|
|
sudo apt-get update
|
2017-08-09 17:34:10 -07:00
|
|
|
wait_for_dpkg_unlock
|
|
|
|
|
sleep 5
|
|
|
|
|
wait_for_dpkg_unlock
|
2017-08-03 11:20:19 -07:00
|
|
|
|
|
|
|
|
sudo apt-get install -y apt-transport-https
|
2017-08-01 15:26:11 -07:00
|
|
|
sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
|
2021-08-06 12:01:57 +05:30
|
|
|
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
|
2017-08-01 15:26:11 -07:00
|
|
|
|
2017-08-09 17:34:10 -07:00
|
|
|
sudo apt-get update
|
|
|
|
|
wait_for_dpkg_unlock
|
|
|
|
|
sleep 5
|
|
|
|
|
wait_for_dpkg_unlock
|
2020-07-07 03:38:47 +09:00
|
|
|
|
|
|
|
|
# We install the specific version of kubernetes-cni for aws_1.11.x test.
|
|
|
|
|
# kubelet in this test requires the version. If the newer versions are
|
|
|
|
|
# necessary in the tests of other Kubernetes versions, kubernetes-cni is
|
|
|
|
|
# updated in the kubelet installation.
|
|
|
|
|
sudo apt-get install -y kubernetes-cni="0.7.5-00"
|
2020-07-01 16:59:18 -06:00
|
|
|
sudo apt-get install -y kubelet="${KUBE_INSTALL_VERSION}" kubeadm="${KUBE_INSTALL_VERSION}" nfs-common
|