forked from kubernetes-sigs/kubespray
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If no_proxy_exclude_workers is true, workers will be excluded from th…
…e no_proxy variable. This prevents docker engine restarting when scaling workers. (kubernetes-sigs#6520) Signed-off-by: holmesb <5072156+holmesb@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
51 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 38 additions & 33 deletions
71
roles/kubespray-defaults/tasks/no_proxy.yml
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,38 @@ | ||
--- | ||
- name: Set no_proxy to all assigned cluster IPs and hostnames | ||
set_fact: | ||
no_proxy_prepare: >- | ||
{%- if loadbalancer_apiserver is defined -%} | ||
{{ apiserver_loadbalancer_domain_name| default('') }}, | ||
{{ loadbalancer_apiserver.address | default('') }}, | ||
{%- endif -%} | ||
{%- for item in (groups['k8s-cluster'] + groups['etcd'] + groups['calico-rr']|default([]))|unique -%} | ||
{{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(fallback_ips[item])) }}, | ||
{%- if item != hostvars[item].get('ansible_hostname', '') -%} | ||
{{ hostvars[item]['ansible_hostname'] }}, | ||
{{ hostvars[item]['ansible_hostname'] }}.{{ dns_domain }}, | ||
{%- endif -%} | ||
{{ item }},{{ item }}.{{ dns_domain }}, | ||
{%- endfor -%} | ||
{%- if additional_no_proxy is defined -%} | ||
{{ additional_no_proxy }}, | ||
{%- endif -%} | ||
127.0.0.1,localhost,{{ kube_service_addresses }},{{ kube_pods_subnet }} | ||
delegate_to: localhost | ||
connection: local | ||
delegate_facts: yes | ||
become: no | ||
run_once: yes | ||
|
||
- name: Populates no_proxy to all hosts | ||
set_fact: | ||
no_proxy: "{{ hostvars.localhost.no_proxy_prepare }}" | ||
proxy_env: "{{ proxy_env | combine({ | ||
'no_proxy': hostvars.localhost.no_proxy_prepare, | ||
'NO_PROXY': hostvars.localhost.no_proxy_prepare | ||
}) }}" | ||
--- | ||
- name: Set no_proxy to all assigned cluster IPs and hostnames | ||
set_fact: | ||
no_proxy_prepare: >- | ||
{%- if loadbalancer_apiserver is defined -%} | ||
{{ apiserver_loadbalancer_domain_name| default('') }}, | ||
{{ loadbalancer_apiserver.address | default('') }}, | ||
{%- endif -%} | ||
{%- if ( (no_proxy_exclude_workers is defined) and (no_proxy_exclude_workers) ) -%} | ||
{% set cluster_or_master = 'kube-master' %} | ||
{% else %} | ||
{% set cluster_or_master = 'k8s-cluster' %} | ||
{% endif %} | ||
{%- for item in (groups[cluster_or_master] + groups['etcd'] + groups['calico-rr']|default([]))|unique -%} | ||
{{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(fallback_ips[item])) }}, | ||
{%- if item != hostvars[item].get('ansible_hostname', '') -%} | ||
{{ hostvars[item]['ansible_hostname'] }}, | ||
{{ hostvars[item]['ansible_hostname'] }}.{{ dns_domain }}, | ||
{%- endif -%} | ||
{{ item }},{{ item }}.{{ dns_domain }}, | ||
{%- endfor -%} | ||
{%- if additional_no_proxy is defined -%} | ||
{{ additional_no_proxy }}, | ||
{%- endif -%} | ||
127.0.0.1,localhost,{{ kube_service_addresses }},{{ kube_pods_subnet }} | ||
delegate_to: localhost | ||
connection: local | ||
delegate_facts: yes | ||
become: no | ||
run_once: yes | ||
|
||
- name: Populates no_proxy to all hosts | ||
set_fact: | ||
no_proxy: "{{ hostvars.localhost.no_proxy_prepare }}" | ||
proxy_env: "{{ proxy_env | combine({ | ||
'no_proxy': hostvars.localhost.no_proxy_prepare, | ||
'NO_PROXY': hostvars.localhost.no_proxy_prepare | ||
}) }}" |