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.

35 lines
1.4 KiB

  1. ---
  2. - name: "Pre-upgrade | etcd3 upgrade | see if old config exists"
  3. command: "{{ bin_dir }}/etcdctl --peers={{ etcd_access_addresses }} ls /registry/minions"
  4. environment:
  5. ETCDCTL_API: 2
  6. ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/node-{{ inventory_hostname }}.pem"
  7. ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/node-{{ inventory_hostname }}-key.pem"
  8. register: old_data_exists
  9. delegate_to: "{{groups['etcd'][0]}}"
  10. changed_when: false
  11. when: kube_apiserver_storage_backend == "etcd3"
  12. failed_when: false
  13. - name: "Pre-upgrade | etcd3 upgrade | use etcd2 unless forced to etcd3"
  14. set_fact:
  15. kube_apiserver_storage_backend: "etcd2"
  16. when: old_data_exists.rc == 0 and not force_etcd3|bool
  17. - name: "Pre-upgrade | Delete master manifests"
  18. file:
  19. path: "/etc/kubernetes/manifests/{{item}}.manifest"
  20. state: absent
  21. with_items:
  22. - ["kube-apiserver", "kube-controller-manager", "kube-scheduler"]
  23. register: kube_apiserver_manifest_replaced
  24. when: (secret_changed|default(false) or etcd_secret_changed|default(false))
  25. - name: "Pre-upgrade | Delete master containers forcefully"
  26. shell: "docker ps -af name=k8s_{{item}}* -q | xargs --no-run-if-empty docker rm -f"
  27. with_items:
  28. - ["kube-apiserver", "kube-controller-manager", "kube-scheduler"]
  29. when: kube_apiserver_manifest_replaced.changed
  30. register: remove_master_container
  31. retries: 4
  32. until: remove_master_container.rc == 0
  33. delay: 5