Use a variable for standardizing kubectl invocation (#8329)

* Add kubectl variable

* Replace kubectl usage by kubectl variable in roles

* Remove redundant --kubeconfig on kubectl usage

* Replace unecessary shell usage with command
This commit is contained in:
Max Gautier
2022-01-05 11:26:32 +01:00
committed by GitHub
parent 3eab1129b9
commit cb54eb40ce
25 changed files with 73 additions and 55 deletions

View File

@@ -12,9 +12,9 @@
# 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
{{ kubectl }}
get ds kube-proxy --namespace=kube-system
-o jsonpath='{.spec.template.spec.nodeSelector.{{ kube_proxy_nodeselector | regex_replace('\.', '\\.') }}}'
-o jsonpath={.spec.template.spec.nodeSelector.{{ kube_proxy_nodeselector | regex_replace('\.', '\\.') }}}
register: current_kube_proxy_state
retries: 60
delay: 5
@@ -22,8 +22,8 @@
changed_when: false
- name: Apply nodeselector patch for kube-proxy daemonset
shell: >-
{{ bin_dir }}/kubectl --kubeconfig {{ kube_config_dir }}/admin.conf
command: >
{{ kubectl }}
patch ds kube-proxy --namespace=kube-system --type=strategic -p
'{"spec":{"template":{"spec":{"nodeSelector":{"{{ kube_proxy_nodeselector }}":"linux"} }}}}'
register: patch_kube_proxy_state