From 113925afea4a309aacab196ab784884aab2e2b28 Mon Sep 17 00:00:00 2001 From: Greg Althaus Date: Sat, 14 Jan 2017 23:38:07 -0600 Subject: [PATCH] Add a variable that defaults to kube_apiserver_port that defines the which port the local nginx proxy should listen on for HA local balancer configurations. --- inventory/group_vars/all.yml | 2 ++ roles/kubernetes/node/templates/nginx.conf.j2 | 2 +- roles/kubernetes/preinstall/tasks/set_facts.yml | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml index 308922a99..0cee9c329 100644 --- a/inventory/group_vars/all.yml +++ b/inventory/group_vars/all.yml @@ -127,6 +127,8 @@ peer_with_router: false kube_apiserver_ip: "{{ kube_service_addresses|ipaddr('net')|ipaddr(1)|ipaddr('address') }}" kube_apiserver_port: 443 # (https) kube_apiserver_insecure_port: 8080 # (http) +# local loadbalancer should use this port instead - default to kube_apiserver_port +nginx_kube_apiserver_port: "{{ kube_apiserver_port }}" # Internal DNS configuration. # Kubernetes can create and mainatain its own DNS server to resolve service names diff --git a/roles/kubernetes/node/templates/nginx.conf.j2 b/roles/kubernetes/node/templates/nginx.conf.j2 index 352218da4..6e8622ed4 100644 --- a/roles/kubernetes/node/templates/nginx.conf.j2 +++ b/roles/kubernetes/node/templates/nginx.conf.j2 @@ -16,7 +16,7 @@ stream { } server { - listen 127.0.0.1:{{ kube_apiserver_port }}; + listen 127.0.0.1:{{ nginx_kube_apiserver_port }}; proxy_pass kube_apiserver; proxy_timeout 10m; proxy_connect_timeout 1s; diff --git a/roles/kubernetes/preinstall/tasks/set_facts.yml b/roles/kubernetes/preinstall/tasks/set_facts.yml index f57cd702e..456467a97 100644 --- a/roles/kubernetes/preinstall/tasks/set_facts.yml +++ b/roles/kubernetes/preinstall/tasks/set_facts.yml @@ -10,7 +10,7 @@ - set_fact: kube_apiserver_endpoint: |- {% if not is_kube_master and loadbalancer_apiserver_localhost -%} - https://localhost:{{ kube_apiserver_port }} + https://localhost:{{ nginx_kube_apiserver_port }} {%- elif is_kube_master and loadbalancer_apiserver is not defined -%} http://127.0.0.1:{{ kube_apiserver_insecure_port }} {%- else -%}