diff --git a/03.docker.yml b/03.docker.yml index b0711f5..02f3a7e 100644 --- a/03.docker.yml +++ b/03.docker.yml @@ -1,8 +1,6 @@ # to install docker service - hosts: - kube-master - - new-master - kube-node - - new-node roles: - docker diff --git a/11.harbor.yml b/11.harbor.yml index 6443360..289580c 100644 --- a/11.harbor.yml +++ b/11.harbor.yml @@ -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'] }}" diff --git a/21.addmaster.yml b/21.addmaster.yml index dd13466..927edf3 100644 --- a/21.addmaster.yml +++ b/21.addmaster.yml @@ -1,16 +1,10 @@ -# 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'" } @@ -18,40 +12,17 @@ # 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'] } diff --git a/22.upgrade.yml b/22.upgrade.yml index 529b9eb..6a92d3a 100644 --- a/22.upgrade.yml +++ b/22.upgrade.yml @@ -4,9 +4,7 @@ # update kubectl binary - hosts: - kube-master - - new-master - kube-node - - new-node - deploy roles: - prepare @@ -14,7 +12,6 @@ # update masters - hosts: - kube-master - - new-master roles: - kube-master - kube-node @@ -22,6 +19,5 @@ # update nodes - hosts: - kube-node - - new-node roles: - { role: kube-node, when: "DEPLOY_MODE != 'allinone'" } diff --git a/24.restore.yml b/24.restore.yml index d9c90e2..4b0467b 100644 --- a/24.restore.yml +++ b/24.restore.yml @@ -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 @@ -67,7 +64,6 @@ # to set up 'kube-node' nodes - hosts: - kube-node - - new-node roles: - kube-node diff --git a/99.clean.yml b/99.clean.yml index 46748d3..f37fbb5 100644 --- a/99.clean.yml +++ b/99.clean.yml @@ -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 @@ -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 @@ -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" @@ -168,9 +163,7 @@ # to clean ntp, certs and keys, env path - hosts: - kube-master - - new-master - kube-node - - new-node - deploy - etcd - lb diff --git a/roles/ex-lb/templates/haproxy.cfg.j2 b/roles/ex-lb/templates/haproxy.cfg.j2 index da43653..f4cbe97 100644 --- a/roles/ex-lb/templates/haproxy.cfg.j2 +++ b/roles/ex-lb/templates/haproxy.cfg.j2 @@ -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" %} @@ -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 %} diff --git a/roles/kube-master/templates/kube-apiserver-v1.8.service.j2 b/roles/kube-master/templates/kube-apiserver-v1.8.service.j2 index c1357d7..0c3cbbb 100644 --- a/roles/kube-master/templates/kube-apiserver-v1.8.service.j2 +++ b/roles/kube-master/templates/kube-apiserver-v1.8.service.j2 @@ -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 \ diff --git a/roles/lb/templates/haproxy.cfg.j2 b/roles/lb/templates/haproxy.cfg.j2 index 6efe895..b9b3409 100644 --- a/roles/lb/templates/haproxy.cfg.j2 +++ b/roles/lb/templates/haproxy.cfg.j2 @@ -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 @@ -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" %} @@ -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 %} diff --git a/tools/change_k8s_network.yml b/tools/change_k8s_network.yml index 34dff13..99b973f 100644 --- a/tools/change_k8s_network.yml +++ b/tools/change_k8s_network.yml @@ -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" @@ -98,9 +96,7 @@ - hosts: - kube-master - - new-master - kube-node - - new-node # 安装新的网络插件 roles: - { role: calico, when: "CLUSTER_NETWORK == 'calico'" }