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.

168 lines
6.7 KiB

  1. ---
  2. - name: Check ansible version
  3. import_playbook: ansible_version.yml
  4. - name: Ensure compatibility with old groups
  5. import_playbook: legacy_groups.yml
  6. - name: Install bastion ssh config
  7. hosts: bastion[0]
  8. gather_facts: False
  9. environment: "{{ proxy_disable_env }}"
  10. roles:
  11. - { role: kubespray-defaults }
  12. - { role: bastion-ssh-config, tags: ["localhost", "bastion"] }
  13. - name: Gather facts
  14. tags: always
  15. import_playbook: facts.yml
  16. - name: Download images to ansible host cache via first kube_control_plane node
  17. hosts: kube_control_plane[0]
  18. gather_facts: False
  19. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  20. environment: "{{ proxy_disable_env }}"
  21. roles:
  22. - { role: kubespray-defaults, when: "not skip_downloads and download_run_once and not download_localhost"}
  23. - { role: kubernetes/preinstall, tags: preinstall, when: "not skip_downloads and download_run_once and not download_localhost" }
  24. - { role: download, tags: download, when: "not skip_downloads and download_run_once and not download_localhost" }
  25. - name: Prepare nodes for upgrade
  26. hosts: k8s_cluster:etcd:calico_rr
  27. gather_facts: False
  28. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  29. environment: "{{ proxy_disable_env }}"
  30. roles:
  31. - { role: kubespray-defaults }
  32. - { role: kubernetes/preinstall, tags: preinstall }
  33. - { role: download, tags: download, when: "not skip_downloads" }
  34. - name: Upgrade container engine on non-cluster nodes
  35. hosts: etcd:calico_rr:!k8s_cluster
  36. gather_facts: False
  37. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  38. environment: "{{ proxy_disable_env }}"
  39. serial: "{{ serial | default('20%') }}"
  40. roles:
  41. - { role: kubespray-defaults }
  42. - { role: container-engine, tags: "container-engine", when: deploy_container_engine }
  43. - name: Install etcd
  44. hosts: etcd:kube_control_plane
  45. gather_facts: False
  46. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  47. environment: "{{ proxy_disable_env }}"
  48. roles:
  49. - { role: kubespray-defaults }
  50. - role: etcd
  51. tags: etcd
  52. vars:
  53. etcd_cluster_setup: true
  54. etcd_events_cluster_setup: "{{ etcd_events_cluster_enabled }}"
  55. when: etcd_deployment_type != "kubeadm"
  56. - name: Install etcd certs on nodes if required
  57. hosts: k8s_cluster
  58. gather_facts: False
  59. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  60. environment: "{{ proxy_disable_env }}"
  61. roles:
  62. - { role: kubespray-defaults }
  63. - role: etcd
  64. tags: etcd
  65. vars:
  66. etcd_cluster_setup: false
  67. etcd_events_cluster_setup: false
  68. when:
  69. - etcd_deployment_type != "kubeadm"
  70. - kube_network_plugin in ["calico", "flannel", "canal", "cilium"] or cilium_deploy_additionally | default(false) | bool
  71. - kube_network_plugin != "calico" or calico_datastore == "etcd"
  72. - name: Handle upgrades to master components first to maintain backwards compat.
  73. gather_facts: False
  74. hosts: kube_control_plane
  75. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  76. environment: "{{ proxy_disable_env }}"
  77. serial: 1
  78. roles:
  79. - { role: kubespray-defaults }
  80. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  81. - { role: upgrade/system-upgrade, tags: system-upgrade }
  82. - { role: download, tags: download, when: "system_upgrade and system_upgrade_reboot != 'never' and not skip_downloads" }
  83. - { role: kubernetes-apps/kubelet-csr-approver, tags: kubelet-csr-approver }
  84. - { role: container-engine, tags: "container-engine", when: deploy_container_engine }
  85. - { role: kubernetes/node, tags: node }
  86. - { role: kubernetes/control-plane, tags: master, upgrade_cluster_setup: true }
  87. - { role: kubernetes/client, tags: client }
  88. - { role: kubernetes/node-label, tags: node-label }
  89. - { role: kubernetes-apps/cluster_roles, tags: cluster-roles }
  90. - { role: kubernetes-apps, tags: csi-driver }
  91. - { role: upgrade/post-upgrade, tags: post-upgrade }
  92. - name: Upgrade calico and external cloud provider on all masters, calico-rrs, and nodes
  93. hosts: kube_control_plane:calico_rr:kube_node
  94. gather_facts: False
  95. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  96. serial: "{{ serial | default('20%') }}"
  97. environment: "{{ proxy_disable_env }}"
  98. roles:
  99. - { role: kubespray-defaults }
  100. - { role: kubernetes-apps/external_cloud_controller, tags: external-cloud-controller }
  101. - { role: network_plugin, tags: network }
  102. - { role: kubernetes-apps/network_plugin, tags: network }
  103. - { role: kubernetes-apps/policy_controller, tags: policy-controller }
  104. - name: Finally handle worker upgrades, based on given batch size
  105. hosts: kube_node:calico_rr:!kube_control_plane
  106. gather_facts: False
  107. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  108. environment: "{{ proxy_disable_env }}"
  109. serial: "{{ serial | default('20%') }}"
  110. roles:
  111. - { role: kubespray-defaults }
  112. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  113. - { role: upgrade/system-upgrade, tags: system-upgrade }
  114. - { role: download, tags: download, when: "system_upgrade and system_upgrade_reboot != 'never' and not skip_downloads" }
  115. - { role: container-engine, tags: "container-engine", when: deploy_container_engine }
  116. - { role: kubernetes/node, tags: node }
  117. - { role: kubernetes/kubeadm, tags: kubeadm }
  118. - { role: kubernetes/node-label, tags: node-label }
  119. - { role: upgrade/post-upgrade, tags: post-upgrade }
  120. - name: Patch Kubernetes for Windows
  121. hosts: kube_control_plane[0]
  122. gather_facts: False
  123. any_errors_fatal: true
  124. environment: "{{ proxy_disable_env }}"
  125. roles:
  126. - { role: kubespray-defaults }
  127. - { role: win_nodes/kubernetes_patch, tags: ["master", "win_nodes"] }
  128. - name: Install Calico Route Reflector
  129. hosts: calico_rr
  130. gather_facts: False
  131. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  132. environment: "{{ proxy_disable_env }}"
  133. roles:
  134. - { role: kubespray-defaults }
  135. - { role: network_plugin/calico/rr, tags: network }
  136. - name: Install Kubernetes apps
  137. hosts: kube_control_plane
  138. gather_facts: False
  139. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  140. environment: "{{ proxy_disable_env }}"
  141. roles:
  142. - { role: kubespray-defaults }
  143. - { role: kubernetes-apps/ingress_controller, tags: ingress-controller }
  144. - { role: kubernetes-apps/external_provisioner, tags: external-provisioner }
  145. - { role: kubernetes-apps, tags: apps }
  146. - name: Apply resolv.conf changes now that cluster DNS is up
  147. hosts: k8s_cluster
  148. gather_facts: False
  149. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  150. environment: "{{ proxy_disable_env }}"
  151. roles:
  152. - { role: kubespray-defaults }
  153. - { role: kubernetes/preinstall, when: "dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'", tags: resolvconf, dns_late: true }