From c91a3183d38e6a13bfd0596cd0e873a9e2376430 Mon Sep 17 00:00:00 2001 From: Smaine Kahlouch Date: Tue, 15 Dec 2015 16:51:55 +0100 Subject: [PATCH] manage undefined vars for loadbalancing --- roles/dnsmasq/tasks/main.yml | 2 +- .../kubernetes/node/templates/manifests/kube-proxy.manifest.j2 | 2 +- roles/kubernetes/node/templates/openssl.conf.j2 | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/dnsmasq/tasks/main.yml b/roles/dnsmasq/tasks/main.yml index 87c056167..b3585f47a 100644 --- a/roles/dnsmasq/tasks/main.yml +++ b/roles/dnsmasq/tasks/main.yml @@ -14,7 +14,7 @@ regexp: ".*{{ apiserver_loadbalancer_domain_name }}$" line: "{{ loadbalancer_apiserver.address }} lb-apiserver.kubernetes.local" state: present - when: loadbalancer_apiserver is defined + when: loadbalancer_apiserver is defined and apiserver_loadbalancer_domain_name is defined - name: clean hosts file lineinfile: diff --git a/roles/kubernetes/node/templates/manifests/kube-proxy.manifest.j2 b/roles/kubernetes/node/templates/manifests/kube-proxy.manifest.j2 index 923c29764..3c429ec07 100644 --- a/roles/kubernetes/node/templates/manifests/kube-proxy.manifest.j2 +++ b/roles/kubernetes/node/templates/manifests/kube-proxy.manifest.j2 @@ -15,7 +15,7 @@ spec: {% if inventory_hostname in groups['kube-master'] %} - --master=http://127.0.0.1:8080 {% else %} -{% if loadbalancer_apiserver.address is defined | default('') %} +{% if loadbalancer_apiserver is defined and apiserver_loadbalancer_domain_name is defined %} - --master=https://{{ apiserver_loadbalancer_domain_name }}:{{ loadbalancer_apiserver.port }} {% else %} - --master=https://{{ groups['kube-master'][0] }}:{{ kube_apiserver_port }} diff --git a/roles/kubernetes/node/templates/openssl.conf.j2 b/roles/kubernetes/node/templates/openssl.conf.j2 index 3715d97b8..c594e3337 100644 --- a/roles/kubernetes/node/templates/openssl.conf.j2 +++ b/roles/kubernetes/node/templates/openssl.conf.j2 @@ -10,7 +10,9 @@ subjectAltName = @alt_names DNS.1 = kubernetes DNS.2 = kubernetes.default DNS.3 = kubernetes.default.svc.{{ dns_domain }} +{% if loadbalancer_apiserver is defined and apiserver_loadbalancer_domain_name is defined %} DNS.4 = {{ apiserver_loadbalancer_domain_name }} +{% endif %} {% for host in groups['kube-master'] %} IP.{{ loop.index }} = {{ hostvars[host]['ip'] | default(hostvars[host]['ansible_default_ipv4']['address']) }} {% endfor %}