40857b9859
* Move proxy_env to kubespray-defaults/defaults There is no reasons to use set_facts here Signed-off-by: Etienne Champetier <e.champetier@ateme.com> * Ensure kubeadm doesn't use proxy *_proxy variables might be present in the environment (/etc/environment, bash profile, ...) When this is the case we end up with those proxy configuration in /etc/kubernetes/manifests/kube-*.yaml manifests We cannot unset env variables, but kubeadm is nice enough to ignore empty vars93d288e2a4/cmd/kubeadm/app/util/env.go (L27)
Signed-off-by: Etienne Champetier <e.champetier@ateme.com> (cherry picked from commit1c5391dda7
)
47 lines
1.5 KiB
YAML
47 lines
1.5 KiB
YAML
---
|
|
- name: Test if correct apiserver is set in all kubeconfigs
|
|
shell: >-
|
|
grep -Fq "{{ kube_apiserver_endpoint }}" {{ kube_config_dir }}/admin.conf &&
|
|
grep -Fq "{{ kube_apiserver_endpoint }}" {{ kube_config_dir }}/controller-manager.conf &&
|
|
grep -Fq "{{ kube_apiserver_endpoint }}" {{ kube_config_dir }}/kubelet.conf &&
|
|
grep -Fq "{{ kube_apiserver_endpoint }}" {{ kube_config_dir }}/scheduler.conf
|
|
register: kubeconfig_correct_apiserver
|
|
changed_when: False
|
|
failed_when: False
|
|
|
|
- name: Create temporary directory
|
|
tempfile:
|
|
state: directory
|
|
register: kubeconfig_temp_dir
|
|
when: kubeconfig_correct_apiserver.rc != 0
|
|
|
|
- name: Generate new kubeconfigs with correct apiserver
|
|
command: >-
|
|
{{ bin_dir }}/kubeadm init phase kubeconfig all
|
|
--config {{ kube_config_dir }}/kubeadm-config.yaml
|
|
--kubeconfig-dir {{ kubeconfig_temp_dir.path }}
|
|
environment: "{{ proxy_disable_env }}"
|
|
when: kubeconfig_correct_apiserver.rc != 0
|
|
|
|
- name: Copy new kubeconfigs to kube config dir
|
|
copy:
|
|
src: "{{ kubeconfig_temp_dir.path }}/{{ item }}"
|
|
dest: "{{ kube_config_dir }}/{{ item }}"
|
|
mode: 0640
|
|
remote_src: yes
|
|
when: kubeconfig_correct_apiserver.rc != 0
|
|
with_items:
|
|
- admin.conf
|
|
- controller-manager.conf
|
|
- kubelet.conf
|
|
- scheduler.conf
|
|
notify:
|
|
- "Master | Restart kube-controller-manager"
|
|
- "Master | Restart kube-scheduler"
|
|
- "Master | reload kubelet"
|
|
|
|
- name: Cleanup temporary directory
|
|
file:
|
|
path: "{{ kubeconfig_temp_dir.path }}"
|
|
state: absent
|
|
when: kubeconfig_correct_apiserver.rc != 0
|