kubeasz/roles/calico/tasks/main.yml

45 lines
1.3 KiB
YAML

- name: 创建calico 相关目录
file: name={{ item }} state=directory
with_items:
- /etc/calico/ssl
- /etc/cni/net.d
- name: 复制CA 证书到calico 证书目录
copy: src=ca.pem dest=/etc/calico/ssl/ca.pem
- name: 创建calico 证书请求
template: src=calico-csr.json.j2 dest=/etc/calico/ssl/calico-csr.json
- name: 创建 calico证书和私钥
shell: "cd /etc/calico/ssl && {{ bin_dir }}/cfssl gencert \
-ca={{ ca_dir }}/ca.pem \
-ca-key={{ ca_dir }}/ca-key.pem \
-config={{ ca_dir }}/ca-config.json \
-profile=kubernetes calico-csr.json | {{ bin_dir }}/cfssljson -bare calico"
- name: 创建 calico 的 systemd unit 文件
template: src=calico-node.service.j2 dest=/etc/systemd/system/calico-node.service
- name: daemon-reload
shell: systemctl daemon-reload
- name: enable-calico
shell: systemctl enable calico-node
- name: 重新启动calico
shell: systemctl restart calico-node
- name: 下载calico cni plugins和calicoctl 客户端
copy: src={{ base_dir }}/bin/{{ item }} dest={{ bin_dir }}/{{ item }} mode=0755
with_items:
- calico
- calico-ipam
- loopback
- calicoctl
- name: 准备 calicoctl配置文件
template: src=calicoctl.cfg.j2 dest=/etc/calico/calicoctl.cfg
- name: 准备 cni配置文件
template: src=cni-calico.conf.j2 dest=/etc/cni/net.d/10-calico.conf