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.

130 lines
4.8 KiB

  1. ---
  2. - hosts: localhost
  3. gather_facts: False
  4. roles:
  5. - { role: kubespray-defaults}
  6. - { role: bastion-ssh-config, tags: ["localhost", "bastion"]}
  7. - hosts: k8s-cluster:etcd:calico-rr
  8. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  9. gather_facts: false
  10. vars:
  11. # Need to disable pipelining for bootstrap-os as some systems have requiretty in sudoers set, which makes pipelining
  12. # fail. bootstrap-os fixes this on these systems, so in later plays it can be enabled.
  13. ansible_ssh_pipelining: false
  14. roles:
  15. - { role: kubespray-defaults}
  16. - { role: bootstrap-os, tags: bootstrap-os}
  17. - hosts: k8s-cluster:etcd:calico-rr
  18. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  19. vars:
  20. ansible_ssh_pipelining: true
  21. gather_facts: true
  22. pre_tasks:
  23. - name: gather facts from all instances
  24. setup:
  25. delegate_to: "{{item}}"
  26. delegate_facts: True
  27. with_items: "{{ groups['k8s-cluster'] + groups['etcd'] + groups['calico-rr']|default([]) }}"
  28. - hosts: k8s-cluster:etcd:calico-rr
  29. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  30. serial: "{{ serial | default('20%') }}"
  31. roles:
  32. - { role: kubespray-defaults}
  33. - { role: kubernetes/preinstall, tags: preinstall }
  34. - { role: docker, tags: docker, when: container_manager == 'docker' }
  35. - { role: cri-o, tags: crio, when: container_manager == 'crio' }
  36. - role: rkt
  37. tags: rkt
  38. when: "'rkt' in [etcd_deployment_type, kubelet_deployment_type, vault_deployment_type]"
  39. - { role: download, tags: download, when: "not skip_downloads" }
  40. environment: "{{proxy_env}}"
  41. - hosts: etcd:k8s-cluster:vault
  42. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  43. roles:
  44. - { role: kubespray-defaults, when: "cert_management == 'vault'" }
  45. - { role: vault, tags: vault, vault_bootstrap: true, when: "cert_management == 'vault'" }
  46. environment: "{{proxy_env}}"
  47. - hosts: etcd
  48. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  49. roles:
  50. - { role: kubespray-defaults}
  51. - { role: etcd, tags: etcd, etcd_cluster_setup: true }
  52. - hosts: k8s-cluster
  53. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  54. roles:
  55. - { role: kubespray-defaults}
  56. - { role: etcd, tags: etcd, etcd_cluster_setup: false }
  57. - hosts: etcd:k8s-cluster:vault
  58. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  59. roles:
  60. - { role: kubespray-defaults, when: "cert_management == 'vault'"}
  61. - { role: vault, tags: vault, when: "cert_management == 'vault'"}
  62. environment: "{{proxy_env}}"
  63. #Handle upgrades to master components first to maintain backwards compat.
  64. - hosts: kube-master
  65. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  66. serial: 1
  67. roles:
  68. - { role: kubespray-defaults}
  69. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  70. - { role: kubernetes/node, tags: node }
  71. - { role: kubernetes/master, tags: master }
  72. - { role: kubernetes/client, tags: client }
  73. - { role: kubernetes-apps/cluster_roles, tags: cluster-roles }
  74. - { role: upgrade/post-upgrade, tags: post-upgrade }
  75. environment: "{{proxy_env}}"
  76. #Upgrade calico on all masters and nodes
  77. - hosts: kube-master:kube-node
  78. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  79. serial: "{{ serial | default('20%') }}"
  80. roles:
  81. - { role: kubespray-defaults}
  82. - { role: network_plugin, tags: network }
  83. - { role: kubernetes-apps/network_plugin, tags: network }
  84. - { role: kubernetes-apps/policy_controller, tags: policy-controller }
  85. #Finally handle worker upgrades, based on given batch size
  86. - hosts: kube-node:!kube-master
  87. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  88. serial: "{{ serial | default('20%') }}"
  89. roles:
  90. - { role: kubespray-defaults}
  91. - { role: upgrade/pre-upgrade, tags: pre-upgrade }
  92. - { role: kubernetes/node, tags: node }
  93. - { role: upgrade/post-upgrade, tags: post-upgrade }
  94. - { role: kubernetes/kubeadm, tags: kubeadm, when: "kubeadm_enabled" }
  95. - { role: kubespray-defaults}
  96. environment: "{{proxy_env}}"
  97. - hosts: kube-master[0]
  98. any_errors_fatal: true
  99. roles:
  100. - { role: kubespray-defaults}
  101. - { role: kubernetes-apps/rotate_tokens, tags: rotate_tokens, when: "secret_changed|default(false)" }
  102. - hosts: calico-rr
  103. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  104. roles:
  105. - { role: kubespray-defaults}
  106. - { role: network_plugin/calico/rr, tags: network }
  107. - hosts: k8s-cluster
  108. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  109. roles:
  110. - { role: kubespray-defaults}
  111. - { role: dnsmasq, when: "dns_mode == 'dnsmasq_kubedns'", tags: dnsmasq }
  112. - { role: kubernetes/preinstall, when: "dns_mode != 'none' and resolvconf_mode == 'host_resolvconf'", tags: resolvconf }
  113. - hosts: kube-master[0]
  114. any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
  115. roles:
  116. - { role: kubespray-defaults}
  117. - { role: kubernetes-apps, tags: apps }