K8s介绍及离线安装(二)
一、离线实验环境
示例:使用vm虚拟机,硬件配置:2核2G40G虚拟机三台
机器名 | IP地址 |
---|---|
offline-k8s01 | 172.30.161.85 |
offline-k8s02 | 172.30.161.86 |
offline-k8s03 | 172.30.161.87 |
二、通用基础设置
1.通用基础操作设置
#各个机器设置自己的域名
hostnamectl set-hostname xxxx
# 将 SELinux 设置为 permissive 模式(相当于将其禁用)
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
#关闭swap
swapoff -a
sed -ri 's/.*swap.*/#&/' /etc/fstab
#关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
2.安装ntp时间同步
offline-k8s01设为master
yum -y install ntp && systemctl enable ntpd && systemctl start ntpd
vi /etc/ntp.conf
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 172.30.161.85 nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 127.127.1.0
Fudge 127.127.1.0 stratum 10
其余两台机器offline-k8s02,offline-k8s03都需安装ntp,并且和offline-k8s01同步
yum -y install ntp && systemctl enable ntpd && systemctl start ntpd
vi /etc/ntp.conf
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 172.30.161.86 nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 172.30.161.254 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 172.30.161.85
Fudge 172.30.161.85 stratum 10
过5分钟检查是否同步
ntpstat
synchronised to unspecified (172.30.161.85) at stratum 7
time correct to within 280 ms
polling server every 1024 s
3.每台机器host新增
echo "172.30.161.85 offline-k8s01 k8s1.com" >> /etc/hosts
或者
vi /etc/hosts
172.30.161.85 offline-k8s01 k8s1.com
172.30.161.86 offline-k8s02 k8s2.com
172.30.161.87 offline-k8s03 k8s3.com
4.ssh免密登录
ssh-keygen -t rsa #一路回车
ssh-copy-id 172.30.161.85 #yes后输入密码
ssh-copy-id 172.30.161.86 #yes后输入密码
ssh-copy-id 172.30.161.87 #yes后输入密码
总结
例如:以上就是基础的linux设置,下一篇离线安装docker。