upgrade_nodes.yml 2.1 KB

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