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.

158 lines
6.1 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. - name: Gather facts
  13. tags: always
  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. - hosts: etcd:kube_control_plane
  43. gather_facts: False
  44. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  45. environment: "{{ proxy_disable_env }}"
  46. roles:
  47. - { role: kubespray-defaults }
  48. - role: etcd
  49. tags: etcd
  50. vars:
  51. etcd_cluster_setup: true
  52. etcd_events_cluster_setup: "{{ etcd_events_cluster_enabled }}"
  53. when: etcd_deployment_type != "kubeadm"
  54. - hosts: k8s_cluster
  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: false
  64. etcd_events_cluster_setup: false
  65. when:
  66. - etcd_deployment_type != "kubeadm"
  67. - kube_network_plugin in ["calico", "flannel", "canal", "cilium"] or cilium_deploy_additionally | default(false) | bool
  68. - kube_network_plugin != "calico" or calico_datastore == "etcd"
  69. - name: Handle upgrades to master components first to maintain backwards compat.
  70. gather_facts: False
  71. hosts: kube_control_plane
  72. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  73. environment: "{{ proxy_disable_env }}"
  74. serial: 1
  75. roles:
  76. - { role: kubespray-defaults }
  77. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  78. - { role: container-engine, tags: "container-engine", when: deploy_container_engine }
  79. - { role: kubernetes/node, tags: node }
  80. - { role: kubernetes/control-plane, tags: master, upgrade_cluster_setup: true }
  81. - { role: kubernetes/client, tags: client }
  82. - { role: kubernetes/node-label, tags: node-label }
  83. - { role: kubernetes-apps/cluster_roles, tags: cluster-roles }
  84. - { role: kubernetes-apps, tags: csi-driver }
  85. - { role: upgrade/post-upgrade, tags: post-upgrade }
  86. - name: Upgrade calico and external cloud provider on all masters, calico-rrs, and nodes
  87. hosts: kube_control_plane:calico_rr:kube_node
  88. gather_facts: False
  89. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  90. serial: "{{ serial | default('20%') }}"
  91. environment: "{{ proxy_disable_env }}"
  92. roles:
  93. - { role: kubespray-defaults }
  94. - { role: kubernetes-apps/external_cloud_controller, tags: external-cloud-controller }
  95. - { role: network_plugin, tags: network }
  96. - { role: kubernetes-apps/network_plugin, tags: network }
  97. - { role: kubernetes-apps/kubelet-csr-approver, tags: kubelet-csr-approver }
  98. - { role: kubernetes-apps/policy_controller, tags: policy-controller }
  99. - name: Finally handle worker upgrades, based on given batch size
  100. hosts: kube_node:calico_rr:!kube_control_plane
  101. gather_facts: False
  102. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  103. environment: "{{ proxy_disable_env }}"
  104. serial: "{{ serial | default('20%') }}"
  105. roles:
  106. - { role: kubespray-defaults }
  107. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  108. - { role: container-engine, tags: "container-engine", when: deploy_container_engine }
  109. - { role: kubernetes/node, tags: node }
  110. - { role: kubernetes/kubeadm, tags: kubeadm }
  111. - { role: kubernetes/node-label, tags: node-label }
  112. - { role: upgrade/post-upgrade, tags: post-upgrade }
  113. - hosts: kube_control_plane[0]
  114. gather_facts: False
  115. any_errors_fatal: true
  116. environment: "{{ proxy_disable_env }}"
  117. roles:
  118. - { role: kubespray-defaults }
  119. - { role: win_nodes/kubernetes_patch, tags: ["master", "win_nodes"] }
  120. - hosts: calico_rr
  121. gather_facts: False
  122. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  123. environment: "{{ proxy_disable_env }}"
  124. roles:
  125. - { role: kubespray-defaults }
  126. - { role: network_plugin/calico/rr, tags: network }
  127. - hosts: kube_control_plane
  128. gather_facts: False
  129. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  130. environment: "{{ proxy_disable_env }}"
  131. roles:
  132. - { role: kubespray-defaults }
  133. - { role: kubernetes-apps/ingress_controller, tags: ingress-controller }
  134. - { role: kubernetes-apps/external_provisioner, tags: external-provisioner }
  135. - { role: kubernetes-apps, tags: apps }
  136. - name: Apply resolv.conf changes now that cluster DNS is up
  137. hosts: k8s_cluster
  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/preinstall, when: "dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'", tags: resolvconf, dns_late: true }