2018-09-29 09:06:19 +08:00
|
|
|
# WARNING: Upgrade the k8s cluster can be risky. Make sure you know what you are doing.
|
|
|
|
# Read the guide: 'op/upgrade.md' .
|
2021-01-07 09:30:50 +08:00
|
|
|
# Usage: ezctl upgrade <cluster_name>
|
|
|
|
|
|
|
|
# check k8s version
|
2021-01-19 17:41:00 +08:00
|
|
|
- hosts: kube_master
|
2021-01-07 09:30:50 +08:00
|
|
|
tasks:
|
|
|
|
- name: get running k8s version
|
|
|
|
shell: "{{ bin_dir }}/kube-apiserver --version"
|
|
|
|
register: RUNNING_VER
|
|
|
|
run_once: true
|
|
|
|
|
|
|
|
- name: print running version
|
|
|
|
debug: var="RUNNING_VER.stdout"
|
|
|
|
run_once: true
|
|
|
|
|
|
|
|
- name: get update version
|
|
|
|
shell: "{{ base_dir }}/bin/kube-apiserver --version"
|
|
|
|
register: UPDATE_VER
|
|
|
|
run_once: true
|
|
|
|
connection: local
|
|
|
|
|
|
|
|
- name: print update version
|
|
|
|
debug: var="UPDATE_VER.stdout"
|
|
|
|
run_once: true
|
|
|
|
|
|
|
|
- name: check version
|
|
|
|
fail: msg="running version is the same as the update version, UPDATE ABORT."
|
|
|
|
when: "RUNNING_VER.stdout == UPDATE_VER.stdout"
|
2018-05-11 11:07:14 +08:00
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# update masters
|
2018-08-12 19:53:04 +08:00
|
|
|
- hosts:
|
2021-01-19 17:41:00 +08:00
|
|
|
- kube_master
|
2018-05-11 11:07:14 +08:00
|
|
|
roles:
|
|
|
|
- kube-master
|
|
|
|
- kube-node
|
|
|
|
|
2018-09-29 09:06:19 +08:00
|
|
|
# update nodes
|
2018-08-12 19:53:04 +08:00
|
|
|
- hosts:
|
2021-01-19 17:41:00 +08:00
|
|
|
- kube_node
|
2018-05-11 11:07:14 +08:00
|
|
|
roles:
|
2021-01-19 17:41:00 +08:00
|
|
|
- { role: kube-node, when: "inventory_hostname not in groups['kube_master']" }
|