最完整,最详细的离线部署kubernetes

 我的服务器完全无法访问互联网,所以所有部署都是离线的,用到的组件全都是我从网上下载好,然后通过内网传上去的。当然我会把相关组件包上传到网盘,大家自己去下载就好

所有组件及依赖包去网盘下载,链接如下 

链接: https://pan.baidu.com/s/1KUjX6HQhUQZtiXhZD7_faQ 提取码: 9uka 复制这段内容后打开百度网盘手机App,操作更方便哦

MasterNode:192.168.200.101

WorkNode:192.168.200.103/192.168.200.104/192.168.200.105/192.168.200.106

操作系统版本

[root@Work-Node3 ~]# 
[root@Work_Node3 ~]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
[root@Work-Node3 ~]# 

 Docker Version:docker-ce-18.09.9-3

Kubenetes Version:kubeadm-1.17.4

1. 挂载ISO装完系统,修改主机名

[root@localhost ~]# hostnamectl set-hostname --static Master-Node1
[root@localhost ~]# hostname
Master-Node1
[root@localhost ~]# 

2. 修改hosts文件,节点之间相互解析

[root@Master-Node1 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.101 Master-Node1
192.168.200.103 Work-Node1
192.168.200.104 Work-Node2
192.168.200.105 Work-Node3
192.168.200.106 Work-Node4
[root@Master-Node1 ~]# 

3. 关闭禁用防火墙

[root@Master-Node1 ~]# 
[root@Master-Node1 ~]# systemctl stop firewalld
[root@Master-Node1 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@Master-Node1 ~]# 

4. 禁用selinux

[root@Master-Node1 ~]# sed -i 's/enforcing/disabled/' /etc/selinux/config
[root@Master-Node1 ~]# getenforce
Enforcing
[root@Master-Node1 ~]# 

5. 关闭swap

[root@Master-Node1 kube_deploy]# swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
[root@Master-Node1 kube_deploy]# free -m
              total        used        free      shared  buff/cache   available
Mem:           7802         378        3503          83        3920        7044
Swap:             0           0           0
[root@Master-Node1 kube_deploy]# 

5. 设置时区

[root@Master-Node1 ~]# timedatectl set-timezone Asia/Shanghai
[root@Master-Node1 ~]# timedatectl
      Local time: Tue 2024-01-23 22:09:07 CST
  Universal time: Tue 2024-01-23 14:09:07 UTC
        RTC time: Tue 2024-01-23 14:10:07
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

6. 初始化内核参数

[root@Master-Node1 ~]# cat > kubernetes.conf <<EOF
> net.bridge.bridge-nf-call-iptables=1
> net.bridge.bridge-nf-call-ip6tables=1
> net.ipv4.ip_forward=1
> net.ipv4.tcp_tw_recycle=0
> vm.swappiness=0     # 禁止使用 swap 空间,只有当系统 OOM 时才允许使用它
> vm.overcommit_memory=1   # 不检查物理内存是否够用
> vm.panic_on_oom=0 # 开启 OOM
> fs.inotify.max_user_instances=8192
> fs.inotify.max_user_watches=1048576
> fs.file-max=52706963
> fs.nr_open=52706963
> net.ipv6.conf.all.disable_ipv6=1
> net.netfilter.nf_conntrack_max=2310720
> EOF
[root@Master-Node1 ~]# 

7. 拷贝刚刚创建的文件到/etc/sysctl.d/

[root@Master-Node1 ~]# cp kubernetes.conf /etc/sysctl.d/kubernetes.conf
[root@Master-Node1 ~]# 

8. 配置时钟同步chronyc,所有节点从master node同步时钟,编辑/etc/chronyc.conf文件

#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst            //注释掉这4行,新起一行,指定本机为服务端
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 127.0.0.1 iburst

allow 192.168.200.0/25             //允许哪些地址来这个服务器同步时钟

local stratum 10    //取消这一行的注释 


9. chronyc 客户端配置,客户端配置比较简单,编辑/etc/chronyc.conf文件

server 192.168.200.101 iburst

10. 配置完成后重启服务端和客户端的chronyd服务,并查看时钟同步状态

[root@Master-Node1 ~]# systemctl restart chronyd
[root@Master-Node1 ~]# chronyc sources -v
210 Number of sources = 1

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? localhost                     0   6     0     -     +0ns[   +0ns] +/-    0ns
[root@Master-Node1 ~]# 


[root@Work-Node2 ~]# systemctl restart chronyd
[root@Work-Node2 ~]# chronyc sources -v
210 Number of sources = 1

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 192.168.200.101              10   6    17    11  -1956us[-1962us] +/- 2212us
[root@Work-Node2 ~]# timedatectl
      Local time: Tue 2024-01-23 23:15:45 CST
  Universal time: Tue 2024-01-23 15:15:45 UTC
        RTC time: Tue 2024-01-23 15:15:45
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
[root@Work-Node2 ~]# 

11. 安装docker-ce-cli-18.09.9-3.el7.x86_64.rpm

[root@Master-Node1 kube_deploy]# yum localinstall docker-ce-cli-18.09.9-3.el7.x86_64.rpm 
Loaded plugins: fastestmirror, langpacks
Examining docker-ce-cli-18.09.9-3.el7.x86_64.rpm: 1:docker-ce-cli-18.09.9-3.el7.x86_64
Marking docker-ce-cli-18.09.9-3.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package docker-ce-cli.x86_64 1:18.09.9-3.el7 will be installed
--> Finished Dependency Resolution
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

Dependencies Resolved

==================================================================================================================================================================
 Package                           Arch                       Version                               Repository                                               Size
==================================================================================================================================================================
Installing:
 docker-ce-cli                     x86_64                     1:18.09.9-3.el7                       /docker-ce-cli-18.09.9-3.el7.x86_64                      72 M

Transaction Summary
==================================================================================================================================================================
Install  1 Package

Total size: 72 M
Installed size: 72 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:docker-ce-cli-18.09.9-3.el7.x86_64                                                                                                           1/1 
  Verifying  : 1:docker-ce-cli-18.09.9-3.el7.x86_64                                                                                                           1/1 

Installed:
  docker-ce-cli.x86_64 1:18.09.9-3.el7                                                                                                                            

Complete!
[root@Master-Node1 kube_deploy]# 

12. 安装audit-libs-python-2.8.5-4.el7.x86_64.rpm 

[root@Master-Node1 kube_deploy]# yum localinstall audit-libs-python-2.8.5-4.el7.x86_64.rpm 
Loaded plugins: fastestmirror, langpacks
Examining audit-libs-python-2.8.5-4.el7.x86_64.rpm: audit-libs-python-2.8.5-4.el7.x86_64
Marking audit-libs-python-2.8.5-4.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
--> Finished Dependency Resolution
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

Dependencies Resolved

==================================================================================================================================================================
 Package                               Arch                       Version                         Repository                                                 Size
==================================================================================================================================================================
Installing:
 audit-libs-python                     x86_64                     2.8.5-4.el7                     /audit-libs-python-2.8.5-4.el7.x86_64                     316 k

Transaction Summary
==================================================================================================================================================================
Install  1 Package

Total size: 316 k
Installed size: 316 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                           1/1 
  Verifying  : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                           1/1 

Installed:
  audit-libs-python.x86_64 0:2.8.5-4.el7                                                                                                                          

Complete!
[root@Master-Node1 kube_deploy]# 

13. 安装libsemanage-python-2.5-14.el7.x86_64.rpm 

[root@Master-Node1 kube_deploy]# yum localinstall libsemanage-python-2.5-14.el7.x86_64.rpm 
Loaded plugins: fastestmirror, langpacks
Examining libsemanage-python-2.5-14.el7.x86_64.rpm: libsemanage-python-2.5-14.el7.x86_64
Marking libsemanage-python-2.5-14.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
--> Finished Dependency Resolution
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

Dependencies Resolved

==================================================================================================================================================================
 Package                                Arch                       Version                        Repository                                                 Size
==================================================================================================================================================================
Installing:
 libsemanage-python                     x86_64                     2.5-14.el7                     /libsemanage-python-2.5-14.el7.x86_64                     441 k

Transaction Summary
==================================================================================================================================================================
Install  1 Package

Total size: 441 k
Installed size: 441 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libsemanage-python-2.5-14.el7.x86_64                                                                                                           1/1 
  Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                                                                           1/1 

Installed:
  libsemanage-python.x86_64 0:2.5-14.el7                                                                                                                          

Complete!
[root@Master-Node1 kube_deploy]# 

14. 安装setools-libs-3.3.8-4.el7.x86_64.rpm

[root@Master-Node1 kube_deploy]# yum localinstall setools-libs-3.3.8-4.el7.x86_64.rpm 
Loaded plugins: fastestmirror, langpacks
Examining setools-libs-3.3.8-4.el7.x86_64.rpm: setools-libs-3.3.8-4.el7.x86_64
Marking setools-libs-3.3.8-4.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Finished Dependency Resolution
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

Dependencies Resolved

==================================================================================================================================================================
 Package                            Arch                         Version                             Repository                                              Size
==================================================================================================================================================================
Installing:
 setools-libs                       x86_64                       3.3.8-4.el7                         /setools-libs-3.3.8-4.el7.x86_64                       1.8 M

Transaction Summary
==================================================================================================================================================================
Install  1 Package

Total size: 1.8 M
Installed size: 1.8 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : setools-libs-3.3.8-4.el7.x86_64                                                                                                                1/1 
  Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                                                                                1/1 

Installed:
  setools-libs.x86_64 0:3.3.8-4.el7                                                                                                                               

Complete!
[root@Master-Node1 kube_deploy]# 

15. 安装checkpolicy-2.5-8.el7.x86_64.rpm

[root@Master-Node1 kube_deploy]# yum localinstall checkpolicy-2.5-8.el7.x86_64.rpm 
Loaded plugins: fastestmirror, langpacks
Examining checkpolicy-2.5-8.el7.x86_64.rpm: checkpolicy-2.5-8.el7.x86_64
Marking checkpolicy-2.5-8.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
--> Finished Dependency Resolution
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

Dependencies Resolved

==================================================================================================================================================================
 Package                             Arch                           Version                           Repository                                             Size
==================================================================================================================================================================
Installing:
 checkpolicy                         x86_64                         2.5-8.el7                         /checkpolicy-2.5-8.el7.x86_64                         1.2 M

Transaction Summary
==================================================================================================================================================================
Install  1 Package

Total size: 1.2 M
Installed size: 1.2 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : checkpolicy-2.5-8.el7.x86_64                                                                                                                   1/1 
  Verifying  : checkpolicy-2.5-8.el7.x86_64                                                                                                                   1/1 

Installed:
  checkpolicy.x86_64 0:2.5-8.el7                                                                                                                                  

Complete!
[root@Master-Node1 kube_deploy]# 

16. 安装 libcgroup-0.41-21.el7.x86_64.rpm

[root@Master-Node1 kube_deploy]# yum localinstall libcgroup-0.41-21.el7.x86_64.rpm 
Loaded plugins: fastestmirror, langpacks
Examining libcgroup-0.41-21.el7.x86_64.rpm: libcgroup-0.41-21.el7.x86_64
Marking libcgroup-0.41-21.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
--> Finished Dependency Resolution
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值