2018-06-05 11:15:20 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Ensure that user manifests directory exists
|
|
|
|
file:
|
|
|
|
path: "{{ kubernetes_user_manifests_path }}/kubernetes"
|
|
|
|
state: directory
|
|
|
|
recurse: yes
|
|
|
|
tags: [init, cni]
|
|
|
|
|
2018-11-14 17:37:53 +00:00
|
|
|
- name: Apply kube-proxy hostnameOverride
|
|
|
|
block:
|
|
|
|
- name: Copy kube-proxy daemonset hostnameOverride patch
|
|
|
|
copy:
|
|
|
|
src: hostnameOverride-patch.json
|
|
|
|
dest: "{{ kubernetes_user_manifests_path }}/hostnameOverride-patch.json"
|
|
|
|
|
|
|
|
- name: Check current command for kube-proxy daemonset
|
|
|
|
shell: "{{bin_dir}}/kubectl get ds kube-proxy --namespace=kube-system -o jsonpath='{.spec.template.spec.containers[0].command}'"
|
|
|
|
register: current_kube_proxy_command
|
|
|
|
|
|
|
|
- name: Apply hostnameOverride patch for kube-proxy daemonset
|
2018-11-16 10:35:02 +00:00
|
|
|
shell: "{{bin_dir}}/kubectl patch ds kube-proxy --namespace=kube-system --type=json -p \"$(cat hostnameOverride-patch.json)\""
|
2018-11-14 17:37:53 +00:00
|
|
|
args:
|
|
|
|
chdir: "{{ kubernetes_user_manifests_path }}"
|
|
|
|
register: patch_kube_proxy_command
|
|
|
|
when: not current_kube_proxy_command.stdout is search("--hostname-override=${NODE_NAME}")
|
|
|
|
|
|
|
|
- debug: msg={{ patch_kube_proxy_command.stdout_lines }}
|
|
|
|
when: patch_kube_proxy_command is not skipped
|
|
|
|
|
|
|
|
- debug: msg={{ patch_kube_proxy_command.stderr_lines }}
|
|
|
|
when: patch_kube_proxy_command is not skipped
|
|
|
|
tags: init
|
|
|
|
when:
|
|
|
|
- not kube_proxy_remove
|
|
|
|
|
2018-06-05 11:15:20 +00:00
|
|
|
- name: Apply kube-proxy nodeselector
|
|
|
|
block:
|
|
|
|
- name: Copy kube-proxy daemonset nodeselector patch
|
|
|
|
copy:
|
|
|
|
src: nodeselector-os-linux-patch.json
|
|
|
|
dest: "{{ kubernetes_user_manifests_path }}/nodeselector-os-linux-patch.json"
|
|
|
|
|
|
|
|
# Due to https://github.com/kubernetes/kubernetes/issues/58212 we cannot rely on exit code for "kubectl patch"
|
|
|
|
- name: Check current nodeselector for kube-proxy daemonset
|
2018-09-06 19:26:32 +00:00
|
|
|
shell: "{{bin_dir}}/kubectl get ds kube-proxy --namespace=kube-system -o jsonpath='{.spec.template.spec.nodeSelector.beta.kubernetes.io/os}'"
|
2018-06-05 11:15:20 +00:00
|
|
|
register: current_kube_proxy_state
|
|
|
|
|
|
|
|
- name: Apply nodeselector patch for kube-proxy daemonset
|
2018-09-06 19:26:32 +00:00
|
|
|
shell: "{{bin_dir}}/kubectl patch ds kube-proxy --namespace=kube-system --type=strategic -p \"$(cat nodeselector-os-linux-patch.json)\""
|
2018-06-05 11:15:20 +00:00
|
|
|
args:
|
|
|
|
chdir: "{{ kubernetes_user_manifests_path }}"
|
|
|
|
register: patch_kube_proxy_state
|
|
|
|
when: current_kube_proxy_state.stdout | trim | lower != "linux"
|
|
|
|
|
|
|
|
- debug: msg={{ patch_kube_proxy_state.stdout_lines }}
|
|
|
|
when: patch_kube_proxy_state is not skipped
|
|
|
|
|
|
|
|
- debug: msg={{ patch_kube_proxy_state.stderr_lines }}
|
|
|
|
when: patch_kube_proxy_state is not skipped
|
|
|
|
tags: init
|
2018-10-16 14:15:05 +00:00
|
|
|
when:
|
|
|
|
- not kube_proxy_remove
|