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.

89 lines
2.7 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. ---
  2. - name: Copy kubectl bash completion
  3. copy:
  4. src: kubectl_bash_completion.sh
  5. dest: /etc/bash_completion.d/kubectl.sh
  6. when: ansible_os_family in ["Debian","RedHat"]
  7. - name: Copy kube-apiserver binary
  8. command: rsync -piu "{{ local_release_dir }}/kubernetes/bin/kube-apiserver" "{{ bin_dir }}/kube-apiserver"
  9. register: kube_apiserver_copy
  10. changed_when: false
  11. - name: Copy kubectl binary
  12. command: rsync -piu "{{ local_release_dir }}/kubernetes/bin/kubectl" "{{ bin_dir }}/kubectl"
  13. changed_when: false
  14. - name: install | Write kube-apiserver systemd init file
  15. template:
  16. src: "kube-apiserver.service.j2"
  17. dest: "/etc/systemd/system/kube-apiserver.service"
  18. backup: yes
  19. when: ansible_service_mgr == "systemd"
  20. notify: restart kube-apiserver
  21. - name: install | Write kube-apiserver initd script
  22. template:
  23. src: "deb-kube-apiserver.initd.j2"
  24. dest: "/etc/init.d/kube-apiserver"
  25. owner: root
  26. mode: 0755
  27. backup: yes
  28. when: ansible_service_mgr in ["sysvinit","upstart"] and ansible_os_family == "Debian"
  29. - name: Write kube-apiserver config file
  30. template:
  31. src: "kube-apiserver.j2"
  32. dest: "{{ kube_config_dir }}/kube-apiserver.env"
  33. backup: yes
  34. notify: restart kube-apiserver
  35. - name: Allow apiserver to bind on both secure and insecure ports
  36. shell: setcap cap_net_bind_service+ep {{ bin_dir }}/kube-apiserver
  37. changed_when: false
  38. - meta: flush_handlers
  39. - include: start.yml
  40. with_items: "{{ groups['kube-master'] }}"
  41. when: "{{ hostvars[item].inventory_hostname == inventory_hostname }}"
  42. # Create kube-system namespace
  43. - name: copy 'kube-system' namespace manifest
  44. copy: src=namespace.yml dest=/etc/kubernetes/kube-system-ns.yml
  45. run_once: yes
  46. when: inventory_hostname == groups['kube-master'][0]
  47. - name: Check if kube-system exists
  48. command: "{{ bin_dir }}/kubectl get ns kube-system"
  49. register: 'kubesystem'
  50. changed_when: False
  51. failed_when: False
  52. run_once: yes
  53. - name: wait for the apiserver to be running
  54. wait_for:
  55. port: "{{kube_apiserver_insecure_port}}"
  56. timeout: 60
  57. - name: Create 'kube-system' namespace
  58. command: "{{ bin_dir }}/kubectl create -f /etc/kubernetes/kube-system-ns.yml"
  59. changed_when: False
  60. when: kubesystem|failed and inventory_hostname == groups['kube-master'][0]
  61. # Write manifests
  62. - name: Write kube-controller-manager manifest
  63. template:
  64. src: manifests/kube-controller-manager.manifest.j2
  65. dest: "{{ kube_manifest_dir }}/kube-controller-manager.manifest"
  66. - name: Write kube-scheduler manifest
  67. template:
  68. src: manifests/kube-scheduler.manifest.j2
  69. dest: "{{ kube_manifest_dir }}/kube-scheduler.manifest"
  70. - name: restart kubelet
  71. service:
  72. name: kubelet
  73. state: restarted
  74. changed_when: false