geerlingguy / ansible-for-devops

Ansible for DevOps examples.
https://www.ansiblefordevops.com
MIT License
8.47k stars 3.47k forks source link

kubernetes does not create an admin.conf file to sym link #108

Closed srufle closed 5 years ago

srufle commented 6 years ago

After the error mentioned below. I set kubernetes_kubelet_extra_args: '--node-ip={{ ansible_host }}' to kubernetes_kubelet_extra_args: '--node-ip=192.168.84.2'

to force an ip since in the book it says inventory_hostname not ansible_host and then did another vagrant provision

TASK [geerlingguy.kubernetes : Initialize Kubernetes master with kubeadm init.] ***
changed: [master]

TASK [geerlingguy.kubernetes : Print the init output to screen.] ***************
ok: [master] => {
    "kubeadmin_init.stdout": ""
}
...
TASK [geerlingguy.kubernetes : Symlink the kubectl admin.conf to ~/.kube/conf.] ***
fatal: [master]: FAILED! => {"changed": false, "msg": "src file does not exist, use \"force=yes\" if you really want to create the link: /etc/kubernetes/admin.conf", "path": "/root/.kube/config", "src": "/etc/kubernetes/admin.conf", "state": "absent"}
geerlingguy commented 6 years ago

@srufle - Interesting; the symlink task shouldn't fail because of a change to the --node-ip anyways; I wonder if this is related to Kubernetes 1.12 or the latest 1.13 alpha releases...

I had to change the geerlingguy.kubernetes role a bit to make sure you can choose which release you want to install, but I haven't tested the book example in a month or so, and that might be slightly broken now :/

geerlingguy commented 5 years ago

I will test the book's Kubernetes example shortly; the upstream role has seen a few additional changes for stability, and I also added some fixes and tested with Kubernetes 1.13.x on my Pi Dramble cluster (both on the Pis and in Vagrant), so it should definitely work once I'm through with it!

geerlingguy commented 5 years ago

I got the same failure — first the master goes then the two nodes:

TASK [geerlingguy.kubernetes : Symlink the kubectl admin.conf to ~/.kube/conf.] ***
fatal: [master]: FAILED! => {"changed": false, "msg": "src file does not exist, use \"force=yes\" if you really want to create the link: /etc/kubernetes/admin.conf", "path": "/root/.kube/config", "src": "/etc/kubernetes/admin.conf", "state": "absent"}

TASK [geerlingguy.kubernetes : Get the kubeadm join command from the Kubernetes master.] ***
skipping: [node1]
skipping: [node2]

TASK [geerlingguy.kubernetes : Set the kubeadm join command globally.] *********
skipping: [node1] => (item=node1) 
skipping: [node1] => (item=node2) 
skipping: [node1] => (item=master) 
skipping: [node2] => (item=node1) 
skipping: [node2] => (item=node2) 
skipping: [node2] => (item=master) 

TASK [geerlingguy.kubernetes : include_tasks] **********************************
included: /Users/jgeerling/Dropbox/VMs/roles/geerlingguy.kubernetes/tasks/node-setup.yml for node1, node2

TASK [geerlingguy.kubernetes : Join node to Kubernetes master] *****************
fatal: [node1]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'kubernetes_join_command' is undefined\n\nThe error appears to have been in '/Users/jgeerling/Dropbox/VMs/roles/geerlingguy.kubernetes/tasks/node-setup.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Join node to Kubernetes master\n  ^ here\n"}
fatal: [node2]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'kubernetes_join_command' is undefined\n\nThe error appears to have been in '/Users/jgeerling/Dropbox/VMs/roles/geerlingguy.kubernetes/tasks/node-setup.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Join node to Kubernetes master\n  ^ here\n"}

Trying with Kubernetes 1.13 now.

geerlingguy commented 5 years ago

So far so good with Kubernetes 1.13. Going to keep prodding and make sure it all works, then update the book and push my fix up to this project.

geerlingguy commented 5 years ago

I can confirm that the above commit fixed the original issue reported by @srufle - thanks for the report! I'll credit you with identifying the issue in the errata logs :)

srufle commented 5 years ago

Ok, thanks, that sounds great.