From 9eade647e6be8eb3d17c68249f0932ea1f8de775 Mon Sep 17 00:00:00 2001
From: rongzhang <rongzhang@alauda.io>
Date: Wed, 29 Aug 2018 18:29:24 +0800
Subject: [PATCH] Fix kubeadm lb

---
 .../master/templates/kubeadm-config.v1alpha1.yaml.j2       | 7 ++++---
 .../master/templates/kubeadm-config.v1alpha2.yaml.j2       | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/roles/kubernetes/master/templates/kubeadm-config.v1alpha1.yaml.j2 b/roles/kubernetes/master/templates/kubeadm-config.v1alpha1.yaml.j2
index f0786b4e9..c1a12fa34 100644
--- a/roles/kubernetes/master/templates/kubeadm-config.v1alpha1.yaml.j2
+++ b/roles/kubernetes/master/templates/kubeadm-config.v1alpha1.yaml.j2
@@ -1,10 +1,11 @@
 apiVersion: kubeadm.k8s.io/v1alpha1
 kind: MasterConfiguration
 api:
-  advertiseAddress: {{ ip | default(ansible_default_ipv4.address) }}
-  bindPort: {{ kube_apiserver_port }}
 {% if groups['kube-master'] | length > 1 and kubeadm_config_api_fqdn is defined %}
-  controlPlaneEndpoint: {{ kubeadm_config_api_fqdn }}
+ controlPlaneEndpoint: {{ kubeadm_config_api_fqdn }}:{{ kube_apiserver_port }}
+{% else %}
+ advertiseAddress: {{ ip | default(ansible_default_ipv4.address) }}
+ bindPort: {{ kube_apiserver_port }}
 {% endif %}
 etcd:
   endpoints:
diff --git a/roles/kubernetes/master/templates/kubeadm-config.v1alpha2.yaml.j2 b/roles/kubernetes/master/templates/kubeadm-config.v1alpha2.yaml.j2
index 68c67db59..22c3821fd 100644
--- a/roles/kubernetes/master/templates/kubeadm-config.v1alpha2.yaml.j2
+++ b/roles/kubernetes/master/templates/kubeadm-config.v1alpha2.yaml.j2
@@ -1,10 +1,11 @@
 apiVersion: kubeadm.k8s.io/v1alpha2
 kind: MasterConfiguration
 api:
-  advertiseAddress: {{ ip | default(ansible_default_ipv4.address) }}
-  bindPort: {{ kube_apiserver_port }}
 {% if groups['kube-master'] | length > 1 and kubeadm_config_api_fqdn is defined %}
-  controlPlaneEndpoint: {{ kubeadm_config_api_fqdn }}
+ controlPlaneEndpoint: {{ kubeadm_config_api_fqdn }}:{{ kube_apiserver_port }}
+{% else %}
+ advertiseAddress: {{ ip | default(ansible_default_ipv4.address) }}
+ bindPort: {{ kube_apiserver_port }}
 {% endif %}
 etcd:
   external:
-- 
GitLab