2017-11-22 12:34:51 +08:00
|
|
|
- name: 创建calico 相关目录
|
|
|
|
file: name={{ item }} state=directory
|
|
|
|
with_items:
|
|
|
|
- /etc/calico/ssl
|
2018-01-02 22:12:51 +08:00
|
|
|
- /root/local/kube-system/calico
|
2017-11-11 19:14:21 +08:00
|
|
|
|
2017-12-04 20:20:17 +08:00
|
|
|
- name: 复制CA 证书到calico 证书目录
|
2017-12-05 09:59:56 +08:00
|
|
|
copy: src={{ ca_dir }}/ca.pem dest=/etc/calico/ssl/ca.pem
|
2017-12-04 20:20:17 +08:00
|
|
|
|
|
|
|
- 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"
|
2017-11-11 19:14:21 +08:00
|
|
|
|
2018-01-02 22:12:51 +08:00
|
|
|
- name: 准备 calico DaemonSet yaml文件
|
|
|
|
template: src=calico.yaml.j2 dest=/root/local/kube-system/calico/calico.yaml
|
2017-11-11 19:14:21 +08:00
|
|
|
|
2018-01-02 22:12:51 +08:00
|
|
|
- name: 准备 calico rbac文件
|
|
|
|
template: src=calico-rbac.yaml.j2 dest=/root/local/kube-system/calico/calico-rbac.yaml
|
2017-11-11 19:14:21 +08:00
|
|
|
|
2018-01-02 22:12:51 +08:00
|
|
|
# 只需单节点执行一次,重复执行的报错可以忽略
|
|
|
|
- name: 运行 calico网络
|
|
|
|
shell: "{{ bin_dir }}/kubectl create -f /root/local/kube-system/calico/ && sleep 15"
|
|
|
|
when: NODE_ID is defined and NODE_ID == "node1"
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
# 删除原有cni配置
|
|
|
|
- name: 删除默认cni配置
|
|
|
|
file: path=/etc/cni/net.d/10-default.conf state=absent
|
|
|
|
|
2018-01-05 23:05:22 +08:00
|
|
|
# 删除原有cni插件网卡mynet0
|
|
|
|
- name: 删除默认cni插件网卡mynet0
|
|
|
|
shell: "ip link del mynet0"
|
|
|
|
ignore_errors: true
|
|
|
|
|
2018-01-04 22:00:34 +08:00
|
|
|
# [可选]cni calico plugins 已经在calico.yaml完成自动安装
|
2018-01-02 22:12:51 +08:00
|
|
|
- name: 下载calicoctl 客户端
|
2017-11-11 19:14:21 +08:00
|
|
|
copy: src={{ base_dir }}/bin/{{ item }} dest={{ bin_dir }}/{{ item }} mode=0755
|
|
|
|
with_items:
|
2018-01-02 22:12:51 +08:00
|
|
|
#- calico
|
|
|
|
#- calico-ipam
|
|
|
|
#- loopback
|
2017-11-22 12:34:51 +08:00
|
|
|
- calicoctl
|
2017-11-11 19:14:21 +08:00
|
|
|
|
2017-11-22 12:34:51 +08:00
|
|
|
- name: 准备 calicoctl配置文件
|
|
|
|
template: src=calicoctl.cfg.j2 dest=/etc/calico/calicoctl.cfg
|