Setup cluster kubernetes 3 node with kubeadm using ansible

Environment

hostnameiposnginx versionvirtualizationnote
ops-master10.10.10.6020.04.6 LTS (Focal Fossa)nginx version: nginx/1.18.0 (Ubuntu)kvmLoadbalancer & client servers
ops-worker-110.10.10.6120.04.6 LTS (Focal Fossa)nginx version: nginx/1.18.0 (Ubuntu)kvmclient servers
ops-worker-210.10.10.6220.04.6 LTS (Focal Fossa)nginx version: nginx/1.18.0 (Ubuntu)kvmclient servers

Setup ssh

Setup ssh for all node for ssh passwordless to user

execute from master-1

1
ssh-keygen -t rsa

copy /.ssh/id.rsa.pub to all node

1
cat ~/.ssh/id_rsa.pub

insert id_rsa.pub master to all worker node

1
nano ~/.ssh/authorized_keys


after insert idrsa.pub , test ssh to all worker node to user root , make sure the ssh passwordless

Setup ansible

Install ansible on master node

1
sudo apt install software-properties-common -y
1
sudo add-apt-repository --yes --update ppa:ansible/ansible
1
sudo apt install ansible -y

makesure ansible has been installed

1
ansible --version