2016-11-03 15:57:11 +00:00
|
|
|
---
|
2016-11-14 12:03:54 +00:00
|
|
|
- name: Canal | Write Canal cni config
|
|
|
|
template:
|
2017-10-16 06:11:38 +00:00
|
|
|
src: "cni-canal.conflist.j2"
|
|
|
|
dest: "/etc/cni/net.d/10-canal.conflist"
|
2017-02-06 12:58:54 +00:00
|
|
|
owner: kube
|
2016-11-14 12:03:54 +00:00
|
|
|
|
|
|
|
- name: Canal | Create canal certs directory
|
|
|
|
file:
|
|
|
|
dest: "{{ canal_cert_dir }}"
|
|
|
|
state: directory
|
|
|
|
mode: 0750
|
2017-02-06 12:58:54 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
2016-11-14 12:03:54 +00:00
|
|
|
|
|
|
|
- name: Canal | Link etcd certificates for canal-node
|
|
|
|
file:
|
|
|
|
src: "{{ etcd_cert_dir }}/{{ item.s }}"
|
|
|
|
dest: "{{ canal_cert_dir }}/{{ item.d }}"
|
|
|
|
state: hard
|
2016-12-07 16:03:04 +00:00
|
|
|
force: yes
|
2016-11-14 12:03:54 +00:00
|
|
|
with_items:
|
|
|
|
- {s: "ca.pem", d: "ca_cert.crt"}
|
2016-12-13 09:03:35 +00:00
|
|
|
- {s: "node-{{ inventory_hostname }}.pem", d: "cert.crt"}
|
|
|
|
- {s: "node-{{ inventory_hostname }}-key.pem", d: "key.pem"}
|
2016-11-14 12:03:54 +00:00
|
|
|
|
2016-11-10 09:49:47 +00:00
|
|
|
- name: Canal | Set Flannel etcd configuration
|
|
|
|
command: |-
|
|
|
|
{{ bin_dir }}/etcdctl --peers={{ etcd_access_addresses }} \
|
|
|
|
set /{{ cluster_name }}/network/config \
|
|
|
|
'{ "Network": "{{ kube_pods_subnet }}", "SubnetLen": {{ kube_network_node_prefix }}, "Backend": { "Type": "{{ flannel_backend_type }}" } }'
|
2017-11-28 16:39:55 +00:00
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
2016-11-10 09:49:47 +00:00
|
|
|
delegate_to: "{{groups['etcd'][0]}}"
|
2017-10-25 20:19:40 +00:00
|
|
|
changed_when: false
|
2016-11-10 09:49:47 +00:00
|
|
|
run_once: true
|
2017-11-07 14:06:16 +00:00
|
|
|
environment:
|
2018-02-22 14:37:07 +00:00
|
|
|
ETCDCTL_CERT_FILE: "{{ etcd_cert_dir }}/node-{{ groups['etcd'][0] }}.pem"
|
|
|
|
ETCDCTL_KEY_FILE: "{{ etcd_cert_dir }}/node-{{ groups['etcd'][0] }}-key.pem"
|
2016-11-03 15:57:11 +00:00
|
|
|
|
2017-09-04 08:29:40 +00:00
|
|
|
- name: Canal | Create canal node manifests
|
2016-11-08 11:13:20 +00:00
|
|
|
template:
|
2017-09-04 08:29:40 +00:00
|
|
|
src: "{{item.file}}.j2"
|
|
|
|
dest: "{{kube_config_dir}}/{{item.file}}"
|
|
|
|
with_items:
|
|
|
|
- {name: canal-config, file: canal-config.yaml, type: cm}
|
|
|
|
- {name: canal-node, file: canal-node.yaml, type: ds}
|
|
|
|
- {name: canal, file: canal-node-sa.yml, type: sa}
|
|
|
|
- {name: calico, file: canal-cr-calico.yml, type: clusterrole}
|
|
|
|
- {name: flannel, file: canal-cr-flannel.yml, type: clusterrole}
|
|
|
|
- {name: canal-calico, file: canal-crb-calico.yml, type: clusterrolebinding}
|
|
|
|
- {name: canal-flannel, file: canal-crb-flannel.yml, type: clusterrolebinding}
|
|
|
|
register: canal_manifests
|
|
|
|
when:
|
|
|
|
- inventory_hostname in groups['kube-master']
|
|
|
|
- rbac_enabled or item.type not in rbac_resources
|
2016-11-03 15:57:11 +00:00
|
|
|
|
|
|
|
- name: Canal | Copy cni plugins from hyperkube
|
2017-10-05 09:51:21 +00:00
|
|
|
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/"
|
2016-11-03 15:57:11 +00:00
|
|
|
register: cni_task_result
|
|
|
|
until: cni_task_result.rc == 0
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
|
|
|
changed_when: false
|
2017-10-05 07:43:04 +00:00
|
|
|
tags:
|
|
|
|
- hyperkube
|
|
|
|
- upgrade
|
2016-11-03 15:57:11 +00:00
|
|
|
|
|
|
|
- name: Canal | Copy cni plugins from calico/cni
|
2017-10-25 20:19:40 +00:00
|
|
|
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/'"
|
2016-11-03 15:57:11 +00:00
|
|
|
register: cni_task_result
|
|
|
|
until: cni_task_result.rc == 0
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
|
|
|
changed_when: false
|
2017-10-05 07:43:04 +00:00
|
|
|
tags:
|
|
|
|
- hyperkube
|
|
|
|
- upgrade
|
2017-01-04 22:46:00 +00:00
|
|
|
|
2017-03-15 11:00:42 +00:00
|
|
|
- name: Canal | Set cni directory permissions
|
|
|
|
file:
|
|
|
|
path: /opt/cni/bin
|
|
|
|
state: directory
|
|
|
|
owner: kube
|
|
|
|
recurse: true
|
|
|
|
mode: 0755
|
|
|
|
|
2017-01-04 22:46:00 +00:00
|
|
|
- name: Canal | Install calicoctl container script
|
|
|
|
template:
|
|
|
|
src: calicoctl-container.j2
|
|
|
|
dest: "{{ bin_dir }}/calicoctl"
|
|
|
|
mode: 0755
|
|
|
|
owner: root
|
|
|
|
group: root
|
2017-01-04 22:51:11 +00:00
|
|
|
|
|
|
|
- name: Canal | Create network policy directory
|
|
|
|
file:
|
|
|
|
path: "{{ canal_policy_dir }}"
|
|
|
|
state: directory
|