You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.6 KiB

  1. ---
  2. - name: Ensure that user manifests directory exists
  3. file:
  4. path: "{{ kubernetes_user_manifests_path }}/kubernetes"
  5. state: directory
  6. recurse: yes
  7. tags: [init, cni]
  8. - name: Apply kube-proxy hostnameOverride
  9. block:
  10. - name: Copy kube-proxy daemonset hostnameOverride patch
  11. copy:
  12. src: hostnameOverride-patch.json
  13. dest: "{{ kubernetes_user_manifests_path }}/hostnameOverride-patch.json"
  14. - name: Check current command for kube-proxy daemonset
  15. shell: "{{bin_dir}}/kubectl get ds kube-proxy --namespace=kube-system -o jsonpath='{.spec.template.spec.containers[0].command}'"
  16. register: current_kube_proxy_command
  17. - name: Apply hostnameOverride patch for kube-proxy daemonset
  18. shell: "{{bin_dir}}/kubectl patch ds kube-proxy --namespace=kube-system --type=json -p \"$(cat hostnameOverride-patch.json)\""
  19. args:
  20. chdir: "{{ kubernetes_user_manifests_path }}"
  21. register: patch_kube_proxy_command
  22. when: not current_kube_proxy_command.stdout is search("--hostname-override=${NODE_NAME}")
  23. - debug: msg={{ patch_kube_proxy_command.stdout_lines }}
  24. when: patch_kube_proxy_command is not skipped
  25. - debug: msg={{ patch_kube_proxy_command.stderr_lines }}
  26. when: patch_kube_proxy_command is not skipped
  27. tags: init
  28. when:
  29. - not kube_proxy_remove
  30. - name: Apply kube-proxy nodeselector
  31. block:
  32. - name: Copy kube-proxy daemonset nodeselector patch
  33. copy:
  34. src: nodeselector-os-linux-patch.json
  35. dest: "{{ kubernetes_user_manifests_path }}/nodeselector-os-linux-patch.json"
  36. # Due to https://github.com/kubernetes/kubernetes/issues/58212 we cannot rely on exit code for "kubectl patch"
  37. - name: Check current nodeselector for kube-proxy daemonset
  38. shell: "{{bin_dir}}/kubectl get ds kube-proxy --namespace=kube-system -o jsonpath='{.spec.template.spec.nodeSelector.beta.kubernetes.io/os}'"
  39. register: current_kube_proxy_state
  40. - name: Apply nodeselector patch for kube-proxy daemonset
  41. shell: "{{bin_dir}}/kubectl patch ds kube-proxy --namespace=kube-system --type=strategic -p \"$(cat nodeselector-os-linux-patch.json)\""
  42. args:
  43. chdir: "{{ kubernetes_user_manifests_path }}"
  44. register: patch_kube_proxy_state
  45. when: current_kube_proxy_state.stdout | trim | lower != "linux"
  46. - debug: msg={{ patch_kube_proxy_state.stdout_lines }}
  47. when: patch_kube_proxy_state is not skipped
  48. - debug: msg={{ patch_kube_proxy_state.stderr_lines }}
  49. when: patch_kube_proxy_state is not skipped
  50. tags: init
  51. when:
  52. - not kube_proxy_remove