diff --git a/roles/kube-node/tasks/main.yml b/roles/kube-node/tasks/main.yml index 7d60886..1f61e62 100644 --- a/roles/kube-node/tasks/main.yml +++ b/roles/kube-node/tasks/main.yml @@ -92,18 +92,6 @@ shell: systemctl daemon-reload && systemctl restart kube-proxy tags: reload-kube-proxy, upgrade_k8s, restart_node, force_change_certs -# 设置k8s_nodename 在/etc/hosts 地址解析 -- name: 设置k8s_nodename 在/etc/hosts 地址解析 - lineinfile: - dest: /etc/hosts - state: present - regexp: "{{ K8S_NODENAME }}" - line: "{{ inventory_hostname }} {{ K8S_NODENAME }}" - delegate_to: "{{ item }}" - with_items: "{{ groups.kube_master }}" - when: "inventory_hostname != K8S_NODENAME" - - # 轮询等待kube-proxy启动完成 - name: 轮询等待kube-proxy启动 shell: "systemctl is-active kube-proxy.service" diff --git a/roles/prepare/tasks/main.yml b/roles/prepare/tasks/main.yml index 4ddfc28..39d5497 100644 --- a/roles/prepare/tasks/main.yml +++ b/roles/prepare/tasks/main.yml @@ -41,3 +41,13 @@ state: present regexp: 'easzlab.io.local' line: "{{ ansible_env.SSH_CLIENT.split(' ')[0] }} easzlab.io.local" + +- name: 设置 k8s_nodename 在 master、node 节点 /etc/hosts 地址解析 + lineinfile: + dest: /etc/hosts + state: present + regexp: "{{ K8S_NODENAME }}" + line: "{{ inventory_hostname }} {{ K8S_NODENAME }}" + delegate_to: "{{ item }}" + with_items: ["{{ groups.kube_master }}", "{{ groups.kube_node }}"] + when: "inventory_hostname != K8S_NODENAME" \ No newline at end of file