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.

74 lines
2.3 KiB

  1. ---
  2. - name: kubeadm | Check api is up
  3. uri:
  4. url: "https://{{ ip | default(fallback_ips[inventory_hostname]) }}:{{ kube_apiserver_port }}/healthz"
  5. validate_certs: false
  6. when: inventory_hostname == groups['kube-master']|first
  7. register: _result
  8. retries: 60
  9. delay: 5
  10. until: _result.status == 200
  11. - name: kubeadm | Upgrade first master
  12. command: >-
  13. timeout -k 600s 600s
  14. {{ bin_dir }}/kubeadm
  15. upgrade apply -y {{ kube_version }}
  16. --config={{ kube_config_dir }}/kubeadm-config.yaml
  17. --ignore-preflight-errors=all
  18. --allow-experimental-upgrades
  19. --etcd-upgrade={{ etcd_kubeadm_enabled | bool | lower }}
  20. --force
  21. register: kubeadm_upgrade
  22. # Retry is because upload config sometimes fails
  23. retries: 3
  24. until: kubeadm_upgrade.rc == 0
  25. when: inventory_hostname == groups['kube-master']|first
  26. failed_when: kubeadm_upgrade.rc != 0 and "field is immutable" not in kubeadm_upgrade.stderr
  27. environment:
  28. PATH: "{{ bin_dir }}:{{ ansible_env.PATH }}"
  29. notify: Master | restart kubelet
  30. - name: kubeadm | Upgrade other masters
  31. command: >-
  32. timeout -k 600s 600s
  33. {{ bin_dir }}/kubeadm
  34. upgrade apply -y {{ kube_version }}
  35. --config={{ kube_config_dir }}/kubeadm-config.yaml
  36. --ignore-preflight-errors=all
  37. --allow-experimental-upgrades
  38. --etcd-upgrade={{ etcd_kubeadm_enabled | bool | lower }}
  39. --force
  40. register: kubeadm_upgrade
  41. when: inventory_hostname != groups['kube-master']|first
  42. failed_when:
  43. - kubeadm_upgrade.rc != 0
  44. - '"field is immutable" not in kubeadm_upgrade.stderr'
  45. environment:
  46. PATH: "{{ bin_dir }}:{{ ansible_env.PATH }}"
  47. notify: Master | restart kubelet
  48. - name: kubeadm | clean kubectl cache to refresh api types
  49. file:
  50. path: "{{ item }}"
  51. state: absent
  52. with_items:
  53. - /root/.kube/cache
  54. - /root/.kube/http-cache
  55. # FIXME: https://github.com/kubernetes/kubeadm/issues/1318
  56. - name: kubeadm | scale down coredns replicas to 0 if not using coredns dns_mode
  57. command: >-
  58. {{ bin_dir }}/kubectl
  59. --kubeconfig /etc/kubernetes/admin.conf
  60. -n kube-system
  61. scale deployment/coredns --replicas 0
  62. register: scale_down_coredns
  63. retries: 6
  64. delay: 5
  65. until: scale_down_coredns is succeeded
  66. run_once: yes
  67. when:
  68. - kubeadm_scale_down_coredns_enabled
  69. - dns_mode not in ['coredns', 'coredns_dual']
  70. changed_when: false