kubernetes集群要新增node,首先要配置ssh免密登陆
root@ht:/etc/ansible# ssh-copy-id 172.18.196.6 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keysroot@172.18.196.6's password: Permission denied, please try again.root@172.18.196.6's password: Permission denied, please try again.root@172.18.196.6's password: Permission denied (publickey,password).
这里出现Permission denied, please try again.出现这个问题应该是服务端SSH 服务配置了禁止root用户登录策略。
所以进入服务端172.18.196.6修改配置
/etc/ssh/sshd_config
将PermitRootLogin改成yes#PermitRootLogin prohibit-passwordPermitRootLogin yes
然后重启ssh服务
service sshd restart
如果还错误的话,也可以修改一下ssh的密码
ssh-keygen -t rsa -b 2048
passwd root
再尝试建立就可以了
然后修改hosts文件
...# 预留组,后续添加node节点使用[new-node]172.18.196.6 NODE_ID=node6 NODE_IP="172.18.196.6"...
再运行
cd /etc/ansible && ansible-playbook 20.addnode.yml