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.

168 lines
6.1 KiB

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