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.

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