K8S安装部署 初始化操作(一)
准备好服务器和服务器资源。
·
准备好服务器和服务器资源
hostname | ip | 资源 (2核2G也可以) |
k8s-master | 192.168.37.118 | 4核 4G 40G硬盘 |
k8s-node1 | 192.168.37.119 | 2核 2G 20G硬盘 |
k8s-node2 | 192.168.37.120 | 2核 2G 20G硬盘 |
初始操作三台同时执行
1、关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# 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@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
Jul 18 16:47:47 localhost.localdomain systemd[1]: Starting firewalld - dynam...
Jul 18 16:47:48 localhost.localdomain systemd[1]: Started firewalld - dynami...
Jul 18 16:47:48 localhost.localdomain firewalld[824]: WARNING: AllowZoneDrif...
Jul 18 17:02:28 localhost.localdomain systemd[1]: Stopping firewalld - dynam...
Jul 18 17:02:28 localhost.localdomain systemd[1]: Stopped firewalld - dynami...
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#
2、关闭 selinux
sed -i 's/enforcing/disable/' /etc/selinux/config
[root@localhost ~]# cat /etc/selinux/config |grep disable
# disable - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of disable.
# disabled - No SELinux policy is loaded.
SELINUX=disable
3、关闭swap分区
sed -ri 's/.*swap.*/#&/' /etc/fstab
4、修改服务器名称
hostnamectl set-hostname <hostname>
添加hosts
[root@localhost ~]# hostnamectl set-hostname k8s-master
[root@localhost ~]# hostname
k8s-master
[root@localhost ~]# cat >> /etc/hosts
hosts hosts.allow hosts.deny
[root@localhost ~]# cat >> /etc/hosts <<EOF
> 192.168.37.118 k8s-master
> 192.168.37.119 k8s-node1
> 192.168.37.120 k8s-node2
> EOF
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.37.118 k8s-master
192.168.37.119 k8s-node1
192.168.37.120 k8s-node2
5、同步时间
yum install ntpdate -y
ntpdate time.windows.com
18 Jul 17:24:47 ntpdate[17423]: adjust time server 52.231.114.183 offset 0.015404 sec
6、IPv4流量传递到iptables的链
[root@localhost ~]# cat > /etc/sysctl.conf/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
cat /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
[root@k8s-master ~]# sysctl --system 执行生效
* Applying /usr/lib/sysctl.d/00-system.conf ...
* Applying /usr/lib/sysctl.d/10-default-yama-scope.conf ...
7、重启服务器
swap生效 即可
[root@k8s-master ~]# free -m
total used free shared buff/cache available
Mem: 3770 266 3327 11 176 3293
Swap: 0 0 0
第二章 k8s环境部署
更多推荐
已为社区贡献3条内容
所有评论(0)