文档说明: 只是记录关键点
k8s 版本 > 1.19
实验环境: linux debian 11
#!/bin/bash
set -eux
set -o pipefail
__CURRENT__=`pwd`
__DIR__=$(cd "$(dirname "$0")";pwd)
cd ${__DIR__}
test -f /etc/apt/sources.list.d/kubernetes.list && rm -rf /etc/apt/sources.list.d/kubernetes.list
apt-get update -y && apt-get install -y apt-transport-https sudo
apt install -y ca-certificates curl gnupg gnupg2 gnupg1 lvm2 lsb-release apt-transport-https curl
mkdir -p /etc/apt/keyrings/
test -f /etc/apt/keyrings/kubernetes-archive-keyring.gpg && rm -rf /etc/apt/keyrings/kubernetes-archive-keyring.gpg
curl -fsSL https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg
# 因为阿里云限速,下载很慢,所以换成中科大的镜像
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://mirrors.ustc.edu.cn/kubernetes/apt/ kubernetes-xenial main" | tee /etc/apt/sources.list.d/kubernetes.list
apt-get update -y
apt-get install -y kubelet kubeadm kubectl
# 锁定版本
# apt-mark hold kubelet kubeadm kubectl
# 安装指定版本也是可以的,如下
# apt-get install -y kubelet=1.24.7-00 kubeadm=1.24.7-00 kubectl=1.24.7-00