2022-04-08 15:02:42 +08:00
|
|
|
---
|
|
|
|
- name: Calico | Check if calico apiserver exists
|
|
|
|
command: "{{ kubectl }} -n calico-apiserver get secret calico-apiserver-certs"
|
|
|
|
register: calico_apiserver_secret
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
- name: Calico | Create ns manifests
|
|
|
|
template:
|
|
|
|
src: "calico-apiserver-ns.yml.j2"
|
|
|
|
dest: "{{ kube_config_dir }}/calico-apiserver-ns.yml"
|
2024-07-26 09:42:20 +08:00
|
|
|
mode: "0644"
|
2022-04-08 15:02:42 +08:00
|
|
|
|
|
|
|
- name: Calico | Apply ns manifests
|
|
|
|
kube:
|
|
|
|
kubectl: "{{ bin_dir }}/kubectl"
|
|
|
|
filename: "{{ kube_config_dir }}/calico-apiserver-ns.yml"
|
|
|
|
state: "latest"
|
|
|
|
|
|
|
|
- name: Calico | Ensure calico certs dir
|
|
|
|
file:
|
|
|
|
path: /etc/calico/certs
|
|
|
|
state: directory
|
2024-07-26 09:42:20 +08:00
|
|
|
mode: "0755"
|
2022-04-08 15:02:42 +08:00
|
|
|
when: calico_apiserver_secret.rc != 0
|
|
|
|
|
|
|
|
- name: Calico | Copy ssl script for apiserver certs
|
|
|
|
template:
|
|
|
|
src: make-ssl-calico.sh.j2
|
|
|
|
dest: "{{ bin_dir }}/make-ssl-apiserver.sh"
|
2024-07-26 09:42:20 +08:00
|
|
|
mode: "0755"
|
2022-04-08 15:02:42 +08:00
|
|
|
when: calico_apiserver_secret.rc != 0
|
|
|
|
|
|
|
|
- name: Calico | Copy ssl config for apiserver certs
|
|
|
|
copy:
|
|
|
|
src: openssl.conf
|
|
|
|
dest: /etc/calico/certs/openssl.conf
|
2024-07-26 09:42:20 +08:00
|
|
|
mode: "0644"
|
2022-04-08 15:02:42 +08:00
|
|
|
when: calico_apiserver_secret.rc != 0
|
|
|
|
|
|
|
|
- name: Calico | Generate apiserver certs
|
|
|
|
command: >-
|
|
|
|
{{ bin_dir }}/make-ssl-apiserver.sh
|
|
|
|
-f /etc/calico/certs/openssl.conf
|
|
|
|
-c {{ kube_cert_dir }}
|
|
|
|
-d /etc/calico/certs
|
|
|
|
-s apiserver
|
|
|
|
when: calico_apiserver_secret.rc != 0
|
|
|
|
|
|
|
|
- name: Calico | Create calico apiserver generic secrets
|
|
|
|
command: >-
|
|
|
|
{{ kubectl }} -n calico-apiserver
|
|
|
|
create secret generic {{ item.name }}
|
|
|
|
--from-file={{ item.cert }}
|
|
|
|
--from-file={{ item.key }}
|
|
|
|
with_items:
|
|
|
|
- name: calico-apiserver-certs
|
|
|
|
cert: /etc/calico/certs/apiserver.crt
|
|
|
|
key: /etc/calico/certs/apiserver.key
|
|
|
|
when: calico_apiserver_secret.rc != 0
|