ubuntu/kali安装k8s

文章目录

      • [1. 阿里云镜像](#1. 阿里云镜像)
      • [2. 更新索引并查看版本](#2. 更新索引并查看版本)
      • [3. 备份所有镜像到一个文件](#3. 备份所有镜像到一个文件)
      • [4. 在目标机器恢复](#4. 在目标机器恢复)

常用的国内源有:


1. 阿里云镜像

复制代码
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg

echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] \
https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main" | \
sudo tee /etc/apt/sources.list.d/kubernetes.list


2. 更新索引并查看版本

复制代码
sudo apt-get update
apt-cache madison kubeadm kubelet kubectl

你就能看到镜像站提供的版本列表,然后再安装指定的版本:

复制代码
sudo apt-get install -y kubelet=1.20.15-00 kubeadm=1.20.15-00 kubectl=1.20.15-00
swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
sudo sysctl net.bridge.bridge-nf-call-iptables=1
sudo sysctl net.ipv4.ip_forward=1


3. 备份所有镜像到一个文件

复制代码
docker save -o all-images.tar $(docker images --format '{{.Repository}}:{{.Tag}}')

这样会把当前机器上所有镜像打包到 all-images.tar 里。


4. 在目标机器恢复

复制代码
docker load -i all-images.tar

这样所有镜像就都导入了。


⚠️ 注意:

  • 如果你有镜像的 TAG<none>,上面命令会报错,可以加个过滤:

    复制代码
    docker save -o all-images.tar $(docker images --format '{{.Repository}}:{{.Tag}}' | grep -v '<none>') 
    
    scp -P 22 all-images.tar michah@192.168.31.161:/home/michah/
    # 检查 192.168.31.161的状态
    sudo systemctl status ssh
    # 关闭swap
    swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab\n
  • docker save 只会打包镜像,不会包含容器里的数据卷。卷的数据需要额外用 rsync 或我上面提到的 busybox tar 方法迁移。

相关推荐
H_老邪6 分钟前
Linux 与 Docker 常用命令
linux·运维·服务器·docker
文静小土豆1 小时前
Linux 进程终止指南:理解 kill 与 kill -9 的核心区别与正确用法
linux·运维·服务器
不懒不懒1 小时前
安装python3.9.7和pycharm-community-2022.3.2.exe以及linux
linux·ide·python·pycharm
IMPYLH1 小时前
Linux 的 df 命令
linux·运维·服务器
wefg11 小时前
【Linux】会话、终端、前后台进程
linux·运维·服务器
zhixingheyi_tian1 小时前
Linux/Windows 免密登录
linux·运维·服务器
尤老师FPGA2 小时前
petalinux制作linux系统flash+sd卡启动
linux·运维·服务器
蓝天居士2 小时前
Linux实用功能代码集(4) —— 线程间消息队列(2)
linux
Name_NaN_None2 小时前
Linux 使用 Remmina 连接 Windows 远程桌面 ——「小白教程」
linux·网络·电脑·远程工作
shepherd1112 小时前
别再无脑 cat 了!后端排查 GB 级生产日志的实战命令
linux·后端