0

According to this documentation, Extra flags for the API server, controller, and scheduler components can be specified using the variables below, in the form of dicts of key-value pairs of configuration parameters that will be inserted into the kubeadm YAML config file:

  • kube_kubeadm_apiserver_extra_args
  • kube_kubeadm_controller_extra_args
  • kube_kubeadm_scheduler_extra_args

But I can't really figure out where to add them in ansible playbooks so that they can be rendered on the master node during the cluster deloyment.

I tried using this file kubespray/roles/kubernetes/master/defaults/main/main.yml and this file kubespray/roles/kubespray-defaults/defaults/main.yaml but it doesn't work for none of the two files, ansible doesn't deploy them, like if ansible doesn't read them.

Where the kubeadm YAML config file is located?

Can someone here help with these parameters management?

Jonas
  • 121,568
  • 97
  • 310
  • 388
nixmind
  • 2,060
  • 6
  • 32
  • 54

1 Answers1

1

As documented on https://kubespray.io/#/docs/ansible?id=group-vars-and-overriding-variables-precedence, you should take a look at inventory/<mycluster>/group_vars/all/all.yml and inventory/<mycluster>/group_vars/k8s-cluster/k8s-cluster.yml for the configuration of your cluster.

Where inventory/<mycluster> is a copy of the kubespray provided inventory/sample folder with adaptations of the inventory.ini file and files inside group_vars.

Kubespray use the inventory layout proposed in https://docs.ansible.com/ansible/latest/user_guide/sample_setup.html#alternative-directory-layout

Whatever your layout, for group_vars to be loaded, the have to be in the same folder as the file referenced by the --inventory-file/--inventory/-i option or defaults.inventory config.

For example, if your inventory is the file config/inventory, you need to copy the sample inventory group_vars in config/group_vars.

zigarn
  • 10,892
  • 2
  • 31
  • 45
  • @zigam, I've read the documentation and see those files under the `kubespray` directory, but I'm not sure where and how ansible read and use them in the kubespray context. I already have an inventory file containing nodes and their IP that is specified in my `ansible.cfg` to be used by `ansible-playbook`. Please when and how the files you mentioned above come into the play? what is the purpose of 'mycluster` here? I'm a litte bit lost, please can you give me more precision on how to get my master components arguments overridden with `kubeadm extra args`? – nixmind Feb 22 '21 at 19:23
  • Ansible inventory contains multiple parts: listing of machines with grouping (ini file), variables for groups (in `group_vars//.yml` and variables for machines (in `host_vars//.yml`. When referencing an inventory file, ansible automatically loads the group_vars and host_vars from the same directory as the inventory ini file. You can check the result of inventory loading with the command `ansible-inventory --graph --vars` – zigarn Feb 22 '21 at 20:26
  • I've put my kubeadm extra args here : `kubespray/inventory/local/group_vars/k8s-cluster/k8s-cluster.yml`. I run the playbook like this `ansible-playbook -l k8s-cluster -I config/inventory playbooks/k8s-cluster.yml` Here `config/inventory` is the file containing my hosts inventory. The master configuration is style not deployed. I'm wondering how kubespray uses these variables in the deployment process. Also it seems like in the previous versions of kubespray, setting these kubeadm exra arags in this file : `kubespray/roles/kubernetes/master/defaults/main/main.yml` worked. – nixmind Feb 22 '21 at 23:51
  • As said in my previous comment: the `group_vars` has to be in the same directory as the referenced inventory, ansible won't load group_vars from another folder. I updated my answer. – zigarn Feb 23 '21 at 07:57