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.

84 lines
2.5 KiB

  1. ---
  2. - name: Canal | Write Canal cni config
  3. template:
  4. src: "cni-canal.conf.j2"
  5. dest: "/etc/cni/net.d/10-canal.conf"
  6. owner: kube
  7. - name: Canal | Create canal certs directory
  8. file:
  9. dest: "{{ canal_cert_dir }}"
  10. state: directory
  11. mode: 0750
  12. owner: root
  13. group: root
  14. - name: Canal | Link etcd certificates for canal-node
  15. file:
  16. src: "{{ etcd_cert_dir }}/{{ item.s }}"
  17. dest: "{{ canal_cert_dir }}/{{ item.d }}"
  18. state: hard
  19. force: yes
  20. with_items:
  21. - {s: "ca.pem", d: "ca_cert.crt"}
  22. - {s: "node-{{ inventory_hostname }}.pem", d: "cert.crt"}
  23. - {s: "node-{{ inventory_hostname }}-key.pem", d: "key.pem"}
  24. - name: Canal | Set Flannel etcd configuration
  25. command: |-
  26. {{ bin_dir }}/etcdctl --peers={{ etcd_access_addresses }} \
  27. set /{{ cluster_name }}/network/config \
  28. '{ "Network": "{{ kube_pods_subnet }}", "SubnetLen": {{ kube_network_node_prefix }}, "Backend": { "Type": "{{ flannel_backend_type }}" } }'
  29. delegate_to: "{{groups['etcd'][0]}}"
  30. run_once: true
  31. - name: Canal | Write canal configmap
  32. template:
  33. src: canal-config.yml.j2
  34. dest: "{{kube_config_dir}}/canal-config.yaml"
  35. - name: Canal | Write canal node configuration
  36. template:
  37. src: canal-node.yml.j2
  38. dest: "{{kube_config_dir}}/canal-node.yaml"
  39. register: canal_node_manifest
  40. - name: Canal | Copy cni plugins from hyperkube
  41. command: "{{ docker_bin_dir }}/docker run --rm -v /opt/cni/bin:/cnibindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /usr/bin/rsync -ac /opt/cni/bin/ /cnibindir/"
  42. register: cni_task_result
  43. until: cni_task_result.rc == 0
  44. retries: 4
  45. delay: "{{ retry_stagger | random + 3 }}"
  46. changed_when: false
  47. tags: [hyperkube, upgrade]
  48. - name: Canal | Copy cni plugins from calico/cni
  49. command: "{{ docker_bin_dir }}/docker run --rm -v /opt/cni/bin:/cnibindir {{ calico_cni_image_repo }}:{{ calico_cni_image_tag }} sh -c 'cp -a /opt/cni/bin/* /cnibindir/'"
  50. register: cni_task_result
  51. until: cni_task_result.rc == 0
  52. retries: 4
  53. delay: "{{ retry_stagger | random + 3 }}"
  54. changed_when: false
  55. tags: [hyperkube, upgrade]
  56. - name: Canal | Set cni directory permissions
  57. file:
  58. path: /opt/cni/bin
  59. state: directory
  60. owner: kube
  61. recurse: true
  62. mode: 0755
  63. - name: Canal | Install calicoctl container script
  64. template:
  65. src: calicoctl-container.j2
  66. dest: "{{ bin_dir }}/calicoctl"
  67. mode: 0755
  68. owner: root
  69. group: root
  70. changed_when: false
  71. - name: Canal | Create network policy directory
  72. file:
  73. path: "{{ canal_policy_dir }}"
  74. state: directory