- 在新增结点上执行如下操作:
systemctl stop firewalld
systemctl disable firewalld
rm /etc/yum.repos.d/*.repo -f
echo "nameserver 114.114.118.110" > /etc/resolv.conf
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
cd /etc/pki/rpm-gpg/
wget https://archive.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
setenforce 0
sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
yum install -y epel-release
yum install -y python-pip
yum install -y python36 python36-pip
pip install --upgrade pip
pip install netaddr
pip install --upgrade jinja2
并在原有集群的ansible-cilent使用ssh-copy-id root@192.168.0.8的方式生成免密登录
并修改ansible-cilent所在服务器的/etc/hosts文件,将新增的结点加入
-
修改原有kubespray安装目录下的host.ini文件, 例如:inventory/mycluster/hosts.ini,必须与原有k8s集群的相同,增加新的结点
-
执行ansible-playbook -i inventory/mycluster/hosts.ini scale.yml 即可
-
如果需要减去结点,只要修改hosts.ini文件,减少对应的结点,之后执行
ansible-playbook -i inventory/mycluster/hosts.ini remove-node.yml -b -v