# 一、服务器准备
|名称|IP|组件|
|--|--|--|
|k8s-master1|192.168.72.166|kube-apiserver kube-controller-manage kube-scheduler etcd|
|k8s-master2|192.168.72.167|kube-apiserver kube-controller-manage kube-scheduler|
|k8s-node1|192.168.72.168|kubelet kube-proxy docker etcd |
|k8s-node2|192.168.72.169 |kubelet kube-proxy docker etcd|
|Load Balancer(Master)|192.168.72.170 192.168.72.171(VIP)|Nginx L4 |
|Load Balancer(Master)|192.168.72.172|Nginx L4 |
# 二、所有操作系统初始化
这里我们搭建一台主节点(192.168.72.166、192.168.72.167),和两台从节点(192.168.72.168、192.168.72.169)
1、关闭防火墙:
```
systemctl stop firewalld #关闭
systemctl status firewalld #状态
systemctl disable firewalld #设置开机禁用防火墙
```
2、关闭selinux:
```
getenforce #查看
setenforce 0 # 临时关闭
sed -i 's/enforcing/disabled/' /etc/selinux/config # 永久关闭
```
3、关闭swap:
```
swapoff -a # 临时
vim /etc/fstab # 永久
```
4、同步系统时间:
```
ntpdate time.windows.com
```
5、添加hosts:
```
vim /etc/hosts
```
```
192.168.72.166 k8s-master1
192.168.72.167 k8s-master2
192.168.72.168 k8s-node1
192.168.72.169 k8s-node2
```
6、修改主机名:
这里需要修改成你hosts中配置的主机名
```
hostnamectl set-hostname k8s-master(主机名)
```