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

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