Fix kube-proxy ds win nodeselector check for 1.17 (#5982)
* Fix kube-proxy ds nodeselector for older versions * Fix for ansible-lintpull/5993/head
parent
6e29a47784
commit
536606c2ed
|
@ -3,3 +3,5 @@
|
|||
kubernetes_user_manifests_path: "{{ ansible_env.HOME }}/kube-manifests"
|
||||
# Optionally remove kube_proxy installed by kubeadm
|
||||
kube_proxy_remove: false
|
||||
# nodeselector for kube-proxy ds is beta until 1.18
|
||||
kube_proxy_nodeselector: "{{ 'kubernetes.io/os' if kube_version is version('v1.18.0', '>=') else 'beta.kubernetes.io/os' }}"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"spec":{"template":{"spec":{"nodeSelector":{"kubernetes.io/os":"linux"}}}}}
|
|
@ -9,17 +9,12 @@
|
|||
|
||||
- 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
|
||||
command: >-
|
||||
{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf
|
||||
get ds kube-proxy --namespace=kube-system
|
||||
-o jsonpath='{.spec.template.spec.nodeSelector.kubernetes\.io/os}'
|
||||
-o jsonpath='{.spec.template.spec.nodeSelector.{{ kube_proxy_nodeselector | regex_replace('\.', '\\.') }}}'
|
||||
register: current_kube_proxy_state
|
||||
retries: 60
|
||||
delay: 5
|
||||
|
@ -30,9 +25,7 @@
|
|||
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)"
|
||||
args:
|
||||
chdir: "{{ kubernetes_user_manifests_path }}"
|
||||
'{"spec":{"template":{"spec":{"nodeSelector":{"{{ kube_proxy_nodeselector }}":"linux"} }}}}'
|
||||
register: patch_kube_proxy_state
|
||||
when: current_kube_proxy_state.stdout | trim | lower != "linux"
|
||||
|
||||
|
|
Loading…
Reference in New Issue