master 192.168.2.191
worker1 192.168.2.10
一、设置master主机名、服务器初始化配置
设置虚拟机IP、网关
vi /etc/sysconfig/network-scripts/ifcfg-ens33
service network restart
service network restart
service NetworkManager status
service NetworkManager stop
journalctl -xe
service network restart #虚拟机ip地址被占用,network服务启动不了
1.设置master主机名和/etc/hosts
所有节点配置主机名(其他节点名称可自行更改)
hostnamectl set-hostname k8sadmin
cat /etc/hostname
所有节点配置hosts,修改/etc/hosts如下
cat /etc/hosts
192.168.2.191 k8sadmin
192.168.2.10 k8sadminnode1
vi /etc/hostname
所有节点配置Docker、Kubernetes和默认yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
所有节点安装一些常用的工具
yum install wget jq psmisc vim net-tools telnet git -y
所有节点关闭防火墙、SELinux、DNSmasq:
systemctl disable --now firewalld
systemctl disable --now dnsmasq
systemctl disable --now NetworkManager
setenforce 0
sed -i 's#SELINUX=enforcing#SElINUX=disabled#g' /etc/sysconfig/selinux
sed -i 's#SELINUX=enforcing#SElINUX=disabled#g' /etc/selinux/config
所有节点关闭Swap分区:
swapoff -a && sysctl -w vm.swappiness=0
sysctl -w vm.swappiness=0
sed -ri '/^[^#]*swap/s@^@#@' /etc/fstab
所有节点安装ntpdate(如果公司的服务器已经配置了自动同步时间,关于时间的配置可以不用操作):
yum update
rpm -ivh http://mirrors.wlnmp.com/centos/wlnmp