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.

96 lines
3.0 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. - name: Canal | Create canal node manifests
  35. template:
  36. src: "{{item.file}}.j2"
  37. dest: "{{kube_config_dir}}/{{item.file}}"
  38. with_items:
  39. - {name: canal-config, file: canal-config.yaml, type: cm}
  40. - {name: canal-node, file: canal-node.yaml, type: ds}
  41. - {name: canal, file: canal-node-sa.yml, type: sa}
  42. - {name: calico, file: canal-cr-calico.yml, type: clusterrole}
  43. - {name: flannel, file: canal-cr-flannel.yml, type: clusterrole}
  44. - {name: canal-calico, file: canal-crb-calico.yml, type: clusterrolebinding}
  45. - {name: canal-flannel, file: canal-crb-flannel.yml, type: clusterrolebinding}
  46. register: canal_manifests
  47. when:
  48. - inventory_hostname in groups['kube-master']
  49. - rbac_enabled or item.type not in rbac_resources
  50. - name: Canal | Copy cni plugins from hyperkube
  51. command: "{{ docker_bin_dir }}/docker run --rm -v /opt/cni/bin:/cnibindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /bin/cp -r /opt/cni/bin/. /cnibindir/"
  52. register: cni_task_result
  53. until: cni_task_result.rc == 0
  54. retries: 4
  55. delay: "{{ retry_stagger | random + 3 }}"
  56. changed_when: false
  57. tags:
  58. - hyperkube
  59. - upgrade
  60. - name: Canal | Copy cni plugins from calico/cni
  61. 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/'"
  62. register: cni_task_result
  63. until: cni_task_result.rc == 0
  64. retries: 4
  65. delay: "{{ retry_stagger | random + 3 }}"
  66. changed_when: false
  67. tags:
  68. - hyperkube
  69. - upgrade
  70. - name: Canal | Set cni directory permissions
  71. file:
  72. path: /opt/cni/bin
  73. state: directory
  74. owner: kube
  75. recurse: true
  76. mode: 0755
  77. - name: Canal | Install calicoctl container script
  78. template:
  79. src: calicoctl-container.j2
  80. dest: "{{ bin_dir }}/calicoctl"
  81. mode: 0755
  82. owner: root
  83. group: root
  84. - name: Canal | Create network policy directory
  85. file:
  86. path: "{{ canal_policy_dir }}"
  87. state: directory