diff --git a/docs/vars.md b/docs/vars.md index d2b3ef600..b2a9dc452 100644 --- a/docs/vars.md +++ b/docs/vars.md @@ -156,20 +156,42 @@ node_taints: ### Custom flags for Kube Components -For all kube components, custom flags can be passed in. This allows for edge cases where users need changes to the default deployment that may not be applicable to all deployments. This can be done by providing a list of flags. The `kubelet_node_custom_flags` apply kubelet settings only to nodes and not masters. Example: +For all kube components, custom flags can be passed in. This allows for edge cases where users need changes to the default deployment that may not be applicable to all deployments. + +Extra flags for the kubelet can be specified using these variables, +in the form of dicts of key-value pairs of configuration parameters that will be inserted into the kubelet YAML config file. The `kubelet_node_config_extra_args` apply kubelet settings only to nodes and not masters. Example: ```yml -kubelet_custom_flags: - - "--eviction-hard=memory.available<100Mi" - - "--eviction-soft-grace-period=memory.available=30s" - - "--eviction-soft=memory.available<300Mi" +kubelet_config_extra_args: + EvictionHard: + memory.available: "<100Mi" + EvictionSoftGracePeriod: + memory.available: "30s" + EvictionSoft: + memory.available: "<300Mi" ``` The possible vars are: +* *kubelet_config_extra_args* +* *kubelet_node_config_extra_args* + +Previously, the same paramaters could be passed as flags to kubelet binary with the following vars: + * *kubelet_custom_flags* * *kubelet_node_custom_flags* +The `kubelet_node_custom_flags` apply kubelet settings only to nodes and not masters. Example: + +```yml +kubelet_custom_flags: + - "--eviction-hard=memory.available<100Mi" + - "--eviction-soft-grace-period=memory.available=30s" + - "--eviction-soft=memory.available<300Mi" +``` + +This alternative is deprecated and will remain until the flags are completely removed from kubelet + Extra flags for the API server, controller, and scheduler components can be specified using these variables, in the form of dicts of key-value pairs of configuration parameters that will be inserted into the kubeadm YAML config file: diff --git a/roles/kubernetes/node/defaults/main.yml b/roles/kubernetes/node/defaults/main.yml index ebf52220f..5dc5a8cd3 100644 --- a/roles/kubernetes/node/defaults/main.yml +++ b/roles/kubernetes/node/defaults/main.yml @@ -68,6 +68,12 @@ kubelet_load_modules: false # default is equal to application default kubelet_max_pods: 110 +## Support parameters to be passed to kubelet via kubelet-config.yaml +kubelet_config_extra_args: {} + +## Support parameters to be passed to kubelet via kubelet-config.yaml only on nodes, not masters +kubelet_node_config_extra_args: {} + ## Support custom flags to be passed to kubelet kubelet_custom_flags: [] diff --git a/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 b/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 index ec83e9d54..50a2d0610 100644 --- a/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 +++ b/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 @@ -70,3 +70,9 @@ systemReserved: {% endif %} {% endif %} resolvConf: "{{ kube_resolv_conf }}" +{% if kubelet_config_extra_args %} +{{ kubelet_config_extra_args | to_nice_yaml(indent=2) }} +{% endif %} +{% if inventory_hostname in groups['kube-node'] and kubelet_node_config_extra_args %} +{{ kubelet_node_config_extra_args | to_nice_yaml(indent=2) }} +{% endif %}