(一)kubernetes1.29.4离线部署之-安装文件准备
(二)kubernetes1.29.4离线部署之-镜像文件准备
(三)kubernetes1.29.4离线部署之-环境初始化
(四)kubernetes1.29.4离线部署之-组件安装
(五)kubernetes1.29.4离线部署之-初始化第一个控制平面
(六)kubernetes1.29.4离线部署之-加入Node节点
(七)kubernetes1.29.4离线部署之-网络插件
(八)kubernetes1.29.4离线部署之-测试验证
备注: 完整版请参阅 【k8s】Kubernetes 1.29.4离线安装部署(总)
特别关注:
再拷贝kubeadm、kubelet、kubectl文件后,务必记得要创建必须要的几个目录,否则会导致后面初始化控制平面时会出错,详情见完整的安装脚本
sudo mkdir -p /var/lib/kubelet
sudo mkdir -p /etc/kubernetes/manifests
yum 自动从网络安装不会出现该问题,会自动创建。
#!/bin/bash
###############################################
# QingHub K8S Install 版本: $VERSION
# 架构: $ARCH_TYPE 目前版本主要支持amd64,其他待敬请期待
# 操作系统: $os_type
# QingHub Studio官网: https://qinghub.net
# 如过您安装遇到问题,请到官网查找官方联系方式或加支持群:
# https://qinghub.net
###############################################
ENV_CFG=./env.cfg
if [ -f ${ENV_CFG} ] ; then
chmod 777 ${ENV_CFG}
source ${ENV_CFG}
fi
os_type=$(uname -s)
if [ $(arch) = "x86_64" ] || [ $(arch) = "amd64" ]; then
arch_type=amd64
elif [ $(arch) = "aarch64" ] || [ $(arch) = "arm64" ]; then
arch_type=arm64
elif [ $(arch) = "i386" ]; then
arch_type=amd64
echo -e "${YELLOW}[WAIN] 检测到 i386, 我们暂时把它当做 x86_64(amd64) ${NC}"
else
echo -e "${RED}[ERROR] QingHub Studio 目前还不支持 $(arch) 架构 ${NC}"
exit 1
fi
###############################################
# 复制并安装cri_containerd_cni 包括:cri, containerd,cni三合一,后续会覆盖安装
# QingHub Studio官网: https://qinghub.net
# 如过您安装遇到问题,请到官网查找官方联系方式或加支持群:
# https://qinghub.net
###############################################
function install_cri_containerd_cni(){
echo -e "${GREEN}[INFO] 下载并安装cri_containerd_cni二级制文件 ${cri_containerd_cni_name} ${NC}"
if [[ -e /usr/bin/curl ]]; then
# 离线下载文件请修改TODO
curl -L ${cri_containerd_cni_url} | sudo tar -C / -xz || {
echo -e "${RED}[ERROR] 下载并安装cri_containerd_cni二进制文件失败 ${NC}"
exit 1
}
else
wget -c "$cri_containerd_cni_url" | sudo tar -C / -xz || {
echo -e "${RED}[ERROR] 下载cri_containerd_cni二进制文件失败 ${NC}"
exit 1
}
fi
echo -e "${GREEN}[INFO] 创建containerd.service 文件 ${NC}"
sudo systemctl enable --now containerd
echo -e "${GREEN}[INFO] 安装containerd成功${NC}"
}
###############################################
# 描述: 初始化containerd 配置文件,添加修改仓库信息,请酌情修改
# QingHub Studio官网: https://qinghub.net
# 如过您安装遇到问题,请到官网查找官方联系方式或加支持群:
# https://qinghub.net
###############################################
function install_containerd_config(){
mkdir -p /etc/containerd
sudo /usr/local/bin/containerd config default | tee /etc/containerd/config.toml
# 修改Containerd的配置文件
sudo sed -i "s#SystemdCgroup\ \=\ false#SystemdCgroup\ \=\ true#g" /etc/containerd/config.toml
cat /etc/containerd/config.toml | grep SystemdCgroup
sudo sed -i "s#registry.k8s.io\/pause:3.8#qinghub.net:5000\/qingcloudtech\/pause:3.9#g" /etc/containerd/config.toml
cat /etc/containerd/config.toml | grep sandbox_image
sudo sed -i "s#config_path\ \=\ \"\"#config_path\ \=\ \"/etc/containerd/certs.d\"#g" /etc/containerd/config.toml
cat /etc/containerd/config.toml | grep certs.d
mkdir /etc/containerd/certs.d/qinghub.net:5000 -pv
sudo bash -c 'cat > /etc/containerd/certs.d/qinghub.net:5000/hosts.toml << EOF
server = "qinghub.net:5000"
[host."qinghub.net:5000"]
capabilities = ["pull", "resolve"]
EOF'
mkdir /etc/containerd/certs.d/docker.io -pv
sudo bash -c 'cat > /etc/containerd/certs.d/docker.io/hosts.toml << EOF
server = "https://docker.io"
[host."https://qinghub.net:5000"]
capabilities = ["pull", "resolve"]
[host."https://dockerproxy.com"]
capabilities = ["pull", "resolve"]
[host."https://docker.m.daocloud.io"]
capabilities = ["pull", "resolve"]
[host."https://reg-mirror.qiniu.com"]
capabilities = ["pull", "resolve"]
[host."http://hub-mirror.c.163.com"]
capabilities = ["pull", "resolve"]
EOF'
systemctl daemon-reload
systemctl restart containerd.service
}
###############################################
# 描述: 安装cni文件
# QingHub Studio官网: https://qinghub.net
# 如过您安装遇到问题,请到官网查找官方联系方式或加支持群:
# https://qinghub.net
###############################################
function install_cni_plugins(){
DEST="/opt/cni/bin"
sudo mkdir -p "$DEST"
echo -e "${GREEN}[INFO] 下载并安装cni_plugins二级制文件 ${cni_plugins_name} ${NC}"
if [[ -e /usr/bin/curl ]]; then
# 离线下载文件请修改TODO
curl -L ${cni_plugins_url} | sudo tar -C "$DEST" -xz || {
echo -e "${RED}[ERROR] 下载cni_plugins二进制文件失败 ${NC}"
exit 1
}
else
wget -c "$cni_plugins_url" | sudo tar -C "$DEST" -xz || {
echo -e "${RED}[ERROR] 下载cni_plugins二进制文件失败 ${NC}"
exit 1
}
fi
echo -e "${GREEN}[INFO] 安装cni_plugins成功${NC}"
}
###############################################
# 描述: 拷贝runc文件
# QingHub Studio官网: https://qinghub.net
# 如过您安装遇到问题,请到官网查找官方联系方式或加支持群:
# https://qinghub.net
###############################################
function install_runc(){
DEST="/usr/bin"
sudo mkdir -p "$DEST"
cd "$DEST"
echo -e "${GREEN}[INFO] 下载并安装runc二级制文件 ${runc_name} ${NC}"
if [[ -e /usr/bin/curl ]]; then
# 离线下载文件请修改TODO
curl -L -O ${runc_url} || {
echo -e "${RED}[ERROR] 下载并安装runc二进制文件失败 ${NC}"
exit 1
}
else
wget -c "$runc_url" || {
echo -e "${RED}[ERROR] 下载runc二进制文件失败 ${NC}"
exit 1
}
fi
if [ -f $DEST/runc.amd64 ]; then
chmod +x $DEST/runc.amd64
mv $DEST/runc.amd64 $DEST/runc
fi
echo -e "${GREEN}[INFO] 安装runc成功${NC}"
}
###############################################
# 描述: 拷贝crictl工具文件
# QingHub Studio官网: https://qinghub.net
# 如过您安装遇到问题,请到官网查找官方联系方式或加支持群:
# https://qinghub.net
###############################################
function install_crictl(){
DEST="/usr/local/bin"
sudo mkdir -p "$DEST"
echo -e "${GREEN}[INFO] 下载并安装crictl二级制文件 ${crictl_name} ${NC}"
if [[ -e /usr/bin/curl ]]; then
# 离线下载文件请修改TODO
sudo curl -L ${crictl_url} | sudo tar -C $DEST -xz || {
echo -e "${RED}[ERROR] 下载crictl二进制文件失败 ${NC}"
exit 1
}
else
sudo wget -c "$crictl_url" | sudo tar -C "$DEST" -xz || {
echo -e "${RED}[ERROR] 下载crictl二进制文件失败 ${NC}"
exit 1
}
fi
echo -e "${GREEN}[INFO] 安装crictl成功${NC}"
#生成配置文件
sudo bash -c "cat > /etc/crictl.yaml < /usr/lib/systemd/system/kubelet.service < /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf < /etc/sysconfig/kubelet <
你可以通过【QingHub Studio】) 套件直接安装部署,也可以手动按如下文档操作,该项目已经全面开源,完整的脚本可以从如下开源地址获取:
开源地址: https://gitee.com/qingplus/qingcloud-platform
【QingHub Studio集成开发套件】