2018-06-05 19:15:20 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Ensure that user manifests directory exists
|
|
|
|
file:
|
|
|
|
path: "{{ kubernetes_user_manifests_path }}/kubernetes"
|
|
|
|
state: directory
|
|
|
|
recurse: yes
|
|
|
|
tags: [init, cni]
|
|
|
|
|
|
|
|
- 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
|
2020-03-11 20:17:36 +08:00
|
|
|
command: >-
|
|
|
|
{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf
|
|
|
|
get ds kube-proxy --namespace=kube-system
|
2020-04-18 15:41:35 +08:00
|
|
|
-o jsonpath='{.spec.template.spec.nodeSelector.kubernetes\.io/os}'
|
2018-06-05 19:15:20 +08:00
|
|
|
register: current_kube_proxy_state
|
2019-12-12 03:23:55 +08:00
|
|
|
retries: 60
|
|
|
|
delay: 5
|
|
|
|
until: current_kube_proxy_state is succeeded
|
2020-03-11 20:17:36 +08:00
|
|
|
changed_when: false
|
2018-06-05 19:15:20 +08:00
|
|
|
|
|
|
|
- name: Apply nodeselector patch for kube-proxy daemonset
|
2020-03-11 20:17:36 +08:00
|
|
|
shell: >-
|
|
|
|
{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf
|
|
|
|
patch ds kube-proxy --namespace=kube-system --type=strategic -p
|
|
|
|
"$(cat nodeselector-os-linux-patch.json)"
|
2018-06-05 19:15:20 +08: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 22:15:05 +08:00
|
|
|
when:
|
|
|
|
- not kube_proxy_remove
|