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.

148 lines
5.5 KiB

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