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:
|
|
|
|
# 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-20 23:43:39 +08:00
|
|
|
-o jsonpath='{.spec.template.spec.nodeSelector.{{ kube_proxy_nodeselector | regex_replace('\.', '\\.') }}}'
|
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
|
2020-04-20 23:43:39 +08:00
|
|
|
'{"spec":{"template":{"spec":{"nodeSelector":{"{{ kube_proxy_nodeselector }}":"linux"} }}}}'
|
2018-06-05 19:15:20 +08:00
|
|
|
register: patch_kube_proxy_state
|
|
|
|
when: current_kube_proxy_state.stdout | trim | lower != "linux"
|
|
|
|
|
2021-07-12 15:00:47 +08:00
|
|
|
- debug: # noqa unnamed-task
|
|
|
|
msg: "{{ patch_kube_proxy_state.stdout_lines }}"
|
2018-06-05 19:15:20 +08:00
|
|
|
when: patch_kube_proxy_state is not skipped
|
|
|
|
|
2021-07-12 15:00:47 +08:00
|
|
|
- debug: # noqa unnamed-task
|
|
|
|
msg: "{{ patch_kube_proxy_state.stderr_lines }}"
|
2018-06-05 19:15:20 +08:00
|
|
|
when: patch_kube_proxy_state is not skipped
|
|
|
|
tags: init
|
2018-10-16 22:15:05 +08:00
|
|
|
when:
|
2020-09-17 19:30:45 +08:00
|
|
|
- kube_proxy_deployed
|