kubespray离线部署kubernetes - 离线文件获取(2)
1. 修改kubernetes组件镜像地址
cat inventory/mycluster/group_vars/k8s-cluster/k8s-cluster.yml |grep kube_image_repo
kube_image_repo: "registry.cn-beijing.aliyuncs.com/ltds_k8s"
2. 手动下载kubectl、kubelet、kubeadm二进制文件
# 通过github release下载对应版本的二进制文件 wget https://storage.googleapis.com/kubernetes-release/release/v1.18.10/kubernetes-node-linux-amd64.tar.gz # 解压文件,把bin下的kubelet、kubectl、kubeadm mv到/tmp/releases/下 # 重命名为 kubelet-v1.18.10-amd64、kubectl-v1.18.10-amd64、kubeadm-v1.18.10-amd64
3. 保存kubernetes离线文件
# 打包kubernetes二进制包 tar zcvf k8s-binary.tgz /usr/local/bin # 打包kubernetes镜像包 mkdir /tmp/images for i in $(docker images | awk {'print $1":"$2'});do name=$(echo $i|awk -F "/" {'print $NF'});docker save $i -o /tmp/images/$name.tar;done tar zcvf images.tgz /tmp/images/*
4. 保存centos7.6依赖软件包
mkidr /tmp/rpms # 从yum缓存路径拷贝rpm包到临时目录 for i in $(find /var/cache/yum -name *.rpm);do cp $i /tmp/rpms;done # 打包rpm包 tar zcvf rpms.tgz /tmp/rpms/*
5. 打包全部安装文件
# 将之前的离线文件移到kubespray目录下,并统一打包 cd ~ tar zcvf kubespray.tgz kubespray