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.

99 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 }}/node-{{ inventory_hostname }}.pem"
  36. ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/node-{{ inventory_hostname }}-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. - rbac_enabled or item.type not in rbac_resources
  53. - name: Canal | Copy cni plugins from hyperkube
  54. 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/"
  55. register: cni_task_result
  56. until: cni_task_result.rc == 0
  57. retries: 4
  58. delay: "{{ retry_stagger | random + 3 }}"
  59. changed_when: false
  60. tags:
  61. - hyperkube
  62. - upgrade
  63. - name: Canal | Copy cni plugins from calico/cni
  64. 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/'"
  65. register: cni_task_result
  66. until: cni_task_result.rc == 0
  67. retries: 4
  68. delay: "{{ retry_stagger | random + 3 }}"
  69. changed_when: false
  70. tags:
  71. - hyperkube
  72. - upgrade
  73. - name: Canal | Set cni directory permissions
  74. file:
  75. path: /opt/cni/bin
  76. state: directory
  77. owner: kube
  78. recurse: true
  79. mode: 0755
  80. - name: Canal | Install calicoctl container script
  81. template:
  82. src: calicoctl-container.j2
  83. dest: "{{ bin_dir }}/calicoctl"
  84. mode: 0755
  85. owner: root
  86. group: root
  87. - name: Canal | Create network policy directory
  88. file:
  89. path: "{{ canal_policy_dir }}"
  90. state: directory