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.

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