Fix kube-proxy ds win nodeselector check for 1.17 (#5982)

* Fix kube-proxy ds nodeselector for older versions

* Fix for ansible-lint
pull/5993/head
Lovro Seder 2020-04-20 17:43:39 +02:00 committed by GitHub
parent 6e29a47784
commit 536606c2ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 10 deletions

View File

@ -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' }}"

View File

@ -1 +0,0 @@
{"spec":{"template":{"spec":{"nodeSelector":{"kubernetes.io/os":"linux"}}}}}

View File

@ -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"