upgrade_scale_group.yml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ---
  2. - name: create new scale group
  3. hosts: localhost
  4. tasks:
  5. - name: build upgrade scale groups
  6. import_role:
  7. name: openshift_aws
  8. tasks_from: upgrade_node_group.yml
  9. - fail:
  10. msg: "Ensure that new scale groups were provisioned before proceeding to update."
  11. when:
  12. - "'oo_sg_new_nodes' not in groups or groups.oo_sg_new_nodes|length == 0"
  13. - "'oo_sg_current_nodes' not in groups or groups.oo_sg_current_nodes|length == 0"
  14. - groups.oo_sg_current_nodes == groups.oo_sg_new_nodes
  15. - name: initialize upgrade bits
  16. import_playbook: init.yml
  17. - name: unschedule nodes
  18. hosts: oo_sg_current_nodes
  19. tasks:
  20. - name: Load lib_openshift modules
  21. import_role:
  22. name: ../roles/lib_openshift
  23. - name: Mark node unschedulable
  24. oc_adm_manage_node:
  25. node: "{{ openshift.node.nodename | lower }}"
  26. schedulable: False
  27. delegate_to: "{{ groups.oo_first_master.0 }}"
  28. retries: 10
  29. delay: 5
  30. register: node_unschedulable
  31. until: node_unschedulable is succeeded
  32. - name: Drain nodes
  33. hosts: oo_sg_current_nodes
  34. # This var must be set with -e on invocation, as it is not a per-host inventory var
  35. # and is evaluated early. Values such as "20%" can also be used.
  36. serial: "{{ openshift_upgrade_nodes_serial | default(1) }}"
  37. max_fail_percentage: "{{ openshift_upgrade_nodes_max_fail_percentage | default(0) }}"
  38. tasks:
  39. - name: Drain Node for Kubelet upgrade
  40. command: >
  41. {{ hostvars[groups.oo_first_master.0]['first_master_client_binary'] }} adm drain {{ openshift.node.nodename | lower }}
  42. --config={{ openshift.common.config_base }}/master/admin.kubeconfig
  43. --force --delete-local-data --ignore-daemonsets
  44. --timeout={{ openshift_upgrade_nodes_drain_timeout | default(0) }}s
  45. delegate_to: "{{ groups.oo_first_master.0 }}"
  46. register: l_upgrade_nodes_drain_result
  47. until: not (l_upgrade_nodes_drain_result is failed)
  48. retries: "{{ 1 if openshift_upgrade_nodes_drain_timeout | default(0) == '0' else 0 | int }}"
  49. delay: 5
  50. failed_when:
  51. - l_upgrade_nodes_drain_result is failed
  52. - openshift_upgrade_nodes_drain_timeout | default(0) == '0'
  53. # Alright, let's clean up!
  54. - name: clean up the old scale group
  55. hosts: localhost
  56. tasks:
  57. - name: clean up scale group
  58. import_role:
  59. name: openshift_aws
  60. tasks_from: remove_scale_group.yml