upgrade_nodes.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ---
  2. - name: Prepull images and rpms before doing rolling restart
  3. hosts: oo_nodes_to_upgrade:!oo_masters_to_config
  4. roles:
  5. - role: openshift_facts
  6. tasks:
  7. - include_role:
  8. name: openshift_node
  9. tasks_from: upgrade_pre.yml
  10. vars:
  11. openshift_node_upgrade_in_progress: True
  12. - name: Drain and upgrade nodes
  13. hosts: oo_nodes_to_upgrade:!oo_masters_to_config
  14. # This var must be set with -e on invocation, as it is not a per-host inventory var
  15. # and is evaluated early. Values such as "20%" can also be used.
  16. serial: "{{ openshift_upgrade_nodes_serial | default(1) }}"
  17. max_fail_percentage: "{{ openshift_upgrade_nodes_max_fail_percentage | default(0) }}"
  18. roles:
  19. - lib_openshift
  20. - openshift_facts
  21. pre_tasks:
  22. # TODO: To better handle re-trying failed upgrades, it would be nice to check if the node
  23. # or docker actually needs an upgrade before proceeding. Perhaps best to save this until
  24. # we merge upgrade functionality into the base roles and a normal config.yml playbook run.
  25. - name: Mark node unschedulable
  26. oc_adm_manage_node:
  27. node: "{{ openshift.node.nodename | lower }}"
  28. schedulable: False
  29. delegate_to: "{{ groups.oo_first_master.0 }}"
  30. retries: 10
  31. delay: 5
  32. register: node_unschedulable
  33. until: node_unschedulable is succeeded
  34. - name: Drain Node for Kubelet upgrade
  35. command: >
  36. {{ hostvars[groups.oo_first_master.0]['first_master_client_binary'] }} adm drain {{ openshift.node.nodename | lower }} --config={{ openshift.common.config_base }}/master/admin.kubeconfig --force --delete-local-data --ignore-daemonsets
  37. delegate_to: "{{ groups.oo_first_master.0 }}"
  38. register: l_upgrade_nodes_drain_result
  39. until: not (l_upgrade_nodes_drain_result is failed)
  40. retries: 60
  41. delay: 60
  42. post_tasks:
  43. - include_role:
  44. name: openshift_node
  45. tasks_from: upgrade.yml
  46. vars:
  47. openshift_node_upgrade_in_progress: True
  48. - name: Set node schedulability
  49. oc_adm_manage_node:
  50. node: "{{ openshift.node.nodename | lower }}"
  51. schedulable: True
  52. delegate_to: "{{ groups.oo_first_master.0 }}"
  53. retries: 10
  54. delay: 5
  55. register: node_schedulable
  56. until: node_schedulable is succeeded
  57. when: node_unschedulable is changed
  58. - name: Re-enable excluders
  59. hosts: oo_nodes_to_upgrade:!oo_masters_to_config
  60. tasks:
  61. - include_role:
  62. name: openshift_excluder
  63. vars:
  64. r_openshift_excluder_action: enable