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.

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