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.

332 lines
13 KiB

  1. apiVersion: kubeadm.k8s.io/v1beta2
  2. kind: InitConfiguration
  3. {% if kubeadm_token is defined %}
  4. bootstrapTokens:
  5. - token: "{{ kubeadm_token }}"
  6. description: "kubespray kubeadm bootstrap token"
  7. ttl: "24h"
  8. {% endif %}
  9. localAPIEndpoint:
  10. advertiseAddress: {{ ip | default(fallback_ips[inventory_hostname]) }}
  11. bindPort: {{ kube_apiserver_port }}
  12. {% if kubeadm_certificate_key is defined %}
  13. certificateKey: {{ kubeadm_certificate_key }}
  14. {% endif %}
  15. nodeRegistration:
  16. {% if kube_override_hostname|default('') %}
  17. name: {{ kube_override_hostname }}
  18. {% endif %}
  19. {% if inventory_hostname in groups['kube-master'] and inventory_hostname not in groups['kube-node'] %}
  20. taints:
  21. - effect: NoSchedule
  22. key: node-role.kubernetes.io/master
  23. {% else %}
  24. taints: []
  25. {% endif %}
  26. criSocket: {{ cri_socket }}
  27. ---
  28. apiVersion: kubeadm.k8s.io/v1beta2
  29. kind: ClusterConfiguration
  30. clusterName: {{ cluster_name }}
  31. etcd:
  32. {% if not etcd_kubeadm_enabled %}
  33. external:
  34. endpoints:
  35. {% for endpoint in etcd_access_addresses.split(',') %}
  36. - {{ endpoint }}
  37. {% endfor %}
  38. caFile: {{ etcd_cert_dir }}/{{ kube_etcd_cacert_file }}
  39. certFile: {{ etcd_cert_dir }}/{{ kube_etcd_cert_file }}
  40. keyFile: {{ etcd_cert_dir }}/{{ kube_etcd_key_file }}
  41. {% elif etcd_kubeadm_enabled %}
  42. local:
  43. imageRepository: "{{ etcd_image_repo | regex_replace("/etcd$","") }}"
  44. imageTag: "{{ etcd_image_tag }}"
  45. dataDir: "/var/lib/etcd"
  46. extraArgs:
  47. metrics: {{ etcd_metrics }}
  48. election-timeout: "{{ etcd_election_timeout }}"
  49. heartbeat-interval: "{{ etcd_heartbeat_interval }}"
  50. auto-compaction-retention: "{{ etcd_compaction_retention }}"
  51. {% if etcd_snapshot_count is defined %}
  52. snapshot-count: "{{ etcd_snapshot_count }}"
  53. {% endif %}
  54. {% if etcd_quota_backend_bytes is defined %}
  55. quota-backend-bytes: "{{ etcd_quota_backend_bytes }}"
  56. {% endif %}
  57. {% if etcd_log_package_levels is defined %}
  58. log-package_levels: "{{ etcd_log_package_levels }}"
  59. {% endif %}
  60. {% for key, value in etcd_extra_vars.items() %}
  61. {{ key }}: "{{ value }}"
  62. {% endfor %}
  63. {% if host_architecture != "amd64" -%}
  64. etcd-unsupported-arch: {{host_architecture}}
  65. {% endif %}
  66. serverCertSANs:
  67. {% for san in etcd_cert_alt_names %}
  68. - {{ san }}
  69. {% endfor %}
  70. {% for san in etcd_cert_alt_ips %}
  71. - {{ san }}
  72. {% endfor %}
  73. peerCertSANs:
  74. {% for san in etcd_cert_alt_names %}
  75. - {{ san }}
  76. {% endfor %}
  77. {% for san in etcd_cert_alt_ips %}
  78. - {{ san }}
  79. {% endfor %}
  80. {% endif %}
  81. dns:
  82. type: CoreDNS
  83. imageRepository: {{ coredns_image_repo | regex_replace('/coredns$','') }}
  84. imageTag: {{ coredns_image_tag }}
  85. networking:
  86. dnsDomain: {{ dns_domain }}
  87. serviceSubnet: {{ kube_service_addresses }}
  88. podSubnet: {{ kube_pods_subnet }}
  89. kubernetesVersion: {{ kube_version }}
  90. {% if kubeadm_config_api_fqdn is defined %}
  91. controlPlaneEndpoint: {{ kubeadm_config_api_fqdn }}:{{ loadbalancer_apiserver.port | default(kube_apiserver_port) }}
  92. {% else %}
  93. controlPlaneEndpoint: {{ ip | default(fallback_ips[inventory_hostname]) }}:{{ kube_apiserver_port }}
  94. {% endif %}
  95. certificatesDir: {{ kube_cert_dir }}
  96. imageRepository: {{ kube_image_repo }}
  97. useHyperKubeImage: false
  98. apiServer:
  99. extraArgs:
  100. {% if kube_api_anonymous_auth is defined %}
  101. anonymous-auth: "{{ kube_api_anonymous_auth }}"
  102. {% endif %}
  103. authorization-mode: {{ authorization_modes | join(',') }}
  104. bind-address: {{ kube_apiserver_bind_address }}
  105. {% if kube_apiserver_insecure_port|string != "0" %}
  106. insecure-bind-address: {{ kube_apiserver_insecure_bind_address }}
  107. {% endif %}
  108. insecure-port: "{{ kube_apiserver_insecure_port }}"
  109. {% if kube_apiserver_enable_admission_plugins|length > 0 %}
  110. enable-admission-plugins: {{ kube_apiserver_enable_admission_plugins | join(',') }}
  111. {% endif %}
  112. {% if kube_apiserver_disable_admission_plugins|length > 0 %}
  113. disable-admission-plugins: {{ kube_apiserver_disable_admission_plugins | join(',') }}
  114. {% endif %}
  115. apiserver-count: "{{ kube_apiserver_count }}"
  116. endpoint-reconciler-type: lease
  117. {% if etcd_events_cluster_enabled %}
  118. etcd-servers-overrides: "/events#{{ etcd_events_access_addresses_semicolon }}"
  119. {% endif %}
  120. service-node-port-range: {{ kube_apiserver_node_port_range }}
  121. kubelet-preferred-address-types: "{{ kubelet_preferred_address_types }}"
  122. profiling: "{{ kube_profiling }}"
  123. request-timeout: "{{ kube_apiserver_request_timeout }}"
  124. enable-aggregator-routing: "{{ kube_api_aggregator_routing }}"
  125. {% if kube_basic_auth|default(true) %}
  126. basic-auth-file: {{ kube_users_dir }}/known_users.csv
  127. {% endif %}
  128. {% if kube_token_auth|default(true) %}
  129. token-auth-file: {{ kube_token_dir }}/known_tokens.csv
  130. {% endif %}
  131. {% if kube_oidc_auth|default(false) and kube_oidc_url is defined and kube_oidc_client_id is defined %}
  132. oidc-issuer-url: {{ kube_oidc_url }}
  133. oidc-client-id: {{ kube_oidc_client_id }}
  134. {% if kube_oidc_ca_file is defined %}
  135. oidc-ca-file: {{ kube_oidc_ca_file }}
  136. {% endif %}
  137. {% if kube_oidc_username_claim is defined %}
  138. oidc-username-claim: {{ kube_oidc_username_claim }}
  139. {% endif %}
  140. {% if kube_oidc_groups_claim is defined %}
  141. oidc-groups-claim: {{ kube_oidc_groups_claim }}
  142. {% endif %}
  143. {% if kube_oidc_username_prefix is defined %}
  144. oidc-username-prefix: "{{ kube_oidc_username_prefix }}"
  145. {% endif %}
  146. {% if kube_oidc_groups_prefix is defined %}
  147. oidc-groups-prefix: "{{ kube_oidc_groups_prefix }}"
  148. {% endif %}
  149. {% endif %}
  150. {% if kube_webhook_token_auth|default(false) %}
  151. authentication-token-webhook-config-file: {{ kube_config_dir }}/webhook-token-auth-config.yaml
  152. {% endif %}
  153. {% if kube_encrypt_secret_data %}
  154. encryption-provider-config: {{ kube_cert_dir }}/secrets_encryption.yaml
  155. {% endif %}
  156. storage-backend: {{ kube_apiserver_storage_backend }}
  157. {% if kube_api_runtime_config is defined %}
  158. runtime-config: {{ kube_api_runtime_config | join(',') }}
  159. {% endif %}
  160. allow-privileged: "true"
  161. {% if kubernetes_audit %}
  162. audit-log-path: "{{ audit_log_path }}"
  163. audit-log-maxage: "{{ audit_log_maxage }}"
  164. audit-log-maxbackup: "{{ audit_log_maxbackups }}"
  165. audit-log-maxsize: "{{ audit_log_maxsize }}"
  166. audit-policy-file: {{ audit_policy_file }}
  167. {% endif %}
  168. {% for key in kube_kubeadm_apiserver_extra_args %}
  169. {{ key }}: "{{ kube_kubeadm_apiserver_extra_args[key] }}"
  170. {% endfor %}
  171. {% if kube_feature_gates %}
  172. feature-gates: {{ kube_feature_gates|join(',') }}
  173. {% endif %}
  174. {% if cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere", "aws"] %}
  175. cloud-provider: {{ cloud_provider }}
  176. cloud-config: {{ kube_config_dir }}/cloud_config
  177. {% elif cloud_provider is defined and cloud_provider in ["external"] %}
  178. cloud-config: {{ kube_config_dir }}/cloud_config
  179. {% endif %}
  180. {% if kubernetes_audit or kube_basic_auth|default(true) or kube_token_auth|default(true) or kube_webhook_token_auth|default(false) or ( cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere", "aws"] ) or apiserver_extra_volumes or ssl_ca_dirs|length %}
  181. extraVolumes:
  182. {% if cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere", "aws", "external"] %}
  183. - name: cloud-config
  184. hostPath: {{ kube_config_dir }}/cloud_config
  185. mountPath: {{ kube_config_dir }}/cloud_config
  186. {% endif %}
  187. {% if kube_basic_auth|default(true) %}
  188. - name: basic-auth-config
  189. hostPath: {{ kube_users_dir }}
  190. mountPath: {{ kube_users_dir }}
  191. {% endif %}
  192. {% if kube_token_auth|default(true) %}
  193. - name: token-auth-config
  194. hostPath: {{ kube_token_dir }}
  195. mountPath: {{ kube_token_dir }}
  196. {% endif %}
  197. {% if kube_webhook_token_auth|default(false) %}
  198. - name: webhook-token-auth-config
  199. hostPath: {{ kube_config_dir }}/webhook-token-auth-config.yaml
  200. mountPath: {{ kube_config_dir }}/webhook-token-auth-config.yaml
  201. {% endif %}
  202. {% if kubernetes_audit %}
  203. - name: {{ audit_policy_name }}
  204. hostPath: {{ audit_policy_hostpath }}
  205. mountPath: {{ audit_policy_mountpath }}
  206. {% if audit_log_path != "-" %}
  207. - name: {{ audit_log_name }}
  208. hostPath: {{ audit_log_hostpath }}
  209. mountPath: {{ audit_log_mountpath }}
  210. readOnly: false
  211. {% endif %}
  212. {% endif %}
  213. {% for volume in apiserver_extra_volumes %}
  214. - name: {{ volume.name }}
  215. hostPath: {{ volume.hostPath }}
  216. mountPath: {{ volume.mountPath }}
  217. readOnly: {{ volume.readOnly | d(not (volume.writable | d(false))) }}
  218. {% endfor %}
  219. {% if ssl_ca_dirs|length %}
  220. {% for dir in ssl_ca_dirs %}
  221. - name: {{ dir | regex_replace('^/(.*)$', '\\1' ) | regex_replace('/', '-') }}
  222. hostPath: {{ dir }}
  223. mountPath: {{ dir }}
  224. readOnly: true
  225. {% endfor %}
  226. {% endif %}
  227. {% endif %}
  228. certSANs:
  229. {% for san in apiserver_sans %}
  230. - {{ san }}
  231. {% endfor %}
  232. timeoutForControlPlane: 5m0s
  233. controllerManager:
  234. extraArgs:
  235. node-monitor-grace-period: {{ kube_controller_node_monitor_grace_period }}
  236. node-monitor-period: {{ kube_controller_node_monitor_period }}
  237. pod-eviction-timeout: {{ kube_controller_pod_eviction_timeout }}
  238. node-cidr-mask-size: "{{ kube_network_node_prefix }}"
  239. profiling: "{{ kube_profiling }}"
  240. terminated-pod-gc-threshold: "{{ kube_controller_terminated_pod_gc_threshold }}"
  241. bind-address: {{ kube_controller_manager_bind_address }}
  242. {% if kube_feature_gates %}
  243. feature-gates: {{ kube_feature_gates|join(',') }}
  244. {% endif %}
  245. {% for key in kube_kubeadm_controller_extra_args %}
  246. {{ key }}: "{{ kube_kubeadm_controller_extra_args[key] }}"
  247. {% endfor %}
  248. {% if cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere", "aws"] %}
  249. cloud-provider: {{ cloud_provider }}
  250. cloud-config: {{ kube_config_dir }}/cloud_config
  251. {% elif cloud_provider is defined and cloud_provider in ["external"] %}
  252. cloud-config: {{ kube_config_dir }}/cloud_config
  253. {% endif %}
  254. {% if kube_network_plugin is defined and kube_network_plugin not in ["cloud"] %}
  255. configure-cloud-routes: "false"
  256. {% endif %}
  257. {% if cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere", "aws", "external"] or controller_manager_extra_volumes %}
  258. extraVolumes:
  259. {% if cloud_provider is defined and cloud_provider in ["openstack"] and openstack_cacert is defined %}
  260. - name: openstackcacert
  261. hostPath: "{{ kube_config_dir }}/openstack-cacert.pem"
  262. mountPath: "{{ kube_config_dir }}/openstack-cacert.pem"
  263. {% endif %}
  264. {% if cloud_provider is defined and cloud_provider in ["openstack", "azure", "vsphere", "aws", "external"] %}
  265. - name: cloud-config
  266. hostPath: {{ kube_config_dir }}/cloud_config
  267. mountPath: {{ kube_config_dir }}/cloud_config
  268. {% endif %}
  269. {% for volume in controller_manager_extra_volumes %}
  270. - name: {{ volume.name }}
  271. hostPath: {{ volume.hostPath }}
  272. mountPath: {{ volume.mountPath }}
  273. readOnly: {{ volume.readOnly | d(not (volume.writable | d(false))) }}
  274. {% endfor %}
  275. {% endif %}
  276. scheduler:
  277. extraArgs:
  278. bind-address: {{ kube_scheduler_bind_address }}
  279. {% if kube_feature_gates %}
  280. feature-gates: {{ kube_feature_gates|join(',') }}
  281. {% endif %}
  282. {% if kube_kubeadm_scheduler_extra_args|length > 0 %}
  283. {% for key in kube_kubeadm_scheduler_extra_args %}
  284. {{ key }}: "{{ kube_kubeadm_scheduler_extra_args[key] }}"
  285. {% endfor %}
  286. {% endif %}
  287. extraVolumes:
  288. {% if scheduler_extra_volumes %}
  289. extraVolumes:
  290. {% for volume in scheduler_extra_volumes %}
  291. - name: {{ volume.name }}
  292. hostPath: {{ volume.hostPath }}
  293. mountPath: {{ volume.mountPath }}
  294. readOnly: {{ volume.readOnly | d(not (volume.writable | d(false))) }}
  295. {% endfor %}
  296. {% endif %}
  297. ---
  298. apiVersion: kubeproxy.config.k8s.io/v1alpha1
  299. kind: KubeProxyConfiguration
  300. bindAddress: {{ kube_proxy_bind_address }}
  301. clientConnection:
  302. acceptContentTypes: {{ kube_proxy_client_accept_content_types }}
  303. burst: {{ kube_proxy_client_burst }}
  304. contentType: {{ kube_proxy_client_content_type }}
  305. kubeconfig: {{ kube_proxy_client_kubeconfig }}
  306. qps: {{ kube_proxy_client_qps }}
  307. clusterCIDR: {{ kube_pods_subnet }}
  308. configSyncPeriod: {{ kube_proxy_config_sync_period }}
  309. conntrack:
  310. maxPerCore: {{ kube_proxy_conntrack_max_per_core }}
  311. min: {{ kube_proxy_conntrack_min }}
  312. tcpCloseWaitTimeout: {{ kube_proxy_conntrack_tcp_close_wait_timeout }}
  313. tcpEstablishedTimeout: {{ kube_proxy_conntrack_tcp_established_timeout }}
  314. enableProfiling: {{ kube_proxy_enable_profiling }}
  315. healthzBindAddress: {{ kube_proxy_healthz_bind_address }}
  316. hostnameOverride: {{ kube_override_hostname }}
  317. iptables:
  318. masqueradeAll: {{ kube_proxy_masquerade_all }}
  319. masqueradeBit: {{ kube_proxy_masquerade_bit }}
  320. minSyncPeriod: {{ kube_proxy_min_sync_period }}
  321. syncPeriod: {{ kube_proxy_sync_period }}
  322. ipvs:
  323. excludeCIDRs: {{ kube_proxy_exclude_cidrs }}
  324. minSyncPeriod: {{ kube_proxy_min_sync_period }}
  325. scheduler: {{ kube_proxy_scheduler }}
  326. syncPeriod: {{ kube_proxy_sync_period }}
  327. metricsBindAddress: {{ kube_proxy_metrics_bind_address }}
  328. mode: {{ kube_proxy_mode }}
  329. nodePortAddresses: {{ kube_proxy_nodeport_addresses }}
  330. oomScoreAdj: {{ kube_proxy_oom_score_adj }}
  331. portRange: {{ kube_proxy_port_range }}
  332. udpIdleTimeout: {{ kube_proxy_udp_idle_timeout }}