Fix run kubectl error (#2199)

* Fix run kubectl error

Fix run kubectl error when first master doesn't work

* if access_ip is define use first_kube_master
else different master use a different ip

* Delete set first_kube_master and use kube_apiserver_access_address
pull/2383/merge
RongZhang 2018-02-27 07:32:20 -06:00 committed by Matthew Mosesohn
parent b7e06085c7
commit 128d3ef94c
1 changed files with 1 additions and 5 deletions

View File

@ -1,15 +1,11 @@
---
- name: Set first kube master
set_fact:
first_kube_master: "{{ hostvars[groups['kube-master'][0]]['access_ip'] | default(hostvars[groups['kube-master'][0]]['ip'] | default(hostvars[groups['kube-master'][0]]['ansible_default_ipv4']['address'])) }}"
- name: Set external kube-apiserver endpoint
set_fact:
external_apiserver_endpoint: >-
{%- if loadbalancer_apiserver is defined and loadbalancer_apiserver.port is defined -%}
https://{{ apiserver_loadbalancer_domain_name }}:{{ loadbalancer_apiserver.port|default(kube_apiserver_port) }}
{%- else -%}
https://{{ first_kube_master }}:{{ kube_apiserver_port }}
https://{{ kube_apiserver_address }}:{{ kube_apiserver_port }}
{%- endif -%}
tags:
- facts