Fix kube-proxy ds win nodeselector check for 1.17 (#5982)
* Fix kube-proxy ds nodeselector for older versions * Fix for ansible-lint
This commit is contained in:
parent
6e29a47784
commit
536606c2ed
3 changed files with 4 additions and 10 deletions
|
@ -3,3 +3,5 @@
|
||||||
kubernetes_user_manifests_path: "{{ ansible_env.HOME }}/kube-manifests"
|
kubernetes_user_manifests_path: "{{ ansible_env.HOME }}/kube-manifests"
|
||||||
# Optionally remove kube_proxy installed by kubeadm
|
# Optionally remove kube_proxy installed by kubeadm
|
||||||
kube_proxy_remove: false
|
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
|
- name: Apply kube-proxy nodeselector
|
||||||
block:
|
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"
|
# 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
|
- name: Check current nodeselector for kube-proxy daemonset
|
||||||
command: >-
|
command: >-
|
||||||
{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf
|
{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf
|
||||||
get ds kube-proxy --namespace=kube-system
|
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
|
register: current_kube_proxy_state
|
||||||
retries: 60
|
retries: 60
|
||||||
delay: 5
|
delay: 5
|
||||||
|
@ -30,9 +25,7 @@
|
||||||
shell: >-
|
shell: >-
|
||||||
{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf
|
{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf
|
||||||
patch ds kube-proxy --namespace=kube-system --type=strategic -p
|
patch ds kube-proxy --namespace=kube-system --type=strategic -p
|
||||||
"$(cat nodeselector-os-linux-patch.json)"
|
'{"spec":{"template":{"spec":{"nodeSelector":{"{{ kube_proxy_nodeselector }}":"linux"} }}}}'
|
||||||
args:
|
|
||||||
chdir: "{{ kubernetes_user_manifests_path }}"
|
|
||||||
register: patch_kube_proxy_state
|
register: patch_kube_proxy_state
|
||||||
when: current_kube_proxy_state.stdout | trim | lower != "linux"
|
when: current_kube_proxy_state.stdout | trim | lower != "linux"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue