安装教程:
http://www.rhce.cc/2182.html
https://blog.csdn.net/wo18237095579/article/details/86630750
https://www.cnblogs.com/zhongle21/p/12220789.html#_lab2_0_2
一、所有节点
1、在所有节点上修改hostname
hostnamectl set-hostname master
hostnamectl set-hostname node
2、在所有节点上修改ip
vi /etc/sysconfig/network-scripts/ifcfg-ens33
注意事项:(1)BOOTPROTO=static
(2)ONBOOT=yes
(3)IPADDR=10.4.7.23
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=cf12d995-ca97-4e6e-9f08-bdc547ee9478
DEVICE=ens33
ONBOOT=yes
IPADDR=10.4.7.23
NETMASK=255.255.255.0
GATEWAY=10.4.7.1
DNS1=8.8.8.8
DNS2=114.114.114.114
ZONE=public
service network restart
3、在所有节点上同步/etc/hosts
vi /etc/hosts
/etc/init.d/network restart
注意事项:(1)151.101.108.133 raw.githubusercontent.com,这一行是防止配置flannel时连接不上raw.githubusercontent.com
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.133.99 Centos dbserver
10.4.7.23 kubeadm1
10.4.7.24 kubeadm2
151.101.108.133 raw.githubusercontent.com
4、在所有节点上配置防火墙和关闭selinux
systemctl disable firewalld.service
systemctl stop firewalld.service
setenforce 0
swapoff -a
vim /etc/selinux/config
SELINUX=disabled
5、在所有节点上关闭swap
swapoff -a
6、在所有节点上配置好yum源
vi /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes Repo
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
7、在所有节点安装并启动docker,并设置docker自动启动
yum install docker -y
systemctl enable docker --now
8、在所有节点设置相关属性
vi /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
vm.swappiness=0
9、在所有节点上安装软件包
yum install -y kubelet-1.18.2-0 kubeadm-1.18.2-0 kubectl-1.18.2-0 --disableexcludes=kubernetes
yum install -y kubelet-1.18.2-0 kubeadm-1.18.2-0 kubectl-1.18.2-0 --disableexcludes=kubernetes
10、在所有节点上启动kubelet,并设置开机自动启动
systemctl restart kubelet
systemctl enable kubelet
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> /etc/profile
source /etc/profile
echo $KUBECONFIG
scp /etc/kubernetes/admin.conf root@10.4.7.21:/etc/kubernetes/
11、修改阿里云的源