Using Vagrant/Ansible to spin up a multi-node kubernetes cluster fails detecting kubelet file

7/12/2019

I am following instructions on site to spin up a multi-node kubernetes cluster using vagrant/ansible. Unfortunately, I get following error:

TASK [Configure node ip] *******************************************************
fatal: [k8s-master]: FAILED! => {"changed": false, "msg": "Destination /etc/default/kubelet does not exist !", "rc": 257}

The relevant passage in the Vagrantfile is:

- name: Install Kubernetes binaries
    apt:
      name: "{{ packages }}"
      state: present
      update_cache: yes
    vars:
      packages:
        - kubelet
        - kubeadm
        - kubectl

  - name: Configure node ip
    lineinfile:
      path: /etc/default/kubelet
      line: KUBELET_EXTRA_ARGS=--node-ip={{ node_ip }}

Is it just the wrong path? Which one would it be then ?

P.S.: I also get a warning beforehand indicating:

[WARNING]: Could not find aptitude. Using apt-get instead

Is it not installing the kubelet package and might that be the reason why it doesn't find the file ? How to fix it in that case ?

-- Paul Rousseau
ansible
kubernetes
vagrant

1 Answer

7/12/2019

Updating the node ip in the config file is not required. If you still wanted to change for any specific reason, below is the solution.

You can change the file to /etc/systemd/system/kubelet.service.d/10-kubeadm.conf as per the change

Before you change, please check if this file exists in the nodes.

/etc/default/kubelet is for yum package.

-- Prakash Krishna
Source: StackOverflow