You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.8 KiB

  1. ---
  2. - set_fact: kube_apiserver_count="{{ groups['kube-master'] | length }}"
  3. - set_fact: kube_apiserver_address="{{ ip | default(ansible_default_ipv4['address']) }}"
  4. - set_fact: kube_apiserver_access_address="{{ access_ip | default(kube_apiserver_address) }}"
  5. - set_fact: is_kube_master="{{ inventory_hostname in groups['kube-master'] }}"
  6. - 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'])) }}"
  7. - set_fact:
  8. kube_apiserver_insecure_bind_address: |-
  9. {% if loadbalancer_apiserver_localhost %}{{ kube_apiserver_address }}{% else %}127.0.0.1{% endif %}
  10. - set_fact:
  11. kube_apiserver_endpoint: |-
  12. {% if loadbalancer_apiserver_localhost -%}
  13. http://127.0.0.1:{{ kube_apiserver_insecure_port }}
  14. {%- elif is_kube_master and loadbalancer_apiserver is not defined -%}
  15. http://127.0.0.1:{{ kube_apiserver_insecure_port }}
  16. {%- else -%}
  17. {%- if loadbalancer_apiserver is defined and loadbalancer_apiserver.port is defined -%}
  18. https://{{ apiserver_loadbalancer_domain_name|default('lb-apiserver.kubernetes.local') }}:{{ loadbalancer_apiserver.port|default(kube_apiserver_port) }}
  19. {%- else -%}
  20. https://{{ first_kube_master }}:{{ kube_apiserver_port }}
  21. {%- endif -%}
  22. {%- endif %}
  23. - set_fact: etcd_address="{{ ip | default(ansible_default_ipv4['address']) }}"
  24. - set_fact: etcd_access_address="{{ access_ip | default(etcd_address) }}"
  25. - set_fact: etcd_peer_url="http://{{ etcd_access_address }}:2380"
  26. - set_fact: etcd_client_url="http://{{ etcd_access_address }}:2379"
  27. - set_fact: etcd_authority="{{ access_ip|default('127.0.0.1') }}:2379"
  28. - set_fact: etcd_endpoint="http://{{ etcd_authority }}"
  29. - set_fact:
  30. etcd_access_addresses: |-
  31. {% for item in groups['etcd'] -%}
  32. http://{{ hostvars[item].etcd_access_address }}:2379{% if not loop.last %},{% endif %}
  33. {%- endfor %}
  34. - set_fact: etcd_access_endpoint="{% if etcd_multiaccess %}{{ etcd_access_addresses }}{% else %}{{ etcd_endpoint }}{% endif %}"
  35. - set_fact:
  36. etcd_member_name: |-
  37. {% for host in groups['etcd'] %}
  38. {% if inventory_hostname == host %}{{"etcd"+loop.index|string }}{% endif %}
  39. {% endfor %}
  40. - set_fact:
  41. etcd_proxy_member_name: |-
  42. {% for host in groups['k8s-cluster'] %}
  43. {% if inventory_hostname == host %}{{"etcd-proxy"+loop.index|string }}{% endif %}
  44. {% endfor %}
  45. - set_fact:
  46. is_etcd_proxy: "{{ inventory_hostname in groups['k8s-cluster'] }}"
  47. - set_fact:
  48. is_etcd_master: "{{ inventory_hostname in groups['etcd'] }}"
  49. - set_fact:
  50. etcd_after_v3: etcd_version | version_compare("v3.0.0", ">=")
  51. - set_fact:
  52. etcd_container_bin_dir: "{% if etcd_after_v3 %}/usr/local/bin/{% else %}/{% endif %}"