kubeasz/tools/change_ip_aio.yml

44 lines
2.0 KiB
YAML
Raw Normal View History

2018-07-23 17:32:36 +08:00
# 敬告本脚本仅作测试交流使用详细操作说明请参阅docs/op/change_ip_allinone.md
# 此脚本仅用于allinone部署情况下需要修改host ip地址使用比如虚机装完allinone部署克隆或者复制分享给别人测试使用
#
# ------- 前提 一个运行正常的allinone部署在虚机关机后复制给别人使用新虚机开机后如果需要修改IP请执行如下步骤
# 1. 修改ansible hosts文件sed -i 's/$OLD_IP/$NEW_IP/g' /etc/ansible/hosts
2019-10-29 16:24:48 +08:00
# 2. 配置ssh免密码登录ssh-copy-id $NEW_IP 按提示完成
# 3. 检查下修改是否成功,并且能够成功执行 ansible all -m ping
2019-05-18 16:48:58 +08:00
# 4. 运行本脚本 ansible-playbook /etc/ansible/tools/change_ip_aio.yml
- hosts: kube-master # hosts 角色无所谓反正allinone所有角色都是同个ip
tasks:
- name: 删除一些证书和配置后面会以新IP重新生成
file: name={{ item }} state=absent
with_items:
- "/etc/etcd/ssl/etcd.pem" # 删除etcd证书
- "/etc/kubernetes/ssl/kubernetes.pem" # 删除旧master证书
- "/etc/kubernetes/kubelet.kubeconfig" # 删除旧kubelet配置文件
- hosts: kube-master
roles:
- deploy
- etcd
- kube-master
- kube-node
- hosts: kube-master
tasks:
- name: 删除老IP地址的node
shell: "{{ bin_dir }}/kubectl get node |grep -v '{{ inventory_hostname }}'|awk '{print $1}' |xargs {{ bin_dir }}/kubectl delete node"
ignore_errors: true
- name: 删除原network插件部署
shell: "{{ bin_dir }}/kubectl delete -f /opt/kube/kube-system/{{ CLUSTER_NETWORK }}.yaml || \
{{ bin_dir }}/kubectl delete -f /opt/kube/kube-ovn/"
ignore_errors: true
- hosts: kube-master
roles:
- { role: calico, when: "CLUSTER_NETWORK == 'calico'" }
2018-08-05 16:12:32 +08:00
- { role: cilium, when: "CLUSTER_NETWORK == 'cilium'" }
- { role: flannel, when: "CLUSTER_NETWORK == 'flannel'" }
- { role: kube-router, when: "CLUSTER_NETWORK == 'kube-router'" }
- { role: kube-ovn, when: "CLUSTER_NETWORK == 'kube-ovn'" }