加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
91-upgrade-cluster.yml 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
setzero 提交于 2021-05-12 09:54 . [IMP]优化脚本默认值获取
- 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:
- prepare/variables
- 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:
- prepare/variables
- upgrade
environment: "{{ proxy_env }}"
- hosts:
- etcd
- new-etcd
- kube-master
- new-master
roles:
- prepare/variables
- etcd/certificates
- kube-certificates
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化