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.

98 lines
3.2 KiB

  1. ---
  2. - name: Canal | Write Canal cni config
  3. template:
  4. src: "cni-canal.conflist.j2"
  5. dest: "/etc/cni/net.d/10-canal.conflist"
  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. retries: 4
  30. delay: "{{ retry_stagger | random + 3 }}"
  31. delegate_to: "{{groups['etcd'][0]}}"
  32. changed_when: false
  33. run_once: true
  34. environment:
  35. ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/admin-{{ groups['etcd'][0] }}.pem"
  36. ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/admin-{{ groups['etcd'][0] }}-key.pem"
  37. - name: Canal | Create canal node manifests
  38. template:
  39. src: "{{item.file}}.j2"
  40. dest: "{{kube_config_dir}}/{{item.file}}"
  41. with_items:
  42. - {name: canal-config, file: canal-config.yaml, type: cm}
  43. - {name: canal-node, file: canal-node.yaml, type: ds}
  44. - {name: canal, file: canal-node-sa.yml, type: sa}
  45. - {name: calico, file: canal-cr-calico.yml, type: clusterrole}
  46. - {name: flannel, file: canal-cr-flannel.yml, type: clusterrole}
  47. - {name: canal-calico, file: canal-crb-calico.yml, type: clusterrolebinding}
  48. - {name: canal-flannel, file: canal-crb-flannel.yml, type: clusterrolebinding}
  49. register: canal_manifests
  50. when:
  51. - inventory_hostname in groups['kube-master']
  52. - name: Canal | Copy cni plugins from hyperkube
  53. command: "{{ docker_bin_dir }}/docker run --rm -v /opt/cni/bin:/cnibindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /bin/cp -rf /opt/cni/bin/. /cnibindir/"
  54. register: cni_task_result
  55. until: cni_task_result.rc == 0
  56. retries: 4
  57. delay: "{{ retry_stagger | random + 3 }}"
  58. changed_when: false
  59. tags:
  60. - hyperkube
  61. - upgrade
  62. - name: Canal | Copy cni plugins from calico/cni
  63. command: "{{ docker_bin_dir }}/docker run --rm -v /opt/cni/bin:/cnibindir {{ calico_cni_image_repo }}:{{ calico_cni_image_tag }} sh -c 'cp /opt/cni/bin/* /cnibindir/'"
  64. register: cni_task_result
  65. until: cni_task_result.rc == 0
  66. retries: 4
  67. delay: "{{ retry_stagger | random + 3 }}"
  68. changed_when: false
  69. tags:
  70. - hyperkube
  71. - upgrade
  72. - name: Canal | Set cni directory permissions
  73. file:
  74. path: /opt/cni/bin
  75. state: directory
  76. owner: kube
  77. recurse: true
  78. mode: 0755
  79. - name: Canal | Install calicoctl container script
  80. template:
  81. src: calicoctl-container.j2
  82. dest: "{{ bin_dir }}/calicoctl"
  83. mode: 0755
  84. owner: root
  85. group: root
  86. - name: Canal | Create network policy directory
  87. file:
  88. path: "{{ canal_policy_dir }}"
  89. state: directory