Skip to content

Commit

Permalink
清除 new-node/new-master 相关配置
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmzj committed Feb 24, 2019
1 parent faccf82 commit ae5bd3f
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 75 deletions.
2 changes: 0 additions & 2 deletions 03.docker.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# to install docker service
- hosts:
- kube-master
- new-master
- kube-node
- new-node
roles:
- docker
2 changes: 0 additions & 2 deletions 11.harbor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

- hosts:
- kube-master
- new-master
- kube-node
- new-node
tasks:
- name: Define 'harbor_host', a domain
set_fact: harbor_host="{{ hostvars[groups.harbor[0]]['HARBOR_DOMAIN'] }}"
Expand Down
43 changes: 7 additions & 36 deletions 21.addmaster.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,28 @@
# reconfigure and restart the haproxy service
- hosts: lb
roles:
- lb

- hosts: new-master
- hosts: "{{ NODE_TO_ADD }}"
roles:
- { role: chrony, when: "hostvars[groups.deploy[0]]['NTP_ENABLED'] == 'yes'" }
- prepare
- docker
- kube-master
- kube-node
#
- { role: calico, when: "CLUSTER_NETWORK == 'calico'" }
- { role: cilium, when: "CLUSTER_NETWORK == 'cilium'" }
- { role: flannel, when: "CLUSTER_NETWORK == 'flannel'" }
- { role: kube-router, when: "CLUSTER_NETWORK == 'kube-router'" }
#
tasks:
- name: Making master nodes SchedulingDisabled
shell: "{{ bin_dir }}/kubectl cordon {{ inventory_hostname }} "
shell: "{{ bin_dir }}/kubectl cordon {{ NODE_TO_ADD }} "
delegate_to: "{{ groups.deploy[0] }}"
when: DEPLOY_MODE != "allinone"
ignore_errors: true

- name: Setting master role name
shell: "{{ bin_dir }}/kubectl label node {{ inventory_hostname }} kubernetes.io/role=master --overwrite"
shell: "{{ bin_dir }}/kubectl label node {{ NODE_TO_ADD }} kubernetes.io/role=master --overwrite"
ignore_errors: true
delegate_to: "{{ groups.deploy[0] }}"

# modify the ansible hosts file
- hosts:
- new-master
tasks:
- name: tag new-master FINISHED=yes
shell: 'sed -i "/\[new-master/,/\[kube-node/s/{{ inventory_hostname }}/{{ inventory_hostname }} FINISHED=yes/" {{ base_dir }}/hosts'
args:
warn: false
connection: local

- name: cp new-master to 'kube-master' group
lineinfile:
dest: "{{ base_dir }}/hosts"
state: present
insertafter: '^\[kube-master'
firstmatch: yes
line: "{{ inventory_hostname }} NEW_MASTER=yes"
connection: local

- hosts: deploy
tasks:
- name: rm new-master in ansible hosts
lineinfile:
dest: "{{ base_dir }}/hosts"
state: absent
regexp: 'FINISHED=yes'
connection: local
# reconfigure and restart the haproxy service
- hosts: lb
roles:
- { role: lb, tags:['restart_lb'] }
4 changes: 0 additions & 4 deletions 22.upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,20 @@
# update kubectl binary
- hosts:
- kube-master
- new-master
- kube-node
- new-node
- deploy
roles:
- prepare

# update masters
- hosts:
- kube-master
- new-master
roles:
- kube-master
- kube-node

# update nodes
- hosts:
- kube-node
- new-node
roles:
- { role: kube-node, when: "DEPLOY_MODE != 'allinone'" }
4 changes: 0 additions & 4 deletions 24.restore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@
- hosts:
- kube-master
- kube-node
- new-master
- new-node
roles:
- docker

# to set up 'kube-master' nodes
- hosts:
- kube-master
- new-master
roles:
- kube-master
- kube-node
Expand All @@ -67,7 +64,6 @@
# to set up 'kube-node' nodes
- hosts:
- kube-node
- new-node
roles:
- kube-node

Expand Down
7 changes: 0 additions & 7 deletions 99.clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# to clean 'kube-node' nodes
- hosts:
- kube-master
- new-master
- kube-node
- new-node
tasks:
- name: stop and disable kube-node service
service: name={{ item }} state=stopped enabled=no
Expand All @@ -33,7 +31,6 @@
# to clean 'kube-master' nodes
- hosts:
- kube-master
- new-master
tasks:
- name: stop and disable kube-master service
service: name={{ item }} state=stopped enabled=no
Expand All @@ -54,9 +51,7 @@
# to clean docker service and networking
- hosts:
- kube-master
- new-master
- kube-node
- new-node
tasks:
- name: clean 'kube-router' stuff
shell: "{{ bin_dir }}/docker run --privileged --net=host cloudnativelabs/kube-router --cleanup-config"
Expand Down Expand Up @@ -168,9 +163,7 @@
# to clean ntp, certs and keys, env path
- hosts:
- kube-master
- new-master
- kube-node
- new-node
- deploy
- etcd
- lb
Expand Down
6 changes: 0 additions & 6 deletions roles/ex-lb/templates/haproxy.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ listen ingress-node
{% for host in groups['kube-node'] %}
server {{ host }} {{ host }}:23456 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% for host in groups['new-node'] %}
server {{ host }} {{ host }}:23456 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% endif %}
{% if INGRESS_TLS_NODEPORT_LB == "yes" %}

Expand All @@ -39,7 +36,4 @@ listen ingress-node-tls
{% for host in groups['kube-node'] %}
server {{ host }} {{ host }}:23457 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% for host in groups['new-node'] %}
server {{ host }} {{ host }}:23457 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% endif %}
2 changes: 1 addition & 1 deletion roles/kube-master/templates/kube-apiserver-v1.8.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ExecStart={{ bin_dir }}/kube-apiserver \
--etcd-keyfile={{ ca_dir }}/kubernetes-key.pem \
--etcd-servers={{ ETCD_ENDPOINTS }} \
--enable-swagger-ui=true \
--apiserver-count={% if DEPLOY_MODE == "multi-master" %}{{ groups['kube-master']|length + groups['new-master']|length }}{% else %}1{% endif %} \
--apiserver-count={% if DEPLOY_MODE == "multi-master" %}{{ groups['kube-master']|length }}{% else %}1{% endif %} \
--allow-privileged=true \
--audit-log-maxage=30 \
--audit-log-maxbackup=3 \
Expand Down
9 changes: 0 additions & 9 deletions roles/lb/templates/haproxy.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ listen kube-master
{% for host in groups['kube-master'] %}
server {{ host }} {{ host }}:6443 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% for host in groups['new-master'] %}
server {{ host }} {{ host }}:6443 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% if INGRESS_NODEPORT_LB == "yes" %}

listen ingress-node
Expand All @@ -36,9 +33,6 @@ listen ingress-node
{% for host in groups['kube-node'] %}
server {{ host }} {{ host }}:23456 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% for host in groups['new-node'] %}
server {{ host }} {{ host }}:23456 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% endif %}
{% if INGRESS_TLS_NODEPORT_LB == "yes" %}

Expand All @@ -50,7 +44,4 @@ listen ingress-node-tls
{% for host in groups['kube-node'] %}
server {{ host }} {{ host }}:23457 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% for host in groups['new-node'] %}
server {{ host }} {{ host }}:23457 check inter 2000 fall 2 rise 2 weight 1
{% endfor %}
{% endif %}
4 changes: 0 additions & 4 deletions tools/change_k8s_network.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# 重置k8s pod网络脚本,使用请仔细阅读 docs/op/change_k8s_network.md
- hosts:
- kube-master
- new-master
- kube-node
- new-node
tasks:
- name: 获取所有已经创建的POD信息
command: "{{ bin_dir }}/kubectl get daemonset -n kube-system"
Expand Down Expand Up @@ -98,9 +96,7 @@

- hosts:
- kube-master
- new-master
- kube-node
- new-node
# 安装新的网络插件
roles:
- { role: calico, when: "CLUSTER_NETWORK == 'calico'" }
Expand Down

0 comments on commit ae5bd3f

Please sign in to comment.