2018-12-25 15:06:27 +08:00
|
|
|
---
|
2020-02-28 03:47:28 +08:00
|
|
|
- name: kubeadm | Check api is up
|
|
|
|
uri:
|
2020-05-18 16:21:36 +08:00
|
|
|
url: "https://{{ ip | default(fallback_ips[inventory_hostname]) }}:{{ kube_apiserver_port }}/healthz"
|
2020-02-28 03:47:28 +08:00
|
|
|
validate_certs: false
|
|
|
|
when: inventory_hostname == groups['kube-master']|first
|
|
|
|
register: _result
|
|
|
|
retries: 60
|
|
|
|
delay: 5
|
|
|
|
until: _result.status == 200
|
|
|
|
|
2018-12-25 15:06:27 +08:00
|
|
|
- name: kubeadm | Upgrade first master
|
|
|
|
command: >-
|
|
|
|
timeout -k 600s 600s
|
|
|
|
{{ bin_dir }}/kubeadm
|
|
|
|
upgrade apply -y {{ kube_version }}
|
|
|
|
--config={{ kube_config_dir }}/kubeadm-config.yaml
|
|
|
|
--ignore-preflight-errors=all
|
|
|
|
--allow-experimental-upgrades
|
2020-07-08 03:36:00 +08:00
|
|
|
--etcd-upgrade={{ etcd_kubeadm_enabled | bool | lower }}
|
2018-12-25 15:06:27 +08:00
|
|
|
--force
|
|
|
|
register: kubeadm_upgrade
|
|
|
|
# Retry is because upload config sometimes fails
|
|
|
|
retries: 3
|
2020-04-21 22:20:56 +08:00
|
|
|
until: kubeadm_upgrade.rc == 0
|
2018-12-25 15:06:27 +08:00
|
|
|
when: inventory_hostname == groups['kube-master']|first
|
|
|
|
failed_when: kubeadm_upgrade.rc != 0 and "field is immutable" not in kubeadm_upgrade.stderr
|
|
|
|
notify: Master | restart kubelet
|
|
|
|
|
2019-04-19 21:01:54 +08:00
|
|
|
# FIXME: https://github.com/kubernetes/kubeadm/issues/1498 remove stdout_lines
|
|
|
|
# check after issue is fixed
|
2018-12-25 15:06:27 +08:00
|
|
|
- name: kubeadm | Upgrade other masters
|
|
|
|
command: >-
|
|
|
|
timeout -k 600s 600s
|
|
|
|
{{ bin_dir }}/kubeadm
|
|
|
|
upgrade apply -y {{ kube_version }}
|
|
|
|
--config={{ kube_config_dir }}/kubeadm-config.yaml
|
|
|
|
--ignore-preflight-errors=all
|
|
|
|
--allow-experimental-upgrades
|
2020-07-08 03:36:00 +08:00
|
|
|
--etcd-upgrade={{ etcd_kubeadm_enabled | bool | lower }}
|
2019-07-09 20:41:59 +08:00
|
|
|
--force
|
2018-12-25 15:06:27 +08:00
|
|
|
register: kubeadm_upgrade
|
|
|
|
when: inventory_hostname != groups['kube-master']|first
|
2019-04-19 21:01:54 +08:00
|
|
|
failed_when:
|
|
|
|
- kubeadm_upgrade.rc != 0
|
|
|
|
- '"field is immutable" not in kubeadm_upgrade.stderr'
|
|
|
|
- kubeadm_upgrade.stdout_lines | length > 1
|
2018-12-25 15:06:27 +08:00
|
|
|
notify: Master | restart kubelet
|
2019-11-05 19:34:38 +08:00
|
|
|
|
2020-01-06 18:23:35 +08:00
|
|
|
- name: kubeadm | clean kubectl cache to refresh api types
|
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- /root/.kube/cache
|
|
|
|
- /root/.kube/http-cache
|
|
|
|
|
2019-11-05 19:34:38 +08:00
|
|
|
# FIXME: https://github.com/kubernetes/kubeadm/issues/1318
|
|
|
|
- name: kubeadm | scale down coredns replicas to 0 if not using coredns dns_mode
|
|
|
|
command: >-
|
|
|
|
{{ bin_dir }}/kubectl
|
|
|
|
--kubeconfig /etc/kubernetes/admin.conf
|
|
|
|
-n kube-system
|
|
|
|
scale deployment/coredns --replicas 0
|
|
|
|
register: scale_down_coredns
|
|
|
|
retries: 6
|
|
|
|
delay: 5
|
|
|
|
until: scale_down_coredns is succeeded
|
2019-11-18 16:13:41 +08:00
|
|
|
run_once: yes
|
2019-11-05 19:34:38 +08:00
|
|
|
when:
|
|
|
|
- kubeadm_scale_down_coredns_enabled
|
|
|
|
- dns_mode not in ['coredns', 'coredns_dual']
|
|
|
|
changed_when: false
|