Skip to content

Commit

Permalink
fix:当node多网卡时可以设置参数使flannel/calico正常运行
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmzj committed Aug 30, 2018
1 parent a86bd89 commit 6c8b3d6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions roles/calico/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 部分calico相关配置,更全配置可以去roles/calico/templates/calico.yaml.j2自定义

# 如果 node 节点有多块网卡,请设置 true
NODE_WITH_MULTIPLE_NETWORKS: "false"

# etcd 集群服务地址列表, 根据etcd组成员自动生成
TMP_ENDPOINTS: "{% for h in groups['etcd'] %}https://{{ h }}:2379,{% endfor %}"
ETCD_ENDPOINTS: "{{ TMP_ENDPOINTS.rstrip(',') }}"
Expand Down
2 changes: 2 additions & 0 deletions roles/calico/templates/calico.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,12 @@ spec:
- name: ENABLED_CONTROLLERS
value: policy,profile,workloadendpoint,node
# if hosts have multiple net interfaces, set following two ENVs
{% if NODE_WITH_MULTIPLE_NETWORKS == 'true' %}
- name: KUBERNETES_SERVICE_HOST
value: "{{ MASTER_IP }}"
- name: KUBERNETES_SERVICE_PORT
value: "{{ KUBE_APISERVER.split(':')[2] }}"
{% end if %}
volumeMounts:
# Mount in the etcd TLS secrets.
- mountPath: /calico-secrets
Expand Down
3 changes: 3 additions & 0 deletions roles/flannel/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 部分flannel配置,详见roles/flannel/templates/kube-flannel.yaml.j2

# 如果 node 节点有多块网卡,请设置 true
NODE_WITH_MULTIPLE_NETWORKS: "false"

# 设置flannel 后端
#FLANNEL_BACKEND: "host-gw"
FLANNEL_BACKEND: "vxlan"
Expand Down
3 changes: 3 additions & 0 deletions roles/flannel/templates/kube-flannel.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,14 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
# if hosts have multiple net interfaces, set following two ENVs
{% if NODE_WITH_MULTIPLE_NETWORKS == 'true' %}
- name: KUBERNETES_SERVICE_HOST
value: "{{ MASTER_IP }}"
#value: "{{ KUBE_APISERVER.split(':')[1].lstrip('/') }}"
- name: KUBERNETES_SERVICE_PORT
value: "{{ KUBE_APISERVER.split(':')[2] }}"
{% end if %}
volumeMounts:
- name: run
mountPath: /run
Expand Down

0 comments on commit 6c8b3d6

Please sign in to comment.