kubernetes二进制安装
1、满足条件
- 一台或多台机器,操作系统 CentOS7.x-86_x64
- 硬件配置:2GB或更多RAM,2个CPU或更多CPU,硬盘30GB或更多
- 集群中所有机器之间网络互通
- 可以访问外网,需要拉取镜像
- 禁止swap分区
- kubernetes >= 1.9.0 内核要大于4.4
2、升级内核
#载入公钥
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
#安装ELRepo仓库
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
#载入elrepo-kernel元数据
yum --disablerepo=\* --enablerepo=elrepo-kernel repolist
#查看可用的rpm包
yum --disablerepo=\* --enablerepo=elrepo-kernel list kernel*
#安装最新版本的kernel-ml
yum --disablerepo=\* --enablerepo=elrepo-kernel install -y kernel-ml.x86_64
#查看系统上可以用的内核版本
awk -F\' '$1=="menuentry " {
print i++ " : " $2}' /etc/grub2.cfg
#更改启动项
grub2-mkconfig -o /boot/grub2/grub.cfg && grub2-set-default 0
注意:这里测试环境选择的 ml ,如果正式环境需要选择lt 长期支持内核版本
3、环境准备
角色 | IP |
---|---|
k8s-master | 192.168.1.66 |
k8s-node1 | 192.168.1.67 |
k8s-node2 | 192.168.1.68 |
#关闭防火墙
systemctl status firewalld
systemctl stop firewalld && systemctl disable firewalld
#关闭selinux
sed -i 's/enforcing/disabled/' /etc/selinux/config
setenforce 0
#关闭swap分区
swapoff -a #临时关闭
vim /etc/fstab # 永久关闭
#设置hosts
vim /etc/hosts
192.168.1.66 k8s-master
192.168.1.67 k8s-node1
192.168.1.68 k8s-node2
时间同步
#使用 chronyd 服务,不建议使用ntp
#master:
vim /etc/chrony.conf
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
#node
server 192.168.1.66 iburst
[root@master opt]# chronyc sources
210 Number of sources = 2
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 120.25.115.20 2 6 17 26 -1620us[-1017us] +/- 16ms
^- 203.107.6.88 2 6 17 26 +540us[ +540us] +/- 24ms
[root@node1 opt]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^? 192.168.1.66 0 6 0 - +0ns[ +0ns] +/- 0ns
[root@node2 opt]# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
============================================================================