You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

373 lines
22 KiB

6 years ago
  1. # Configurable Parameters in Kubespray
  2. ## Generic Ansible variables
  3. You can view facts gathered by Ansible automatically
  4. [here](https://docs.ansible.com/ansible/latest/user_guide/playbooks_vars_facts.html#ansible-facts).
  5. Some variables of note include:
  6. * *ansible_user*: user to connect to via SSH
  7. * *ansible_default_ipv4.address*: IP address Ansible automatically chooses.
  8. Generated based on the output from the command ``ip -4 route get 8.8.8.8``
  9. ## Common vars that are used in Kubespray
  10. * *calico_version* - Specify version of Calico to use
  11. * *calico_cni_version* - Specify version of Calico CNI plugin to use
  12. * *docker_version* - Specify version of Docker to use (should be quoted
  13. string). Must match one of the keys defined for *docker_versioned_pkg*
  14. in `roles/container-engine/docker/vars/*.yml`.
  15. * *containerd_version* - Specify version of containerd to use when setting `container_manager` to `containerd`
  16. * *docker_containerd_version* - Specify which version of containerd to use when setting `container_manager` to `docker`
  17. * *etcd_version* - Specify version of ETCD to use
  18. * *calico_ipip_mode* - Configures Calico ipip encapsulation - valid values are 'Never', 'Always' and 'CrossSubnet' (default 'Never')
  19. * *calico_vxlan_mode* - Configures Calico vxlan encapsulation - valid values are 'Never', 'Always' and 'CrossSubnet' (default 'Always')
  20. * *calico_network_backend* - Configures Calico network backend - valid values are 'none', 'bird' and 'vxlan' (default 'vxlan')
  21. * *kube_network_plugin* - Sets k8s network plugin (default Calico)
  22. * *kube_proxy_mode* - Changes k8s proxy mode to iptables mode
  23. * *kube_version* - Specify a given Kubernetes version
  24. * *searchdomains* - Array of DNS domains to search when looking up hostnames
  25. * *remove_default_searchdomains* - Boolean that removes the default searchdomain
  26. * *nameservers* - Array of nameservers to use for DNS lookup
  27. * *preinstall_selinux_state* - Set selinux state, permitted values are permissive, enforcing and disabled.
  28. ## Addressing variables
  29. * *ip* - IP to use for binding services (host var). This would **usually** be the public ip.
  30. * *access_ip* - IP to use from other hosts to connect to this host. Often required when deploying
  31. from a cloud, such as OpenStack or GCE and you have separate public/floating and private IPs.
  32. This would **usually** be the private ip.
  33. * *ansible_default_ipv4.address* - Not Kubespray-specific, but it is used if ip
  34. and access_ip are undefined
  35. * *ip6* - IPv6 address to use for binding services. (host var)
  36. If *ipv6_stack*(*enable_dual_stack_networks* deprecated) is set to ``true`` and *ip6* is defined,
  37. kubelet's ``--node-ip`` and node's ``InternalIP`` will be the combination of *ip* and *ip6*.
  38. Similarly used for ipv6only scheme.
  39. * *access_ip6* - similarly ``access_ip`` but IPv6
  40. * *ansible_default_ipv6.address* - Not Kubespray-specific, but it is used if ip6
  41. and access_ip6 are undefined
  42. * *loadbalancer_apiserver* - If defined, all hosts will connect to this
  43. address instead of localhost for kube_control_planes and kube_control_plane[0] for
  44. kube_nodes. See more details in the
  45. [HA guide](/docs/operations/ha-mode.md).
  46. * *loadbalancer_apiserver_localhost* - makes all hosts to connect to
  47. the apiserver internally load balanced endpoint. Mutual exclusive to the
  48. `loadbalancer_apiserver`. See more details in the
  49. [HA guide](/docs/operations/ha-mode.md).
  50. ## Special network variables
  51. These variables help avoid a large number of if/else constructs throughout the code associated with enabling different network stack.
  52. These variables are used in all templates.
  53. By default, only ipv4_stack is enabled, so it is given priority in dualstack mode.
  54. Don't change these variables if you don't understand what you're doing.
  55. * *main_access_ip* - equal to ``access_ip`` when ipv4_stack is enabled(even in case of dualstack),
  56. and ``access_ip6`` for IPv6 only clusters
  57. * *main_ip* - equal to ``ip`` when ipv4_stack is enabled(even in case of dualstack),
  58. and ``ip6`` for IPv6 only clusters
  59. * *main_access_ips* - list of ``access_ip`` and ``access_ip6`` for dualstack and one corresponding variable for single
  60. * *main_ips* - list of ``ip`` and ``ip6`` for dualstack and one corresponding variable for single
  61. ## Cluster variables
  62. Kubernetes needs some parameters in order to get deployed. These are the
  63. following default cluster parameters:
  64. * *cluster_name* - Name of cluster (default is cluster.local)
  65. * *container_manager* - Container Runtime to install in the nodes (default is containerd)
  66. * *image_command_tool* - Tool used to pull images (default depends on `container_manager`
  67. and is `nerdctl` for `containerd`, `crictl` for `crio`, `docker` for `docker`)
  68. * *image_command_tool_on_localhost* - Tool used to pull images on localhost
  69. (default is equal to `image_command_tool`)
  70. * *dns_domain* - Name of cluster DNS domain (default is cluster.local)
  71. * *kube_network_plugin* - Plugin to use for container networking
  72. * *kube_service_addresses* - Subnet for cluster IPs (default is
  73. 10.233.0.0/18). Must not overlap with kube_pods_subnet
  74. * *kube_pods_subnet* - Subnet for Pod IPs (default is 10.233.64.0/18). Must not
  75. overlap with kube_service_addresses.
  76. * *kube_network_node_prefix* - Subnet allocated per-node for pod IPs. Remaining
  77. bits in kube_pods_subnet dictates how many kube_nodes can be in cluster. Setting this > 25 will
  78. raise an assertion in playbooks if the `kubelet_max_pods` var also isn't adjusted accordingly
  79. (assertion not applicable to calico which doesn't use this as a hard limit, see
  80. [Calico IP block sizes](https://docs.projectcalico.org/reference/resources/ippool#block-sizes)).
  81. * *kube_service_addresses_ipv6* - Subnet for cluster IPv6 IPs (default is ``fd85:ee78:d8a6:8607::1000/116``). Must not overlap with ``kube_pods_subnet_ipv6``.
  82. * *kube_service_subnets* - All service subnets separated by commas (default is a mix of ``kube_service_addresses`` and ``kube_service_addresses_ipv6`` depending on ``ipv4_stack`` and ``ipv6_stacke`` options),
  83. for example ``10.233.0.0/18,fd85:ee78:d8a6:8607::1000/116`` for dual stack(ipv4_stack/ipv6_stack set to `true`).
  84. It is not recommended to change this variable directly.
  85. * *kube_pods_subnet_ipv6* - Subnet for Pod IPv6 IPs (default is ``fd85:ee78:d8a6:8607::1:0000/112``). Must not overlap with ``kube_service_addresses_ipv6``.
  86. * *kube_pods_subnets* - All pods subnets separated by commas (default is a mix of ``kube_pods_subnet`` and ``kube_pod_subnet_ipv6`` depending on ``ipv4_stack`` and ``ipv6_stacke`` options),
  87. for example ``10.233.64.0/18,fd85:ee78:d8a6:8607::1:0000/112`` for dual stack(ipv4_stack/ipv6_stack set to `true`).
  88. It is not recommended to change this variable directly.
  89. * *kube_network_node_prefix_ipv6* - Subnet allocated per-node for pod IPv6 IPs. Remaining bits in ``kube_pods_subnet_ipv6`` dictates how many kube_nodes can be in cluster.
  90. * *skydns_server* - Cluster IP for DNS (default is 10.233.0.3)
  91. * *skydns_server_secondary* - Secondary Cluster IP for CoreDNS used with coredns_dual deployment (default is 10.233.0.4)
  92. * *enable_coredns_k8s_external* - If enabled, it configures the [k8s_external plugin](https://coredns.io/plugins/k8s_external/)
  93. on the CoreDNS service.
  94. * *coredns_k8s_external_zone* - Zone that will be used when CoreDNS k8s_external plugin is enabled
  95. (default is k8s_external.local)
  96. * *enable_coredns_k8s_endpoint_pod_names* - If enabled, it configures endpoint_pod_names option for kubernetes plugin.
  97. on the CoreDNS service.
  98. * *cloud_provider* - The provider for cloud services. (default is unset, Set to `external` for running with an external cloud provider)
  99. * *kube_feature_gates* - A list of key=value pairs that describe feature gates for
  100. alpha/experimental Kubernetes features. (defaults is `[]`).
  101. Additionally, you can use also the following variables to individually customize your kubernetes components installation (they works exactly like `kube_feature_gates`):
  102. * *kube_apiserver_feature_gates*
  103. * *kube_controller_feature_gates*
  104. * *kube_scheduler_feature_gates*
  105. * *kube_proxy_feature_gates*
  106. * *kubelet_feature_gates*
  107. * *kubeadm_feature_gates* - A list of key=value pairs that describe feature gates for
  108. alpha/experimental Kubeadm features. (defaults is `[]`)
  109. * *authorization_modes* - A list of [authorization mode](
  110. https://kubernetes.io/docs/reference/access-authn-authz/authorization/#using-flags-for-your-authorization-module)
  111. that the cluster should be configured for. Defaults to `['Node', 'RBAC']`
  112. (Node and RBAC authorizers).
  113. Note: `Node` and `RBAC` are enabled by default. Previously deployed clusters can be
  114. converted to RBAC mode. However, your apps which rely on Kubernetes API will
  115. require a service account and cluster role bindings. You can override this
  116. setting by setting authorization_modes to `[]`.
  117. * *kube_apiserver_admission_control_config_file* - Enable configuration for `kube-apiserver` admission plugins.
  118. Currently this variable allow you to configure the `EventRateLimit` admission plugin.
  119. To configure the **EventRateLimit** plugin you have to define a data structure like this:
  120. ```yml
  121. kube_apiserver_admission_event_rate_limits:
  122. limit_1:
  123. type: Namespace
  124. qps: 50
  125. burst: 100
  126. cache_size: 2000
  127. limit_2:
  128. type: User
  129. qps: 50
  130. burst: 100
  131. ...
  132. ```
  133. * *kube_apiserver_service_account_lookup* - Enable validation service account before validating token. Default `true`.
  134. Note, if cloud providers have any use of the ``10.233.0.0/16``, like instances'
  135. private addresses, make sure to pick another values for ``kube_service_addresses``
  136. and ``kube_pods_subnet``, for example from the ``172.18.0.0/16``.
  137. ## Enabling Dual Stack (IPV4 + IPV6) or IPV6 only networking
  138. IPv4 stack enable by *ipv4_stack* is set to ``true``, by default.
  139. IPv6 stack enable by *ipv6_stack* is set to ``false`` by default.
  140. This will use the default IPv4 and IPv6 subnets specified in the defaults file in the ``kubespray-defaults`` role, unless overridden of course. The default config will give you room for up to 256 nodes with 126 pods per node, and up to 4096 services.
  141. Set both variables to ``true`` for Dual Stack mode.
  142. IPv4 has higher priority in Dual Stack mode(e.g. in variables `main_ip`, `main_access_ip` and other).
  143. You can also make IPv6 only clusters with ``false`` in *ipv4_stack*.
  144. ## DNS variables
  145. By default, hosts are set up with 8.8.8.8 as an upstream DNS server and all
  146. other settings from your existing /etc/resolv.conf are lost. Set the following
  147. variables to match your requirements.
  148. * *upstream_dns_servers* - Array of upstream DNS servers configured on host in
  149. addition to Kubespray deployed DNS
  150. * *nameservers* - Array of DNS servers configured for use by hosts
  151. * *searchdomains* - Array of up to 4 search domains
  152. * *remove_default_searchdomains* - Boolean. If enabled, `searchdomains` variable can hold 6 search domains.
  153. * *dns_etchosts* - Content of hosts file for coredns and nodelocaldns
  154. * *dns_upstream_forward_extra_opts* - Options to add in the forward section of coredns/nodelocaldns related to upstream DNS servers
  155. For more information, see [DNS
  156. Stack](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/advanced/dns-stack.md).
  157. ## Other service variables
  158. * *docker_options* - Commonly used to set
  159. ``--insecure-registry=myregistry.mydomain:5000``
  160. * *docker_plugins* - This list can be used to define [Docker plugins](https://docs.docker.com/engine/extend/) to install.
  161. * *containerd_default_runtime* - If defined, changes the default Containerd runtime used by the Kubernetes CRI plugin.
  162. * *containerd_additional_runtimes* - Sets the additional Containerd runtimes used by the Kubernetes CRI plugin.
  163. [Default config](https://github.com/kubernetes-sigs/kubespray/blob/master/roles/container-engine/containerd/defaults/main.yml) can be overridden in inventory vars.
  164. * *crio_criu_support_enabled* - When set to `true`, enables the container checkpoint/restore in CRI-O. It's required to install [CRIU](https://criu.org/Installation) on the host when dumping/restoring checkpoints. And it's recommended to enable the feature gate `ContainerCheckpoint` so that the kubelet get a higher level API to simplify the operations (**Note**: It's still in experimental stage, just for container analytics so far). You can follow the [documentation](https://kubernetes.io/blog/2022/12/05/forensic-container-checkpointing-alpha/).
  165. * *http_proxy/https_proxy/no_proxy/no_proxy_exclude_workers/additional_no_proxy* - Proxy variables for deploying behind a
  166. proxy. Note that no_proxy defaults to all internal cluster IPs and hostnames
  167. that correspond to each node.
  168. * *kubelet_cgroup_driver* - Allows manual override of the cgroup-driver option for Kubelet.
  169. By default autodetection is used to match container manager configuration.
  170. `systemd` is the preferred driver for `containerd` though it can have issues with `cgroups v1` and `kata-containers` in which case you may want to change to `cgroupfs`.
  171. * *kubelet_rotate_certificates* - Auto rotate the kubelet client certificates by requesting new certificates
  172. from the kube-apiserver when the certificate expiration approaches.
  173. * *kubelet_rotate_server_certificates* - Auto rotate the kubelet server certificates by requesting new certificates
  174. from the kube-apiserver when the certificate expiration approaches.
  175. Note that enabling this also activates *kubelet_csr_approver* which approves automatically the CSRs.
  176. To customize its behavior, you can override the Helm values via *kubelet_csr_approver_values*.
  177. See [kubelet-csr-approver](https://github.com/postfinance/kubelet-csr-approver) for more information.
  178. * *kubelet_streaming_connection_idle_timeout* - Set the maximum time a streaming connection can be idle before the connection is automatically closed.
  179. * *kubelet_image_gc_high_threshold* - Set the percent of disk usage after which image garbage collection is always run.
  180. The percent is calculated by dividing this field value by 100, so this field must be between 0 and 100, inclusive.
  181. When specified, the value must be greater than imageGCLowThresholdPercent. Default: 85
  182. * *kubelet_image_gc_low_threshold* - Set the percent of disk usage before which image garbage collection is never run.
  183. Lowest disk usage to garbage collect to.
  184. The percent is calculated by dividing this field value by 100, so the field value must be between 0 and 100, inclusive.
  185. When specified, the value must be less than imageGCHighThresholdPercent. Default: 80
  186. * *kubelet_max_parallel_image_pulls* - Sets the maximum number of image pulls in parallel. The value is `1` by default which means the default is serial image pulling, set it to a integer great than `1` to enable image pulling in parallel.
  187. * *kubelet_make_iptables_util_chains* - If `true`, causes the kubelet ensures a set of `iptables` rules are present on host.
  188. * *kubelet_cpu_manager_policy* - If set to `static`, allows pods with certain resource characteristics to be granted increased CPU affinity and exclusivity on the node. And it should be set with `kube_reserved` or `system-reserved`, enable this with the following guide:[Control CPU Management Policies on the Node](https://kubernetes.io/docs/tasks/administer-cluster/cpu-management-policies/)
  189. * *kubelet_cpu_manager_policy_options* - A dictionary of cpuManagerPolicyOptions to enable. Keep in mind to enable the corresponding feature gates and make sure to pass the booleans as string (i.e. don't forget the quotes)!
  190. ```yml
  191. kubelet_cpu_manager_policy_options:
  192. distribute-cpus-across-numa: "true"
  193. full-pcpus-only: "true"
  194. ```
  195. * *kubelet_topology_manager_policy* - Control the behavior of the allocation of CPU and Memory from different [NUMA](https://en.wikipedia.org/wiki/Non-uniform_memory_access) Nodes. Enable this with the following guide: [Control Topology Management Policies on a node](https://kubernetes.io/docs/tasks/administer-cluster/topology-manager).
  196. * *kubelet_topology_manager_scope* - The Topology Manager can deal with the alignment of resources in a couple of distinct scopes: `container` and `pod`. See [Topology Manager Scopes](https://kubernetes.io/docs/tasks/administer-cluster/topology-manager/#topology-manager-scopes).
  197. * *kubelet_systemd_hardening* - If `true`, provides kubelet systemd service with security features for isolation.
  198. **N.B.** To enable this feature, ensure you are using the **`cgroup v2`** on your system. Check it out with command: `sudo ls -l /sys/fs/cgroup/*.slice`. If directory does not exist, enable this with the following guide: [enable cgroup v2](https://rootlesscontaine.rs/getting-started/common/cgroup2/#enabling-cgroup-v2).
  199. * *kubelet_secure_addresses* - By default *kubelet_systemd_hardening* set the **control plane** `ansible_host` IPs as the `kubelet_secure_addresses`. In case you have multiple interfaces in your control plane nodes and the `kube-apiserver` is not bound to the default interface, you can override them with this variable.
  200. Example:
  201. The **control plane** node may have 2 interfaces with the following IP addresses: `eth0:10.0.0.110`, `eth1:192.168.1.110`.
  202. By default the `kubelet_secure_addresses` is set with the `10.0.0.110` the ansible control host uses `eth0` to connect to the machine. In case you want to use `eth1` as the outgoing interface on which `kube-apiserver` connects to the `kubelet`s, you should override the variable in this way: `kubelet_secure_addresses: "192.168.1.110"`.
  203. * *kubelet_systemd_wants_dependencies* - List of kubelet service dependencies, other than container runtime.
  204. If you use nfs dynamically mounted volumes, sometimes rpc-statd does not start within the kubelet. You can fix it with this parameter : `kubelet_systemd_wants_dependencies: ["rpc-statd.service"]` This will add `Wants=rpc-statd.service` in `[Unit]` section of /etc/systemd/system/kubelet.service
  205. * *node_labels* - Labels applied to nodes via `kubectl label node`.
  206. For example, labels can be set in the inventory as variables or more widely in group_vars.
  207. *node_labels* can only be defined as a dict:
  208. ```yml
  209. node_labels:
  210. label1_name: label1_value
  211. label2_name: label2_value
  212. ```
  213. * *node_taints* - Taints applied to nodes via `kubectl taint node`.
  214. For example, taints can be set in the inventory as variables or more widely in group_vars.
  215. *node_taints* has to be defined as a list of strings in format `key=value:effect`, e.g.:
  216. ```yml
  217. node_taints:
  218. - "node.example.com/external=true:NoSchedule"
  219. ```
  220. * *kubernetes_audit* - When set to `true`, enables Auditing.
  221. The auditing parameters can be tuned via the following variables (which default values are shown below):
  222. * `audit_log_path`: /var/log/audit/kube-apiserver-audit.log
  223. * `audit_log_maxage`: 30
  224. * `audit_log_maxbackups`: 10
  225. * `audit_log_maxsize`: 100
  226. * `audit_policy_file`: "{{ kube_config_dir }}/audit-policy/apiserver-audit-policy.yaml"
  227. By default, the `audit_policy_file` contains [default rules](https://github.com/kubernetes-sigs/kubespray/blob/master/roles/kubernetes/control-plane/templates/apiserver-audit-policy.yaml.j2) that can be overridden with the `audit_policy_custom_rules` variable.
  228. * *kubernetes_audit_webhook* - When set to `true`, enables the webhook audit backend.
  229. The webhook parameters can be tuned via the following variables (which default values are shown below):
  230. * `audit_webhook_config_file`: "{{ kube_config_dir }}/audit-policy/apiserver-audit-webhook-config.yaml"
  231. * `audit_webhook_server_url`: `"https://audit.app"`
  232. * `audit_webhook_server_extra_args`: {}
  233. * `audit_webhook_mode`: batch
  234. * `audit_webhook_batch_max_size`: 100
  235. * `audit_webhook_batch_max_wait`: 1s
  236. * *kubectl_alias* - Bash alias of kubectl to interact with Kubernetes cluster much easier.
  237. * *remove_anonymous_access* - When set to `true`, removes the `kubeadm:bootstrap-signer-clusterinfo` rolebinding created by kubeadm.
  238. By default, kubeadm creates a rolebinding in the `kube-public` namespace which grants permissions to anonymous users. This rolebinding allows kubeadm to discover and validate cluster information during the join phase.
  239. In a nutshell, this option removes the rolebinding after the init phase of the first control plane node and then configures kubeadm to use file discovery for the join phase of other nodes.
  240. This option does not remove the anonymous authentication feature of the API server.
  241. ### Custom flags for Kube Components
  242. 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.
  243. Extra flags for the kubelet can be specified using these variables, in the form of dicts of key-value pairs of
  244. configuration parameters that will be inserted into the kubelet YAML config file. Example:
  245. ```yml
  246. kubelet_config_extra_args:
  247. evictionHard:
  248. memory.available: "100Mi"
  249. evictionSoftGracePeriod:
  250. memory.available: "30s"
  251. evictionSoft:
  252. memory.available: "300Mi"
  253. ```
  254. The possible vars are:
  255. * *kubelet_config_extra_args*
  256. Previously, the same parameters could be passed as flags to kubelet binary with the following vars:
  257. * *kubelet_custom_flags*
  258. ```yml
  259. kubelet_custom_flags:
  260. - "--eviction-hard=memory.available<100Mi"
  261. - "--eviction-soft-grace-period=memory.available=30s"
  262. - "--eviction-soft=memory.available<300Mi"
  263. ```
  264. This alternative is deprecated and will remain until the flags are completely removed from kubelet
  265. Extra flags for the API server, controller, and scheduler components can be specified using these variables,
  266. in the form of dicts of key-value pairs of configuration parameters that will be inserted into the kubeadm YAML config file:
  267. * *kube_kubeadm_apiserver_extra_args*
  268. * *kube_kubeadm_controller_extra_args*
  269. * *kube_kubeadm_scheduler_extra_args*
  270. ### Kubeadm patches
  271. When extra flags are not sufficient and there is a need to further customize kubernetes components,
  272. [kubeadm patches](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/control-plane-flags/#patches)
  273. can be used.
  274. You should use the [`kubeadm_patches` variable](../../roles/kubernetes/kubeadm_common/defaults/main.yml) for that purpose.
  275. ## App variables
  276. * *helm_version* - Only supports v3.x. Existing v2 installs (with Tiller) will not be modified and need to be removed manually.