2

I want to install the new cluster on 3 machines. I ran this command:

ansible-playbook -i inventory/local/hosts.ini --become --become-user=root cluster.yml

but the installation failed:
TASK [remove-node/pre-remove : remove-node | List nodes] *********************************************************************************************************************************************************
fatal: [node1 -> node1]: FAILED! => {"changed": false, "cmd": ["/usr/local/bin/kubectl", "--kubeconfig", "/etc/kubernetes/admin.conf", "get", "nodes", "-o", "go-template={{ range .items }}{{ .metadata.name }}{{ "\n" }}{{ end }}"], "delta": "0:00:00.057781", "end": "2022-03-16 21:27:20.296592", "msg": "non-zero return code", "rc": 1, "start": "2022-03-16 21:27:20.238811", "stderr": "error: stat /etc/kubernetes/admin.conf: no such file or directory", "stderr_lines": ["error: stat /etc/kubernetes/admin.conf: no such file or directory"], "stdout": "", "stdout_lines": []}

Why the installation step tried to remove and why /etc/kubernetes/admin.conf has not been created?

Please assist.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
shai kam
  • 29
  • 1
  • 3

1 Answers1

2

There could be a couple of ways how can you solve your problem. First look at this github issue. Probably you can manually copy the missing file and it should work:

I solved it myself.

I copied the /etc/kubernetes/admin.conf and /etc/kubernetes/ssl/ca.* to the new node and now the scale playbook works. Maybe this is not the right way, but it worked...

The another way is to use wait for module on Ansible. You can find example of usage in this thread.

To another solution I will recommend to read this similar problem:

cluster_initialized.txt created on first fail and ansible never runs kubeadm init again. just delete that file on fail, fix the problem and run again.

Mikołaj Głodziak
  • 4,775
  • 7
  • 28