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.3 KiB

6 years ago
  1. ---
  2. - name: Check ansible version
  3. import_playbook: ansible_version.yml
  4. - name: Add kube-master nodes to kube_control_plane
  5. # This is for old inventory which contains kube-master instead of kube_control_plane
  6. hosts: kube-master
  7. gather_facts: false
  8. tasks:
  9. - name: add nodes to kube_control_plane group
  10. group_by:
  11. key: 'kube_control_plane'
  12. - hosts: bastion[0]
  13. gather_facts: False
  14. environment: "{{ proxy_disable_env }}"
  15. roles:
  16. - { role: kubespray-defaults }
  17. - { role: bastion-ssh-config, tags: ["localhost", "bastion"] }
  18. - hosts: k8s-cluster:etcd:calico-rr
  19. strategy: linear
  20. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  21. gather_facts: false
  22. environment: "{{ proxy_disable_env }}"
  23. vars:
  24. # Need to disable pipelining for bootstrap-os as some systems have requiretty in sudoers set, which makes pipelining
  25. # fail. bootstrap-os fixes this on these systems, so in later plays it can be enabled.
  26. ansible_ssh_pipelining: false
  27. roles:
  28. - { role: kubespray-defaults }
  29. - { role: bootstrap-os, tags: bootstrap-os}
  30. - name: Gather facts
  31. tags: always
  32. import_playbook: facts.yml
  33. - name: Download images to ansible host cache via first kube_control_plane node
  34. hosts: kube_control_plane[0]
  35. gather_facts: False
  36. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  37. environment: "{{ proxy_disable_env }}"
  38. roles:
  39. - { role: kubespray-defaults, when: "not skip_downloads and download_run_once and not download_localhost"}
  40. - { role: kubernetes/preinstall, tags: preinstall, when: "not skip_downloads and download_run_once and not download_localhost" }
  41. - { role: download, tags: download, when: "not skip_downloads and download_run_once and not download_localhost" }
  42. - name: Prepare nodes for upgrade
  43. hosts: k8s-cluster:etcd:calico-rr
  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: kubernetes/preinstall, tags: preinstall }
  50. - { role: download, tags: download, when: "not skip_downloads" }
  51. - name: Upgrade container engine on non-cluster nodes
  52. hosts: etcd:calico-rr:!k8s-cluster
  53. gather_facts: False
  54. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  55. environment: "{{ proxy_disable_env }}"
  56. serial: "{{ serial | default('20%') }}"
  57. roles:
  58. - { role: kubespray-defaults }
  59. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  60. - hosts: etcd
  61. gather_facts: False
  62. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  63. environment: "{{ proxy_disable_env }}"
  64. roles:
  65. - { role: kubespray-defaults }
  66. - role: etcd
  67. tags: etcd
  68. vars:
  69. etcd_cluster_setup: true
  70. etcd_events_cluster_setup: false
  71. when: not etcd_kubeadm_enabled | default(false)
  72. - hosts: k8s-cluster
  73. gather_facts: False
  74. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  75. environment: "{{ proxy_disable_env }}"
  76. roles:
  77. - { role: kubespray-defaults }
  78. - role: etcd
  79. tags: etcd
  80. vars:
  81. etcd_cluster_setup: false
  82. etcd_events_cluster_setup: false
  83. when: not etcd_kubeadm_enabled | default(false)
  84. - name: Handle upgrades to master components first to maintain backwards compat.
  85. gather_facts: False
  86. hosts: kube_control_plane
  87. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  88. environment: "{{ proxy_disable_env }}"
  89. serial: 1
  90. roles:
  91. - { role: kubespray-defaults }
  92. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  93. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  94. - { role: kubernetes/node, tags: node }
  95. - { role: kubernetes/control-plane, tags: master, upgrade_cluster_setup: true }
  96. - { role: kubernetes/client, tags: client }
  97. - { role: kubernetes/node-label, tags: node-label }
  98. - { role: kubernetes-apps/cluster_roles, tags: cluster-roles }
  99. - { role: kubernetes-apps, tags: csi-driver }
  100. - { role: upgrade/post-upgrade, tags: post-upgrade }
  101. - name: Upgrade calico and external cloud provider on all masters, calico-rrs, and nodes
  102. hosts: kube_control_plane:calico-rr:kube-node
  103. gather_facts: False
  104. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  105. serial: "{{ serial | default('20%') }}"
  106. environment: "{{ proxy_disable_env }}"
  107. roles:
  108. - { role: kubespray-defaults }
  109. - { role: kubernetes-apps/external_cloud_controller, tags: external-cloud-controller }
  110. - { role: network_plugin, tags: network }
  111. - { role: kubernetes-apps/network_plugin, tags: network }
  112. - { role: kubernetes-apps/policy_controller, tags: policy-controller }
  113. - name: Finally handle worker upgrades, based on given batch size
  114. hosts: kube-node:calico-rr:!kube_control_plane
  115. gather_facts: False
  116. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  117. environment: "{{ proxy_disable_env }}"
  118. serial: "{{ serial | default('20%') }}"
  119. roles:
  120. - { role: kubespray-defaults }
  121. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  122. - { role: container-engine, tags: "container-engine", when: deploy_container_engine|default(true) }
  123. - { role: kubernetes/node, tags: node }
  124. - { role: kubernetes/kubeadm, tags: kubeadm }
  125. - { role: kubernetes/node-label, tags: node-label }
  126. - { role: upgrade/post-upgrade, tags: post-upgrade }
  127. - hosts: kube_control_plane[0]
  128. gather_facts: False
  129. any_errors_fatal: true
  130. environment: "{{ proxy_disable_env }}"
  131. roles:
  132. - { role: kubespray-defaults }
  133. - { role: win_nodes/kubernetes_patch, tags: ["master", "win_nodes"] }
  134. - hosts: calico-rr
  135. gather_facts: False
  136. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  137. environment: "{{ proxy_disable_env }}"
  138. roles:
  139. - { role: kubespray-defaults }
  140. - { role: network_plugin/calico/rr, tags: network }
  141. - hosts: kube_control_plane
  142. gather_facts: False
  143. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  144. environment: "{{ proxy_disable_env }}"
  145. roles:
  146. - { role: kubespray-defaults }
  147. - { role: kubernetes-apps, tags: apps }
  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 }