You can get that error if your "kubeadm" cannot connect to the Kubernetes cluster using credentials from the configuration file. You can reproduce it by stopping the docker service on your master node.
There is no difference between running the command using Ansible or shell in your case, so it should work.
So, the only things I can suggest are:
- Verify that the Ansible role
masteris attached to the right host. - Check if the Ansible user has access to the
kubeadmconfiguration, its default path is/etc/kubernetes/admin.conf, and make sure that configuration is right. You might try to run the command as root using thebecome: trueoption.
kubernetes - kubeadm token create with Ansible - Stack Overflow
Ansible module for kubeadm
Capturing the kubeadm join command from kubeadm init
you can generate a join command command "on-demand" by running the following on a master
kubeadm token create --print-join-command
Dump it to a file with
kubeadm token create --print-join-command > /tmp/join.sh
However I find it easier to specify the token during init, this way you alreay know the join command for the workers
More on reddit.comAnsible playbook for kubeadm based installation of latest version of kubernetes
Videos
You can get that error if your "kubeadm" cannot connect to the Kubernetes cluster using credentials from the configuration file. You can reproduce it by stopping the docker service on your master node.
There is no difference between running the command using Ansible or shell in your case, so it should work.
So, the only things I can suggest are:
- Verify that the Ansible role
masteris attached to the right host. - Check if the Ansible user has access to the
kubeadmconfiguration, its default path is/etc/kubernetes/admin.conf, and make sure that configuration is right. You might try to run the command as root using thebecome: trueoption.
There was a proxy configuration set in the ansible playbook:
---
- hosts: [vmsk8s]
roles:
- vmsk8s
environment:
http_proxy: http://10.0.0.1:3128
https_proxy: http://10.0.0.1:3128
Removing the proxy environment vars fixed the problem.
Is there such a thing?
Running kubeadm init commands with the shell / command module makes me feel itchy.