forked from TimeBye/kubeadm-ha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
91-upgrade-cluster.yml
53 lines (47 loc) · 1.48 KB
/
91-upgrade-cluster.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
- hosts: kube-master[0]
tasks:
- name: 校验 kube_upgrade_version 是否设置
assert:
that: kube_upgrade_version is defined
msg: "请设置变量 kube_upgrade_version。"
- name: 获取当前 kubernetes 实际版本
shell: "kubeadm version -o short"
register: kubeadm_version_output
- name: 校验 kube_upgrade_version 与当前 kubernetes 版本差异
assert:
that:
- kubeadm_version_output.stdout is version('v{{ kube_upgrade_version }}', '<=')
- "{{ kube_upgrade_version.split('.')[1]|int - kubeadm_version_output.stdout.split('.')[1]|int }} <= 1"
msg: "请设置正确的升级版本号,次版本号只能升一个版本,不能跨版本升级(比如:1.13版本只能升级到1.14,不能直接升级1.15)。"
- hosts:
- all
roles:
- backup
- hosts:
- all
gather_facts: false
tasks:
- name: "设置代理服务器环境变量"
set_fact:
proxy_env:
http_proxy: "{{ http_proxy | default ('') }}"
HTTP_PROXY: "{{ http_proxy | default ('') }}"
https_proxy: "{{ https_proxy | default ('') }}"
HTTPS_PROXY: "{{ https_proxy | default ('') }}"
no_proxy: "{{ no_proxy | default ('') }}"
NO_PROXY: "{{ no_proxy | default ('') }}"
no_log: true
- hosts:
- all
serial: 1
roles:
- upgrade
environment: "{{ proxy_env }}"
- hosts:
- etcd
- new-etcd
- kube-master
- new-master
roles:
- etcd/certificates
- kube-certificates