Skip to content

Commit

Permalink
新增两个节点
Browse files Browse the repository at this point in the history
  • Loading branch information
Leif160519 committed Jun 6, 2024
1 parent b1929b7 commit ae8c4ca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
16 changes: 12 additions & 4 deletions inventory/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
# 如果部署单Master,只保留一个Master节点
# 默认Naster节点也部署Node组件
192.168.31.81 node_name=k8s-master-01
192.168.31.80 node_name=k8s-master-02
#192.168.31.80 node_name=k8s-master-02

[node]
192.168.31.82 node_name=k8s-node-01
192.168.31.83 node_name=k8s-node-02
192.168.31.84 node_name=k8s-node-03
192.168.31.85 node_name=k8s-node-04

[etcd]
192.168.31.80 etcd_name=etcd-2
#192.168.31.80 etcd_name=etcd-2
192.168.31.81 etcd_name=etcd-1
192.168.31.82 etcd_name=etcd-3
192.168.31.83 etcd_name=etcd-4
Expand All @@ -19,11 +20,18 @@
[lb]
# 如果部署单Master,该项忽略
192.168.31.81 lb_name=lb-master
192.168.31.80 lb_name=lb-backup
#192.168.31.80 lb_name=lb-backup

[k8s]
[k8s:children]
master
node
newnode

[off] # 下线机器
k8s-master-02

[newnode]
192.168.31.85 node_name=k8s-node-04
#192.168.31.85 node_name=k8s-node-04
192.168.31.86 node_name=k8s-node-05
192.168.31.87 node_name=k8s-node-06
15 changes: 12 additions & 3 deletions playbooks/add-node.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
---
- name: -1.给所有节点添加新节点hosts
hosts: k8s
tasks:
- lineinfile:
path: /etc/hosts
line: "{{ hostvars[item].inventory_hostname }} {{ hostvars[item].node_name }}"
with_items:
- "{{ groups['k8s'] }}"

- name: 0.系统初始化
gather_facts: true
hosts: newnode
hosts: newnode
roles:
- common
tags: common
tags: common

- name: 1.部署Docker
gather_facts: false
hosts: newnode
roles:
- docker
- docker
tags: docker

- name: 2.部署K8S Node
Expand Down

0 comments on commit ae8c4ca

Please sign in to comment.