Skip to content

Commit

Permalink
删除ansible hosts中自动生成的etcd 相关变量
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmzj committed Aug 22, 2018
1 parent 2ebc31c commit 0036c62
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 33 deletions.
10 changes: 1 addition & 9 deletions docs/02-安装etcd集群.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
## 02-安装etcd集群.md

``` bash
roles/etcd
├── tasks
│   └── main.yml
└── templates
├── etcd-csr.json.j2
└── etcd.service.j2
```
kuberntes 系统使用 etcd 存储所有数据,是最重要的组件之一,注意 etcd集群只能有奇数个节点(1,3,5...),本文档使用3个节点做集群。

请在另外窗口打开[roles/etcd/tasks/main.yml](../roles/etcd/tasks/main.yml) 文件,对照看以下讲解内容。
Expand Down Expand Up @@ -110,7 +102,7 @@ systemctl daemon-reload && systemctl enable etcd && systemctl start etcd
``` bash
# 根据hosts中配置设置shell变量 $NODE_IPS
export NODE_IPS="192.168.1.1 192.168.1.2 192.168.1.3"
$ for ip in ${NODE_IPS}; do
for ip in ${NODE_IPS}; do
ETCDCTL_API=3 etcdctl \
--endpoints=https://${ip}:2379 \
--cacert=/etc/kubernetes/ssl/ca.pem \
Expand Down
8 changes: 0 additions & 8 deletions example/hosts.allinone.example
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ CLUSTER_DNS_SVC_IP="10.68.0.2"
# 集群 DNS 域名
CLUSTER_DNS_DOMAIN="cluster.local."

# etcd 集群间通信的IP和端口, 根据etcd组成员自动生成
TMP_NODES="{% for h in groups['etcd'] %}{{ hostvars[h]['NODE_NAME'] }}=https://{{ h }}:2380,{% endfor %}"
ETCD_NODES="{{ TMP_NODES.rstrip(',') }}"

# etcd 集群服务地址列表, 根据etcd组成员自动生成
TMP_ENDPOINTS="{% for h in groups['etcd'] %}https://{{ h }}:2379,{% endfor %}"
ETCD_ENDPOINTS="{{ TMP_ENDPOINTS.rstrip(',') }}"

# 集群basic auth 使用的用户名和密码
BASIC_AUTH_USER="admin"
BASIC_AUTH_PASS="test1234"
Expand Down
8 changes: 0 additions & 8 deletions example/hosts.m-masters.example
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,6 @@ CLUSTER_DNS_SVC_IP="10.68.0.2"
# 集群 DNS 域名
CLUSTER_DNS_DOMAIN="cluster.local."

# etcd 集群间通信的IP和端口, 根据etcd组成员自动生成
TMP_NODES="{% for h in groups['etcd'] %}{{ hostvars[h]['NODE_NAME'] }}=https://{{ h }}:2380,{% endfor %}"
ETCD_NODES="{{ TMP_NODES.rstrip(',') }}"

# etcd 集群服务地址列表, 根据etcd组成员自动生成
TMP_ENDPOINTS="{% for h in groups['etcd'] %}https://{{ h }}:2379,{% endfor %}"
ETCD_ENDPOINTS="{{ TMP_ENDPOINTS.rstrip(',') }}"

# 集群basic auth 使用的用户名和密码
BASIC_AUTH_USER="admin"
BASIC_AUTH_PASS="test1234"
Expand Down
8 changes: 0 additions & 8 deletions example/hosts.s-master.example
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ CLUSTER_DNS_SVC_IP="10.68.0.2"
# 集群 DNS 域名
CLUSTER_DNS_DOMAIN="cluster.local."

# etcd 集群间通信的IP和端口, 根据etcd组成员自动生成
TMP_NODES="{% for h in groups['etcd'] %}{{ hostvars[h]['NODE_NAME'] }}=https://{{ h }}:2380,{% endfor %}"
ETCD_NODES="{{ TMP_NODES.rstrip(',') }}"

# etcd 集群服务地址列表, 根据etcd组成员自动生成
TMP_ENDPOINTS="{% for h in groups['etcd'] %}https://{{ h }}:2379,{% endfor %}"
ETCD_ENDPOINTS="{{ TMP_ENDPOINTS.rstrip(',') }}"

# 集群basic auth 使用的用户名和密码
BASIC_AUTH_USER="admin"
BASIC_AUTH_PASS="test1234"
Expand Down
4 changes: 4 additions & 0 deletions roles/calico/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 部分calico相关配置,更全配置可以去roles/calico/templates/calico.yaml.j2自定义

# etcd 集群服务地址列表, 根据etcd组成员自动生成
TMP_ENDPOINTS: "{% for h in groups['etcd'] %}https://{{ h }}:2379,{% endfor %}"
ETCD_ENDPOINTS: "{{ TMP_ENDPOINTS.rstrip(',') }}"

# 设置 CALICO_IPV4POOL_IPIP=“off”,可以提高网络性能,条件限制详见 docs/06.calico.md
CALICO_IPV4POOL_IPIP: "always"

Expand Down
4 changes: 4 additions & 0 deletions roles/cluster-restore/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# 指定需要恢复的 etcd 数据备份,默认使用最近的一次备份
db_to_restore: "snapshot.db"

# etcd 集群间通信的IP和端口, 根据etcd组成员自动生成
TMP_NODES: "{% for h in groups['etcd'] %}{{ hostvars[h]['NODE_NAME'] }}=https://{{ h }}:2380,{% endfor %}"
ETCD_NODES: "{{ TMP_NODES.rstrip(',') }}"
3 changes: 3 additions & 0 deletions roles/etcd/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# etcd 集群间通信的IP和端口, 根据etcd组成员自动生成
TMP_NODES: "{% for h in groups['etcd'] %}{{ hostvars[h]['NODE_NAME'] }}=https://{{ h }}:2380,{% endfor %}"
ETCD_NODES: "{{ TMP_NODES.rstrip(',') }}"
4 changes: 4 additions & 0 deletions roles/kube-master/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# etcd 集群服务地址列表, 根据etcd组成员自动生成
TMP_ENDPOINTS: "{% for h in groups['etcd'] %}https://{{ h }}:2379,{% endfor %}"
ETCD_ENDPOINTS: "{{ TMP_ENDPOINTS.rstrip(',') }}"

4 changes: 4 additions & 0 deletions tools/init_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
- cluster-restore
- cluster-storage
- docker
- etcd
- flannel
- helm
- kube-master
- kube-node
- kube-router
- lb
Expand All @@ -32,8 +34,10 @@
- cluster-restore
- cluster-storage
- docker
- etcd
- flannel
- helm
- kube-master
- kube-node
- kube-router
- lb
Expand Down

0 comments on commit 0036c62

Please sign in to comment.