5

Kubernetes实战(五)——K8s集群搭建环境准备

 2 years ago
source link: https://chegva.com/3037.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Kubernetes实战(五)——K8s集群搭建环境准备

2018年9月16日 by anzhihe·0评论 · 1,452 人阅读 · 隐藏边栏 · 最后更新: 2019/3/23

1.Kubernetes集群部署架构

准备三台虚机:CentOS7 x86_64系统,一台部署Kubernetes Master,两台部署Kubernetes Node。

2.环境准备

1. 设置网络。

如果你的默认 NAT 地址段不是 192.168.56.0/24 可以修改 VMware Workstation 的配置, 点击编辑 -> 虚拟网络配置,然后进行配置。

2. 设置 IP 地址

请配置静态 IP 地址。注意将 UUID 和 和 MAC 地址以及其它配置删除掉,便于进行虚拟机克隆,请参考下面的配置。

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.56.11
NETMASK=255.255.255.0
GATEWAY=192.168.56.2
重启网络服务
[root@localhost ~]# systemctl restart network

3. 关闭 NetworkManager 和防火墙开启自启动

[root@linux-node1 ~]# systemctl disable firewalld
[root@linux-node1 ~]# systemctl disable NetworkManager

4. 设置主机名

[root@localhost ~]# vi /etc/hostname
linux-node1.example.com

5. 设置主机名解析

[root@linux-node1 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.11 linux-node1 linux-node1.example.com
192.168.56.12 linux-node2 linux-node2.example.com
192.168.56.13 linux-node3 linux-node2.example.com

6. 设置 DNS 解析

[root@localhost ~]# vi /etc/resolv.conf
nameserver 192.168.56.2

7. 安装 EPEL 仓库和常用命令

[root@linux-node1 ~]# rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
[root@linux-node1 ~]# yum install -y net-tools vim lrzsz tree screen lsof tcpdump nc mtr nmap

8. 关闭并确认 SELinux 处于关闭状态

[root@linux-node1 ~]# vim /etc/sysconfig/selinux
SELINUX=disabled #修改为disabled

9. 重启

[root@linux-node1 ~]# reboot

10. 克隆虚拟机

请关闭虚拟机,并克隆当前虚拟机 linux-node1 到 linux-node2,建议选择“创建完整克隆” ,而不是“创建链接克隆”。克隆完毕后请给 linux-node2 、linux-node3 设置正确的 IP 地址和主机名。

11. 给虚拟机做快照

分别给三台虚拟机做快照。以便于随时回到一个刚初始化完毕的系统状态。可以有效的减少学习过程中

的环境准备时间。同时,请确保实验环境的一致性,便于顺利的完成所有实验

参考:https://github.com/unixhot/salt-kubernetes

anzhihe安志合个人博客,版权所有丨 如未注明,均为原创 丨转载请注明转自:https://chegva.com/3037.html | ☆★★每天进步一点点,加油!★★☆

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK