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.

224 lines
12 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 used (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. * *ipip* - Enables Calico ipip encapsulation by default
  19. * *kube_network_plugin* - Sets k8s network plugin (default Calico)
  20. * *kube_proxy_mode* - Changes k8s proxy mode to iptables mode
  21. * *kube_version* - Specify a given Kubernetes version
  22. * *searchdomains* - Array of DNS domains to search when looking up hostnames
  23. * *nameservers* - Array of nameservers to use for DNS lookup
  24. * *preinstall_selinux_state* - Set selinux state, permitted values are permissive, enforcing and disabled.
  25. ## Addressing variables
  26. * *ip* - IP to use for binding services (host var)
  27. * *access_ip* - IP for other hosts to use to connect to. Often required when
  28. deploying from a cloud, such as OpenStack or GCE and you have separate
  29. public/floating and private IPs.
  30. * *ansible_default_ipv4.address* - Not Kubespray-specific, but it is used if ip
  31. and access_ip are undefined
  32. * *loadbalancer_apiserver* - If defined, all hosts will connect to this
  33. address instead of localhost for kube_control_planes and kube_control_plane[0] for
  34. kube_nodes. See more details in the
  35. [HA guide](/docs/ha-mode.md).
  36. * *loadbalancer_apiserver_localhost* - makes all hosts to connect to
  37. the apiserver internally load balanced endpoint. Mutual exclusive to the
  38. `loadbalancer_apiserver`. See more details in the
  39. [HA guide](/docs/ha-mode.md).
  40. ## Cluster variables
  41. Kubernetes needs some parameters in order to get deployed. These are the
  42. following default cluster parameters:
  43. * *cluster_name* - Name of cluster (default is cluster.local)
  44. * *container_manager* - Container Runtime to install in the nodes (default is docker)
  45. * *dns_domain* - Name of cluster DNS domain (default is cluster.local)
  46. * *kube_network_plugin* - Plugin to use for container networking
  47. * *kube_service_addresses* - Subnet for cluster IPs (default is
  48. 10.233.0.0/18). Must not overlap with kube_pods_subnet
  49. * *kube_pods_subnet* - Subnet for Pod IPs (default is 10.233.64.0/18). Must not
  50. overlap with kube_service_addresses.
  51. * *kube_network_node_prefix* - Subnet allocated per-node for pod IPs. Remaining
  52. bits in kube_pods_subnet dictates how many kube_nodes can be in cluster. Setting this > 25 will
  53. raise an assertion in playbooks if the `kubelet_max_pods` var also isn't adjusted accordingly
  54. (assertion not applicable to calico which doesn't use this as a hard limit, see
  55. [Calico IP block sizes](https://docs.projectcalico.org/reference/resources/ippool#block-sizes).
  56. * *enable_dual_stack_networks* - Setting this to true will provision both IPv4 and IPv6 networking for pods and services.
  57. * *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``.
  58. * *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``.
  59. * *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.
  60. * *skydns_server* - Cluster IP for DNS (default is 10.233.0.3)
  61. * *skydns_server_secondary* - Secondary Cluster IP for CoreDNS used with coredns_dual deployment (default is 10.233.0.4)
  62. * *enable_coredns_k8s_external* - If enabled, it configures the [k8s_external plugin](https://coredns.io/plugins/k8s_external/)
  63. on the CoreDNS service.
  64. * *coredns_k8s_external_zone* - Zone that will be used when CoreDNS k8s_external plugin is enabled
  65. (default is k8s_external.local)
  66. * *enable_coredns_k8s_endpoint_pod_names* - If enabled, it configures endpoint_pod_names option for kubernetes plugin.
  67. on the CoreDNS service.
  68. * *cloud_provider* - Enable extra Kubelet option if operating inside GCE or
  69. OpenStack (default is unset)
  70. * *kube_feature_gates* - A list of key=value pairs that describe feature gates for
  71. alpha/experimental Kubernetes features. (defaults is `[]`)
  72. * *kubeadm_feature_gates* - A list of key=value pairs that describe feature gates for
  73. alpha/experimental Kubeadm features. (defaults is `[]`)
  74. * *authorization_modes* - A list of [authorization mode](
  75. https://kubernetes.io/docs/admin/authorization/#using-flags-for-your-authorization-module)
  76. that the cluster should be configured for. Defaults to `['Node', 'RBAC']`
  77. (Node and RBAC authorizers).
  78. Note: `Node` and `RBAC` are enabled by default. Previously deployed clusters can be
  79. converted to RBAC mode. However, your apps which rely on Kubernetes API will
  80. require a service account and cluster role bindings. You can override this
  81. setting by setting authorization_modes to `[]`.
  82. Note, if cloud providers have any use of the ``10.233.0.0/16``, like instances'
  83. private addresses, make sure to pick another values for ``kube_service_addresses``
  84. and ``kube_pods_subnet``, for example from the ``172.18.0.0/16``.
  85. ## Enabling Dual Stack (IPV4 + IPV6) networking
  86. If *enable_dual_stack_networks* is set to ``true``, Dual Stack networking will be enabled in the cluster. 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.
  87. ## DNS variables
  88. By default, hosts are set up with 8.8.8.8 as an upstream DNS server and all
  89. other settings from your existing /etc/resolv.conf are lost. Set the following
  90. variables to match your requirements.
  91. * *upstream_dns_servers* - Array of upstream DNS servers configured on host in
  92. addition to Kubespray deployed DNS
  93. * *nameservers* - Array of DNS servers configured for use by hosts
  94. * *searchdomains* - Array of up to 4 search domains
  95. * *dns_etchosts* - Content of hosts file for coredns and nodelocaldns
  96. For more information, see [DNS
  97. Stack](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/dns-stack.md).
  98. ## Other service variables
  99. * *docker_options* - Commonly used to set
  100. ``--insecure-registry=myregistry.mydomain:5000``
  101. * *docker_plugins* - This list can be used to define [Docker plugins](https://docs.docker.com/engine/extend/) to install.
  102. * *containerd_default_runtime* - Sets the default Containerd runtime used by the Kubernetes CRI plugin.
  103. * *containerd_additional_runtimes* - Sets the additional Containerd runtimes used by the Kubernetes CRI plugin.
  104. [Default config](https://github.com/kubernetes-sigs/kubespray/blob/master/roles/container-engine/containerd/defaults/main.yml) can be overriden in inventory vars.
  105. * *http_proxy/https_proxy/no_proxy/no_proxy_exclude_workers/additional_no_proxy* - Proxy variables for deploying behind a
  106. proxy. Note that no_proxy defaults to all internal cluster IPs and hostnames
  107. that correspond to each node.
  108. * *kubelet_cgroup_driver* - Allows manual override of the cgroup-driver option for Kubelet.
  109. By default autodetection is used to match container manager configuration.
  110. `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`.
  111. * *kubelet_rotate_certificates* - Auto rotate the kubelet client certificates by requesting new certificates
  112. from the kube-apiserver when the certificate expiration approaches.
  113. * *kubelet_rotate_server_certificates* - Auto rotate the kubelet server certificates by requesting new certificates
  114. from the kube-apiserver when the certificate expiration approaches.
  115. **Note** that server certificates are **not** approved automatically. Approve them manually
  116. (`kubectl get csr`, `kubectl certificate approve`) or implement custom approving controller like
  117. [kubelet-rubber-stamp](https://github.com/kontena/kubelet-rubber-stamp).
  118. * *node_labels* - Labels applied to nodes via kubelet --node-labels parameter.
  119. For example, labels can be set in the inventory as variables or more widely in group_vars.
  120. *node_labels* can only be defined as a dict:
  121. ```yml
  122. node_labels:
  123. label1_name: label1_value
  124. label2_name: label2_value
  125. ```
  126. * *node_taints* - Taints applied to nodes via kubelet --register-with-taints parameter.
  127. For example, taints can be set in the inventory as variables or more widely in group_vars.
  128. *node_taints* has to be defined as a list of strings in format `key=value:effect`, e.g.:
  129. ```yml
  130. node_taints:
  131. - "node.example.com/external=true:NoSchedule"
  132. ```
  133. * *podsecuritypolicy_enabled* - When set to `true`, enables the PodSecurityPolicy admission controller and defines two policies `privileged` (applying to all resources in `kube-system` namespace and kubelet) and `restricted` (applying all other namespaces).
  134. Addons deployed in kube-system namespaces are handled.
  135. * *kubernetes_audit* - When set to `true`, enables Auditing.
  136. The auditing parameters can be tuned via the following variables (which default values are shown below):
  137. * `audit_log_path`: /var/log/audit/kube-apiserver-audit.log
  138. * `audit_log_maxage`: 30
  139. * `audit_log_maxbackups`: 1
  140. * `audit_log_maxsize`: 100
  141. * `audit_policy_file`: "{{ kube_config_dir }}/audit-policy/apiserver-audit-policy.yaml"
  142. 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.
  143. * *kubernetes_audit_webhook* - When set to `true`, enables the webhook audit backend.
  144. The webhook parameters can be tuned via the following variables (which default values are shown below):
  145. * `audit_webhook_config_file`: "{{ kube_config_dir }}/audit-policy/apiserver-audit-webhook-config.yaml"
  146. * `audit_webhook_server_url`: `"https://audit.app"`
  147. * `audit_webhook_server_extra_args`: {}
  148. * `audit_webhook_mode`: batch
  149. * `audit_webhook_batch_max_size`: 100
  150. * `audit_webhook_batch_max_wait`: 1s
  151. ### Custom flags for Kube Components
  152. 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.
  153. Extra flags for the kubelet can be specified using these variables,
  154. 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 control planes. Example:
  155. ```yml
  156. kubelet_config_extra_args:
  157. evictionHard:
  158. memory.available: "100Mi"
  159. evictionSoftGracePeriod:
  160. memory.available: "30s"
  161. evictionSoft:
  162. memory.available: "300Mi"
  163. ```
  164. The possible vars are:
  165. * *kubelet_config_extra_args*
  166. * *kubelet_node_config_extra_args*
  167. Previously, the same parameters could be passed as flags to kubelet binary with the following vars:
  168. * *kubelet_custom_flags*
  169. * *kubelet_node_custom_flags*
  170. The `kubelet_node_custom_flags` apply kubelet settings only to nodes and not control planes. Example:
  171. ```yml
  172. kubelet_custom_flags:
  173. - "--eviction-hard=memory.available<100Mi"
  174. - "--eviction-soft-grace-period=memory.available=30s"
  175. - "--eviction-soft=memory.available<300Mi"
  176. ```
  177. This alternative is deprecated and will remain until the flags are completely removed from kubelet
  178. Extra flags for the API server, controller, and scheduler components can be specified using these variables,
  179. in the form of dicts of key-value pairs of configuration parameters that will be inserted into the kubeadm YAML config file:
  180. * *kube_kubeadm_apiserver_extra_args*
  181. * *kube_kubeadm_controller_extra_args*
  182. * *kube_kubeadm_scheduler_extra_args*
  183. ## App variables
  184. * *helm_version* - Only supports v3.x. Existing v2 installs (with Tiller) will not be modified and need to be removed manually.