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.

132 lines
3.0 KiB

9 years ago
  1. ---
  2. - import_tasks: facts.yml
  3. tags:
  4. - facts
  5. - import_tasks: pre_upgrade.yml
  6. tags:
  7. - kubelet
  8. - name: Ensure /var/lib/cni exists
  9. file:
  10. path: /var/lib/cni
  11. state: directory
  12. mode: 0755
  13. - import_tasks: install.yml
  14. tags:
  15. - kubelet
  16. - import_tasks: nginx-proxy.yml
  17. when: is_kube_master == false and loadbalancer_apiserver_localhost
  18. tags:
  19. - nginx
  20. - name: Write kubelet config file (non-kubeadm)
  21. template:
  22. src: kubelet.standard.env.j2
  23. dest: "{{ kube_config_dir }}/kubelet.env"
  24. backup: yes
  25. when: not kubeadm_enabled
  26. notify: restart kubelet
  27. tags:
  28. - kubelet
  29. - name: Write kubelet config file (kubeadm)
  30. template:
  31. src: kubelet.kubeadm.env.j2
  32. dest: "{{ kube_config_dir }}/kubelet.env"
  33. backup: yes
  34. when: kubeadm_enabled
  35. notify: restart kubelet
  36. tags:
  37. - kubelet
  38. - kubeadm
  39. - name: write the kubecfg (auth) file for kubelet
  40. template:
  41. src: "{{ item }}-kubeconfig.yaml.j2"
  42. dest: "{{ kube_config_dir }}/{{ item }}-kubeconfig.yaml"
  43. backup: yes
  44. with_items:
  45. - node
  46. - kube-proxy
  47. when: not kubeadm_enabled
  48. notify: restart kubelet
  49. tags:
  50. - kubelet
  51. - name: Ensure nodePort range is reserved
  52. sysctl:
  53. name: net.ipv4.ip_local_reserved_ports
  54. value: "{{ kube_apiserver_node_port_range }}"
  55. sysctl_set: yes
  56. state: present
  57. reload: yes
  58. when: kube_apiserver_node_port_range is defined
  59. tags:
  60. - kube-proxy
  61. - name: Verify if br_netfilter module exists
  62. shell: "modinfo br_netfilter"
  63. register: modinfo_br_netfilter
  64. failed_when: modinfo_br_netfilter.rc not in [0, 1]
  65. changed_when: false
  66. - name: Enable br_netfilter module
  67. modprobe:
  68. name: br_netfilter
  69. state: present
  70. when: modinfo_br_netfilter.rc == 0
  71. - name: Persist br_netfilter module
  72. copy:
  73. dest: /etc/modules-load.d/kubespray-br_netfilter.conf
  74. content: br_netfilter
  75. when: modinfo_br_netfilter.rc == 0
  76. # kube-proxy needs net.bridge.bridge-nf-call-iptables enabled when found if br_netfilter is not a module
  77. - name: Check if bridge-nf-call-iptables key exists
  78. command: "sysctl net.bridge.bridge-nf-call-iptables"
  79. failed_when: false
  80. changed_when: false
  81. register: sysctl_bridge_nf_call_iptables
  82. - name: Enable bridge-nf-call tables
  83. sysctl:
  84. name: "{{ item }}"
  85. state: present
  86. value: 1
  87. reload: yes
  88. when: modinfo_br_netfilter.rc == 1 and sysctl_bridge_nf_call_iptables.rc == 0
  89. with_items:
  90. - net.bridge.bridge-nf-call-iptables
  91. - net.bridge.bridge-nf-call-arptables
  92. - net.bridge.bridge-nf-call-ip6tables
  93. - name: Write proxy manifest
  94. template:
  95. src: manifests/kube-proxy.manifest.j2
  96. dest: "{{ kube_manifest_dir }}/kube-proxy.manifest"
  97. when: not kubeadm_enabled
  98. tags:
  99. - kube-proxy
  100. - name: Purge proxy manifest for kubeadm
  101. file:
  102. path: "{{ kube_manifest_dir }}/kube-proxy.manifest"
  103. state: absent
  104. when: kubeadm_enabled
  105. tags:
  106. - kube-proxy
  107. # reload-systemd
  108. - meta: flush_handlers
  109. - name: Enable kubelet
  110. service:
  111. name: kubelet
  112. enabled: yes
  113. state: started
  114. tags:
  115. - kubelet