k8s离线下载安装包指南

因为公司部署k8s的时候需要在现场的内网环境安装,所以需要在无网环境进行安装k8s集群,所以在现场规划设备和系统时,会优先确定操作系统版本,保证安装版本和操作系统的一致性

我们目前安装k8s版本,采用的操作系统为CentOS7.9,所以本地使用虚拟机(vmware或virtualBox)创建一个精简版的虚拟机。进行离线下载安装包

1.获取k8s和docer的版本

 k8s&docker&Centos: [ftp://ftp.rhce.cc/k8s/*](ftp://ftp.rhce.cc/k8s/*)

2.获取yum源依赖包

前提:Centos虚拟机必须可以联网!!!要不后面都玩不下去的。

[root@master01 yum.repos.d]# rm -rf /etc/yum.repos.d/* ; wget -P /etc/yum.repos.d/ ftp://ftp.rhce.cc/k8s/*

--2022-05-05 21:15:13-- ftp://ftp.rhce.cc/k8s/*

 => ‘/etc/yum.repos.d/.listing’

Resolving ftp.rhce.cc (ftp.rhce.cc)... 101.37.152.41

Connecting to ftp.rhce.cc (ftp.rhce.cc)|101.37.152.41|:21... connected.

Logging in as anonymous ... Logged in!

==> SYST ... done. ==> PWD ... done.

==> TYPE I ... done. ==> CWD (1) /k8s ... done.

==> PASV ... done. ==> LIST ... done.

3.# 创建本地仓库包

[root@master01 ~]# yum install --downloadonly --downloaddir=/root/k8sOfflineSetup/packages \

> createrepo

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

docker-ce-stable  | 3.5 kB 00:00:00

epel  | 4.7 kB 00:00:00

extras  | 2.9 kB 00:00:00

kubernetes  | 1.4 kB 00:00:00

updates | 2.9 kB 00:00:00

(1/8): epel/x86_64/group_gz | 96 kB 00:00:00

(2/8): docker-ce-stable/x86_64/primary_db | 76 kB 00:00:00

(3/8): docker-ce-stable/x86_64/updateinfo |  55 B 00:00:00

(4/8): kubernetes/primary | 108 kB 00:00:00

(5/8): extras/7/x86_64/primary_db | 246 kB 00:00:00

…………………………….

Total  938 kB/s | 1.1 MB 00:00:01

exiting because "Download Only" specified

实用工具

[root@master01 ~]# yum install --downloadonly --downloaddir=/root/k8sOfflineSetup/packages \

> yum-utils \

> nfs-utils \

> wget

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

Package wget-1.14-18.el7_6.1.x86_64 already installed and latest version

Resolving Dependencies

--> Running transaction check

---> Package nfs-utils.x86_64 1:1.3.0-0.68.el7.2 will be installed

--> Processing Dependency: libtirpc >= 0.2.4-0.7 for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64

--> Processing Dependency: gssproxy >= 0.7.0-3 for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64

--> Processing Dependency: rpcbind for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64

--> Processing Dependency: quota for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64

--> Processing Dependency: libnfsidmap for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64

--> Processing Dependency: libevent for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64

--> Processing Dependency: keyutils for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64

--> Processing Dependency: libtirpc.so.1()(64bit) for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64

--> Processing Dependency: libnfsidmap.so.0()(64bit) for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64

--> Processing Dependency: libevent-2.0.so.5()(64bit) for package: 1:nfs-utils-1.3.0-0.68.el7.2.x86_64

………………..

Total  789 kB/s | 2.1 MB 00:00:02

exiting because "Download Only" specified

docker 依赖包

[root@master01 ~]# yum install --downloadonly --downloaddir=/root/k8sOfflineSetup/packages \

> device-mapper-persistent-data \

> lvm2

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

Resolving Dependencies

--> Running transaction check

………………………

Total  983 kB/s | 3.8 MB 00:00:03

exiting because "Download Only" specified

docker

[root@master01 ~]# yum install --downloadonly --downloaddir=/root/k8sOfflineSetup/packages \

> docker-ce-19.03.5 \

> docker-ce-cli-19.03.5 \

> containerd.io

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

Resolving Dependencies

--> Running transaction check

…………….

------------------------------------------------------------------------------------------------------------------------

Total  731 kB/s | 99 MB 00:02:18

exiting because "Download Only" specified

kubelet

[root@master01 ~]# yum install --downloadonly --downloaddir=/root/k8sOfflineSetup/packages \

> kubelet-1.21.0 \

> kubeadm-1.21.0 \

> kubectl-1.21.0

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

Resolving Dependencies

--> Running transaction check

---> Package kubeadm.x86_64 0:1.21.0-0 will be installed

--> Processing Dependency: kubernetes-cni >= 0.8.6 for package: kubeadm-1.21.0-0.x86_64

--> Processing Dependency: cri-tools >= 1.13.0 for package: kubeadm-1.21.0-0.x86_64

---> Package kubectl.x86_64 0:1.21.0-0 will be installed

---> Package kubelet.x86_64 0:1.21.0-0 will be installed

--> Processing Dependency: socat for package: kubelet-1.21.0-0.x86_64

--> Processing Dependency: conntrack for package: kubelet-1.21.0-0.x86_64

--> Running transaction check

---> Package cri-tools.x86_64 0:1.23.0-0 will be installed

---> Package kubelet.x86_64 0:1.21.0-0 will be installed

--> Processing Dependency: conntrack for package: kubelet-1.21.0-0.x86_64

---> Package kubernetes-cni.x86_64 0:0.8.7-0 will be installed

---> Package socat.x86_64 0:1.7.3.2-2.el7 will be installed

--> Finished Dependency Resolution

Error: Package: kubelet-1.21.0-0.x86_64 (kubernetes)

 Requires: conntrack

 You could try using --skip-broken to work around the problem

 You could try running: rpm -Va --nofiles --nodigest

—————————————————

报错解决:

执行yum clean all

重新下载即可,如下:

[root@master01 ~]# yum clean all

Loaded plugins: fastestmirror

Cleaning repos: base docker-ce-stable epel extras kubernetes updates

Cleaning up list of fastest mirrors

[root@master01 ~]# yum install --downloadonly --downloaddir=/root/k8sOfflineSetup/packages kubelet-1.21.0 kubeadm-1.21.0 kubectl-1.21.0

Loaded plugins: fastestmirror

Determining fastest mirrors

base  | 3.6 kB 00:00:00

docker-ce-stable  | 3.5 kB 00:00:00

epel  | 4.7 kB 00:00:00

extras  | 2.9 kB 00:00:00

kubernetes  | 1.4 kB 00:00:00

updates | 2.9 kB 00:00:00

—————————

------------------------------------------------------------------------------------------------------------------------

Total  863 kB/s | 65 MB 00:01:16

exiting because "Download Only" specified

获取kubeadm依赖镜像

获取kubeadm用到的镜像列表,这步操作要在一台安装了docker的环境上操作。拉取完成后打包复制到资源包/root/k8sOfflineSetup/images目录中。

从阿里云拉取镜像

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.21.0

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.21.0

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.21.0

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.21.0

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.4.3-0

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.6.5

[root@master01 ~]# docker images

REPOSITORY TAG  IMAGE ID CREATED  SIZE

registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver v1.21.0  4d217480042e 13 months ago  126MB

registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy v1.21.0  38ddd85fe90e 13 months ago  122MB

registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler v1.21.0  62ad3129eca8 13 months ago  50.6MB

registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager  v1.21.0  09708983cc37 13 months ago  120MB

registry.cn-hangzhou.aliyuncs.com/google_containers/coredns  1.6.5  70f311871ae1 2 years ago  41.6MB

registry.cn-hangzhou.aliyuncs.com/google_containers/etcd 3.4.3-0  303ce5db0e90 2 years ago  288MB

registry.cn-hangzhou.aliyuncs.com/google_containers/pause  3.1  da86e6ba6ca1 4 years ago  742kB

重新tag镜像 —kubeadm调用的时候必须要是google的

docker images | grep registry.cn-hangzhou.aliyuncs.com/google_containers|sed 's/registry.cn-hangzhou.aliyuncs.com\/google_containers/k8s.gcr.io/'|awk '{print "docker tag " $3 " "$1":"$2}'|sh

删除旧镜像

docker images | grep registry.cn-hangzhou.aliyuncs.com/google_containers|awk '{print "docker rmi " $1":"$2}'|sh

在当前目录导出镜像为压缩包

docker save -o kube-controller-manager-v1.21.0.tar k8s.gcr.io/kube-controller-manager:v1.21.0

docker save -o kube-apiserver-v1.21.0.tar k8s.gcr.io/kube-apiserver:v1.21.0

docker save -o kube-scheduler-v1.21.0.tar k8s.gcr.io/kube-scheduler:v1.21.0

docker save -o kube-proxy-v1.21.0.tar k8s.gcr.io/kube-proxy:v1.21.0

docker save -o coredns-1.6.5.tar k8s.gcr.io/coredns:1.6.5

docker save -o etcd-3.4.3-0.tar k8s.gcr.io/etcd:3.4.3-0

docker save -o pause-3.1.tar [k8s.gcr.io/pause:3.1](http://k8s.gcr.io/pause:3.1)

**calico网络插件依赖镜像 **

Quickstart for Calico on Kubernetes找到calico.yaml文件,命名为calico-v3.10.3.yaml保存到资源包/root/k8sOfflineSetup/plugins目录中。

注意:当前calico的版本3.10.3 已经很老的,可以选择新一点的版本,作者这边拉取的是3.22.2,操作如下:

[root@master01 ~]# curl https://projectcalico.docs.tigera.io/manifests/calico.yaml -O

 % Total % Received % Xferd Average Speed  Time Time  Time Current

 Dload Upload  Total  Spent Left Speed

100 217k 100 217k 0  0 10633 0 0:00:20 0:00:20 --:--:-- 11727

[root@master01 ~]#

[root@master01 ~]# ls

1.sh anaconda-ks.cfg coredns-1.6.5.tar k8sOfflineSetup  kube-controller-manager-v1.21.0.tar kube-scheduler-v1.21.0.tar

2.sh calico.yaml etcd-3.4.3-0.tar  kube-apiserver-v1.21.0.tar kube-proxy-v1.21.0.tar  pause-3.1.tar

[root@master01 ~]# cat calico.yaml | grep -i "Image:"

 image: docker.io/calico/cni:v3.22.2

 image: docker.io/calico/cni:v3.22.2

 image: docker.io/calico/pod2daemon-flexvol:v3.22.2

 image: docker.io/calico/node:v3.22.2

 image: docker.io/calico/kube-controllers:v3.22.2

[root@master01 ~]# cat calico.yaml | grep -i "Image:"|awk '{print "docker pull "$2}'|sh

在当前目录导出镜像为压缩包

docker save -o calico-cni-v3.22.2.tar calico/cni:v3.22.2

docker save -o calico-pod2daemon-flexvol-v3.22.2.tar calico/pod2daemon-flexvol:v3.22.2

docker save -o calico-node-v3.22.2.tar calico/node:v3.22.2

docker save -o calico-kube-controllers-v3.22.2.tar calico/kube-controllers:v3.22.2

同样拉取完成后打包复制到资源包/root/k8sOfflineSetup/images目录中。

[root@master01 ~]# mkdir -p /root/k8sOfflineSetup/images

[root@master01 ~]# mv *.tar /root/k8sOfflineSetup/images/

自此相应的安装包已下载并保存完毕

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,311评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,339评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,671评论 0 342
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,252评论 1 279
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,253评论 5 371
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,031评论 1 285
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,340评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,973评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,466评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,937评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,039评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,701评论 4 323
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,254评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,259评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,485评论 1 262
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,497评论 2 354
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,786评论 2 345

推荐阅读更多精彩内容