前言
实验环境
节点角色 | 主机名 | 内存 | 硬盘 | IP地址 |
---|
master Node | master | 8G | 100G | 192.168.58.6 |
Worker Node | node | 8G | 100G | 192.168.58.11 |
Harbor | master | 8G | 100G | 192.168.58.6 |

1、基础环境部署
[root@controller ~]
.
├── anaconda-ks.cfg
├── CentOS-7-x86_64-DVD-1804.iso
├── chinaskills_cloud_iaas.iso
└── chinaskills_cloud_paas.iso
[root@controller ~]
[centos]
name = centos
baseurl = ftp://controller/centos
gpgcheck = 0
enabled = 1
[iaas]
name = iaas
baseurl = ftp://controller/OpenStack/iaas-repo
gpgcheck = 0
enabled = 1
[root@controller ~]
/opt/
├── centos
│ ├── CentOS_BuildTag
│ ├── EFI
│ ├── EULA
│ ├── GPL
│ ├── images
│ ├── isolinux
│ ├── LiveOS
│ ├── Packages
│ ├── repodata
│ ├── RPM-GPG-KEY-CentOS-7
│ ├── RPM-GPG-KEY-CentOS-Testing-7
│ └── TRANS.TBL
└── OpenStack
├── iaas-repo
└── images
[root@controller ~]
The authenticity of host '192.168.58.6 (192.168.58.6)' can't be established.
ECDSA key fingerprint is SHA256:FqTDtd28812m1IAFRjAbURuwoPQQRbq7gqGrEYh77C4.
ECDSA key fingerprint is MD5:1a:d0:c6:aa:89:3a:1c:ed:c6:21:1d:dc:4d:63:e8:33.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.58.6' (ECDSA) to the list of known hosts.
root@192.168.58.6's password:
1.1、系统初始化配置(master和node)
1.1.1、修改主机名
[root@docker-1 ~]
[root@docker-1 ~]
[root@master ~]
Static hostname: master
Icon name: computer-vm
Chassis: vm
Machine ID: 622ba110a69e24eda2dca57e4d306baa
Boot ID: 51064e086449407987e3a42a3e53547b
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-862.2.3.el7.x86_64
Architecture: x86-64
[root@docker-2 ~]
[root@docker-2 ~]
[root@node ~]
Static hostname: node
Icon name: computer-vm
Chassis: vm
Machine ID: 622ba110a69e24eda2dca57e4d306baa
Boot ID: 493bc83d9ecb4e36bba1cec5fd1c2328
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-862.2.3.el7.x86_64
Architecture: x86-64
1.1.2、配置主机名映射
[root@master ~]
[root@master ~]
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.6 master
10.0.0.21 node
[root@master ~]
The authenticity of host 'node (10.0.0.21)' can't be established.
ECDSA key fingerprint is SHA256:FqTDtd28812m1IAFRjAbURuwoPQQRbq7gqGrEYh77C4.
ECDSA key fingerprint is MD5:1a:d0:c6:aa:89:3a:1c:ed:c6:21:1d:dc:4d:63:e8:33.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node,10.0.0.21' (ECDSA) to the list of known hosts.
hosts 100% 190 1.6KB/s 00:00
[root@node ~]
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.6 master
10.0.0.21 node

1.1.3、关闭防火墙和SElinux
[root@master ~]
[root@master ~]
[root@master ~]
[root@master ~]
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@master ~]
*filter
:INPUT ACCEPT [33:1948]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [20:1936]
COMMIT
[root@master ~]
[root@master ~]
setenforce: SELinux is disabled
[root@master ~]
Disabled
systemctl stop firewalld
systemctl disable firewalld
1.1.4、配置yum源
[root@master opt]
chinaskills_cloud_paas.iso
[root@master opt]
mount: /dev/loop0 is write-protected, mounting read-only
[root@master opt]
total 64
dr-xr-xr-x 1 root root 2048 Oct 23 2020 ChinaskillMall
dr-xr-xr-x 1 root root 2048 Oct 23 2020 ChinaskillProject
dr-xr-xr-x 1 root root 2048 Oct 23 2020 docker-compose
dr-xr-xr-x 1 root root 2048 Oct 23 2020 harbor
dr-xr-xr-x 1 root root 6144 Oct 23 2020 images
-r-xr-xr-x 1 root root 3049 Oct 21 2020 k8s_harbor_install.sh
-r-xr-xr-x 1 root root 5244 Oct 21 2020 k8s_image_push.sh
-r-xr-xr-x 1 root root 1940 Oct 21 2020 k8s_master_install.sh
-r-xr-xr-x 1 root root 3055 Oct 21 2020 k8s_node_install.sh
dr-xr-xr-x 1 root root 20480 Oct 23 2020 kubernetes-repo
dr-xr-xr-x 1 root root 14336 Oct 23 2020 plugins
dr-xr-xr-x 1 root root 2048 Oct 23 2020 yaml
[root@master opt]
[root@master opt]
[root@master opt]
[centos]
name = centos
baseurl = ftp://controller/centos
gpgcheck = 0
enabled = 1
[k8s]
name = kubernetes-repo
baseurl = file:///opt/kubernetes-repo
gpgcheck = 0
enabled = 1
[root@master opt]
Loaded plugins: fastestmirror
Cleaning repos: centos k8s
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
Loaded plugins: fastestmirror
Determining fastest mirrors
centos | 3.6 kB 00:00:00
k8s | 3.0 kB 00:00:00
(1/7): centos/group_gz | 166 kB 00:00:00
(2/7): centos/filelists_db | 3.1 MB 00:00:00
(3/7): centos/primary_db | 3.1 MB 00:00:00
(4/7): centos/other_db | 1.3 MB 00:00:00
(5/7): k8s/filelists_db | 138 kB 00:00:00
(6/7): k8s/primary_db | 161 kB 00:00:00
(7/7): k8s/other_db | 80 kB 00:00:00
Metadata Cache Created
[root@master opt]
Installed:
tree.x86_64 0:1.6.0-10.el7 vsftpd.x86_64 0:3.0.2-27.el7
Updated:
net-tools.x86_64 0:2.0-0.25.20131004git.el7
[root@master opt]
[root@master opt]
anon_root=/opt
[root@master opt]
[root@master opt]
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
[root@master opt]
baseurl = ftp://controller/centos
baseurl = ftp://master/kubernetes-repo
[root@master opt]
Loaded plugins: fastestmirror
Cleaning repos: centos k8s
Cleaning up everything
...
Metadata Cache Created
[root@node ~]
[root@master opt]
ftp.repo 100% 176 120.6KB/s 00:00
[root@node ~]
ftp.repo
[root@node ~]
Loaded plugins: fastestmirror
Cleaning repos: centos k8s
Cleaning up everything
...
Metadata Cache Created
[root@node ~]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name status
centos centos 3,971
k8s kubernetes-repo 168
repolist: 4,139
1.2、部署Harbor仓库
[root@master opt]

# Harbor 默认账号:admin
# Harbor 默认密码:Harbor12345

1.3、上传镜像到Harbor仓库
[root@master opt]
输入镜像仓库地址(不加http/https): 192.168.58.6
输入镜像仓库用户名: admin
输入镜像仓库用户密码: Harbor12345
您设置的仓库地址为: 192.168.58.6,用户名: admin,密码: xxx
是否确认(Y/N): y




1.4、部署Kubernetes集群
[root@master opt]



1.5、将node节点加入集群
[root@master opt]
k8s_node_install.sh 100% 3055 1.7MB/s 00:00
[root@node opt]


